Path: blob/master/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.h
16349 views
#pragma once12#include "pch.h"3#include "BasicTimer.h"4#include "CubeRenderer.h"5#include <DrawingSurfaceNative.h>6#include <ppltasks.h>7#include <windows.storage.streams.h>8#include <opencv2\core\core.hpp>9#include <opencv2\imgproc\imgproc.hpp>10#include <opencv2\features2d\features2d.hpp>1112namespace PhoneXamlDirect3DApp1Comp13{1415public enum class OCVFilterType16{17ePreview,18eGray,19eCanny,20eSepia,21eNumOCVFilterTypes22};2324public delegate void RequestAdditionalFrameHandler();25public delegate void RecreateSynchronizedTextureHandler();2627[Windows::Foundation::Metadata::WebHostHidden]28public ref class Direct3DInterop sealed : public Windows::Phone::Input::Interop::IDrawingSurfaceManipulationHandler29{30public:31Direct3DInterop();3233Windows::Phone::Graphics::Interop::IDrawingSurfaceContentProvider^ CreateContentProvider();3435// IDrawingSurfaceManipulationHandler36virtual void SetManipulationHost(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ manipulationHost);3738event RequestAdditionalFrameHandler^ RequestAdditionalFrame;39event RecreateSynchronizedTextureHandler^ RecreateSynchronizedTexture;4041property Windows::Foundation::Size WindowBounds;42property Windows::Foundation::Size NativeResolution;43property Windows::Foundation::Size RenderResolution44{45Windows::Foundation::Size get(){ return m_renderResolution; }46void set(Windows::Foundation::Size renderResolution);47}48void CreateTexture(const Platform::Array<int>^ buffer, int with, int height, OCVFilterType filter);495051protected:52// Event Handlers53void OnPointerPressed(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);54void OnPointerMoved(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);55void OnPointerReleased(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);5657internal:58HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host);59void STDMETHODCALLTYPE Disconnect();60HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty);61HRESULT STDMETHODCALLTYPE GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle);62ID3D11Texture2D* GetTexture();6364private:65CubeRenderer^ m_renderer;66BasicTimer^ m_timer;67Windows::Foundation::Size m_renderResolution;6869void ApplyGrayFilter(const cv::Mat& image);70void ApplyCannyFilter(const cv::Mat& image);71void ApplySepiaFilter(const cv::Mat& image);7273void UpdateImage(const cv::Mat& image);7475cv::Mat Lena;76unsigned int frameWidth, frameHeight;77};7879}808182