text: #include "pch.h"
  #include "Direct3DContentProvider.h"
  
  using namespace Direct3DUtilsComp;
  
  Direct3DContentProvider::Direct3DContentProvider(Direct3DUtilsComp::Direct3DInterop^ controller) :
  	m_controller(controller)
  {
  	m_controller->RequestAdditionalFrame += ref new RequestAdditionalFrameHandler([=] ()
  	{
  		if (m_host)
  		{
  			m_host->RequestAdditionalFrame();
  		}
  	});
  }
  
  // IDrawingSurfaceContentProviderNative interface
  HRESULT Direct3DContentProvider::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
  {
  	m_host = host;
  
  	return m_controller->Connect(host, device);
  }
  
  void Direct3DContentProvider::Disconnect()
  {
  	m_controller->Disconnect();
  	m_host = nullptr;
  }
  
  HRESULT Direct3DContentProvider::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize)
  {
  	return m_controller->PrepareResources(presentTargetTime, desiredRenderTargetSize);
  }
  
  HRESULT Direct3DContentProvider::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
  {
  	return m_controller->Draw(device, context, renderTargetView);
  }