#pragma once

#include <flutter/texture_registrar.h>

#include "rendering/texture_bridge.h"

namespace coreframe_flutter_windows {

class TextureBridgeGpu : public TextureBridge {
public:
  TextureBridgeGpu(GraphicsContext *graphics_context,
                   ABI::Windows::UI::Composition::IVisual *visual);

  const FlutterDesktopGpuSurfaceDescriptor *GetSurfaceDescriptor(size_t width,
                                                                 size_t height);

protected:
  void StopInternal() override;

private:
  FlutterDesktopGpuSurfaceDescriptor surface_descriptor_ = {};
  Size surface_size_ = {0, 0};
  winrt::com_ptr<ID3D11Texture2D> surface_{nullptr};
  winrt::com_ptr<IDXGIResource> dxgi_surface_;

  bool ProcessFrame(winrt::com_ptr<ID3D11Texture2D> src_texture);
  bool EnsureSurface(uint32_t width, uint32_t height);
};

} // namespace coreframe_flutter_windows
