Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
142 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "pch.h" | ||
#include "BitmapMap.h" | ||
|
||
using namespace Retrix::UWP::Native; | ||
using namespace Platform; | ||
|
||
BitmapMap::BitmapMap(CanvasDevice^ device, CanvasBitmap^ bitmap) | ||
{ | ||
d2dBitmap = GetWrappedResource<ID2D1Bitmap1, CanvasBitmap>(device, bitmap); | ||
__abi_ThrowIfFailed(d2dBitmap->Map(D2D1_MAP_OPTIONS_WRITE | D2D1_MAP_OPTIONS_DISCARD, &map)); | ||
} | ||
|
||
BitmapMap::~BitmapMap() | ||
{ | ||
__abi_ThrowIfFailed(d2dBitmap->Unmap()); | ||
} | ||
|
||
CanvasBitmap^ BitmapMap::CreateMappableBitmap(CanvasDrawingSession^ drawingSession, unsigned int width, unsigned int height) | ||
{ | ||
ComPtr<ID3D11Device> d3dDevice; | ||
__abi_ThrowIfFailed(GetDXGIInterface(drawingSession->Device, d3dDevice.GetAddressOf())); | ||
|
||
D3D11_TEXTURE2D_DESC texDesc = { 0 }; | ||
texDesc.Width = width; | ||
texDesc.Height = height; | ||
texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; | ||
texDesc.MipLevels = 1; | ||
texDesc.ArraySize = 1; | ||
texDesc.SampleDesc.Count = 1; | ||
texDesc.SampleDesc.Quality = 0; | ||
texDesc.Usage = D3D11_USAGE_DYNAMIC; | ||
texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; | ||
texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; | ||
texDesc.MiscFlags = 0; | ||
|
||
ComPtr<ID3D11Texture2D> d3dTexture; | ||
__abi_ThrowIfFailed(d3dDevice->CreateTexture2D(&texDesc, nullptr, d3dTexture.GetAddressOf())); | ||
|
||
ComPtr<IDXGISurface> d3dSurface; | ||
__abi_ThrowIfFailed(d3dTexture.As(&d3dSurface)); | ||
|
||
auto winRTSurface = CreateDirect3DSurface(d3dSurface.Get()); | ||
auto output = CanvasBitmap::CreateFromDirect3D11Surface(drawingSession, winRTSurface); | ||
return output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
using namespace Microsoft::Graphics::Canvas; | ||
using namespace Microsoft::WRL; | ||
using namespace Platform; | ||
using namespace Windows::Graphics::DirectX::Direct3D11; | ||
|
||
namespace Retrix | ||
{ | ||
namespace UWP | ||
{ | ||
namespace Native | ||
{ | ||
public ref class BitmapMap sealed | ||
{ | ||
#ifdef _WIN64 | ||
typedef int64 UnsafeIntPtr; | ||
#else | ||
typedef int32 UnsafeIntPtr; | ||
#endif | ||
private: | ||
ComPtr<ID2D1Bitmap1> d2dBitmap; | ||
D2D1_MAPPED_RECT map; | ||
|
||
public: | ||
property uint32 PitchBytes { uint32 get() { return map.pitch; } } | ||
property UnsafeIntPtr Data { UnsafeIntPtr get() { return (UnsafeIntPtr)map.bits; } } | ||
|
||
BitmapMap(CanvasDevice^ device, CanvasBitmap^ bitmap); | ||
virtual ~BitmapMap(); | ||
|
||
static CanvasBitmap^ CreateMappableBitmap(CanvasDrawingSession^ drawingSession, unsigned int width, unsigned int height); | ||
}; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.