/// <summary>
         /// Ensures the bitmap cache.
         /// </summary>
         /// <param name="context">The context.</param>
         /// <param name="size">The size.</param>
         /// <param name="maxSize">The maximum size.</param>
         private void EnsureBitmapCache(RenderContext2D context, Size2 size, int maxSize)
         {
             IsBitmapCacheValid = false;
             if (size.Width <= 0 || size.Height <= 0 || !EnableBitmapCache || size.Width * size.Height < MinimumBitmapSize)
             {
                 Disposer.RemoveAndDispose(ref bitmapCache);
             }
             else if (size.Width > maxSize || size.Height > maxSize)
             {
                 return;
             }
             else if (bitmapCache == null || size.Width > bitmapCache.Size.Width || size.Height > bitmapCache.Size.Height)
             {
 #if DEBUGCACHECREATE
                 Debug.WriteLine("Create new bitmap cache.");
 #endif
                 Disposer.RemoveAndDispose(ref bitmapCache);
                 bitmapCache        = BitmapProxy.Create("Cache", context.DeviceContext, size, Format.B8G8R8A8_UNorm);
                 IsBitmapCacheValid = true;
                 IsVisualDirty      = true;
             }
             else
             {
                 IsBitmapCacheValid = true;
             }
         }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="texture"></param>
 /// <param name="deviceContext"></param>
 public void Initialize(Texture2D texture, DeviceContext2D deviceContext)
 {
     RemoveAndDispose(ref d2DTarget);
     using (var surface = texture.QueryInterface <global::SharpDX.DXGI.Surface>())
     {
         d2DTarget = Collect(BitmapProxy.Create("TextureTarget", deviceContext, surface));
     }
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="swapChain"></param>
 /// <param name="deviceContext"></param>
 public void Initialize(SwapChain1 swapChain, DeviceContext2D deviceContext)
 {
     RemoveAndDispose(ref d2DTarget);
     using (var surf = swapChain.GetBackBuffer <Surface>(0))
     {
         d2DTarget = Collect(BitmapProxy.Create("SwapChainTarget", deviceContext, surf));
     }
 }