// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3

#pragma once

#include "imgui.h"

namespace dragonx {
namespace util {

// Returns a cached noise texture (created on first call).
// The texture is a 256x256 tileable white-noise pattern with
// per-pixel random alpha (0-255) designed to be overlaid at very
// low opacity to give cards a subtle grain / paper texture.
//
// texSize receives 256 (the width/height of the texture).
ImTextureID GetNoiseTexture(int* texSize = nullptr);

// Returns a viewport-sized pre-tiled noise texture (single draw call).
// The 256x256 base noise is tiled across the given viewport dimensions.
// Re-creates the texture when the viewport size changes.
// outW/outH receive the actual texture dimensions.
ImTextureID GetTiledNoiseTexture(int viewportW, int viewportH,
                                 int* outW = nullptr, int* outH = nullptr);

// Draw a tiled noise overlay in a single AddImage call.
// Uses the pre-tiled viewport-sized texture — call this instead of
// manually looping with AddImage for each tile.
// dl: draw list, pMin/pMax: rect to cover, tintColor: alpha-premultiplied tint.
void DrawTiledNoiseRect(ImDrawList* dl, const ImVec2& pMin, const ImVec2& pMax,
                        ImU32 tintColor);

} // namespace util
} // namespace dragonx
