OSDN Git Service

D2DContext1 を追加。
authorくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Sep 2016 16:21:55 +0000 (01:21 +0900)
committerくまかみ工房 <kumakamikoubou@gmail.com>
Sat, 17 Sep 2016 16:21:55 +0000 (01:21 +0900)
FDK24/メディア/デバイスリソース.cs

index 895b4ed..53b29e4 100644 (file)
@@ -48,6 +48,7 @@ namespace FDK.メディア
                public SharpDX.DirectWrite.Factory DWriteFactory => this.bs_DWriteFactory;
                public SharpDX.WIC.ImagingFactory2 WicImagingFactory2 => this.bs_WicImagingFactory2;
                public SharpDX.Direct2D1.Device1 D2DDevice1 => this.bs_D2DDevice1;
+               public SharpDX.Direct2D1.DeviceContext1 D2DContext1 => this.bs_D2DContext1;
 
                public void すべてのリソースを作成する( System.Drawing.Size バックバッファサイズ, IntPtr ウィンドウハンドル )
                {
@@ -212,6 +213,14 @@ namespace FDK.メディア
                                }
                                //-----------------
                                #endregion
+                               #region " D2Dの既定のコンテキスト D2DContext1 を作成する。"
+                               //-----------------
+                               this.bs_D2DContext1 = new SharpDX.Direct2D1.DeviceContext1( this.D2DDevice1, SharpDX.Direct2D1.DeviceContextOptions.None );
+
+                               // 現在のディスプレイDPI を取得し、D2DContext に設定する。
+                               this.D2DContext1.DotsPerInch = this.D2DFactory2.DesktopDpi;
+                               //-----------------
+                               #endregion
                        }
 
                        this.サイズに依存するリソースを作成する();
@@ -222,18 +231,19 @@ namespace FDK.メディア
                        FDK.Utilities.解放する( ref this.bs_DWriteFactory );
                        FDK.Utilities.解放する( ref this.bs_D2DFactory2 );
 
+                       // D2D 関連
+                       FDK.Utilities.解放する( ref this.bs_D2DContext1 );
+                       FDK.Utilities.解放する( ref this.bs_D2DDevice1 );
+
+                       // D3D 関連
                        var d3dDevice = (SharpDX.Direct3D11.Device) null;
                        using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.DXGIDeviceManager, out d3dDevice ) )
                        {
-                               // デバイスステートをクリアする。
-                               d3dDevice.ImmediateContext?.ClearState();
-
-                               // スワップチェインをウインドウモードにする。
-                               this.bs_SwapChain?.SetFullscreenState( fullscreen: false, targetRef: null );
+                               d3dDevice.ImmediateContext?.ClearState();   // デバイスステートをクリアする。
+                               this.bs_SwapChain?.SetFullscreenState( fullscreen: false, targetRef: null );    // スワップチェインをウインドウモードにする。
 
                                this.サイズに依存するリソースを解放する();
 
-                               // 取得したインターフェイスの開放
                                FDK.Utilities.解放する( ref this.bs_D3DDepthStencilState );
                                FDK.Utilities.解放する( ref this.bs_SwapChain );
                                this.bs_DXGIDeviceManager?.ResetDevice( null );
@@ -380,6 +390,7 @@ namespace FDK.メディア
                private SharpDX.Direct3D11.Texture2D bs_D3DDepthStencil = null;
                private SharpDX.Direct3D11.DepthStencilView bs_D3DDepthStencilView = null;
                private SharpDX.Direct2D1.Device1 bs_D2DDevice1 = null;
+               private SharpDX.Direct2D1.DeviceContext1 bs_D2DContext1 = null;
                //----------------
                #endregion
        }