Ejemplo n.º 1
0
        private IDeviceBitmap GetOrCreateDeviceBitmap(IDeviceResourceFactory factory, SizeInt32 desiredPixelSize)
        {
            base.VerifyAccess();
            IDeviceBitmap result = null;
            int           num    = Int32Util.Pow2RoundUp(desiredPixelSize.Width);
            int           num2   = Int32Util.Pow2RoundUp(desiredPixelSize.Height);
            int           width  = Math.Max(Math.Max(num, num2), 0x100);
            SizeInt32     num5   = new SizeInt32(width, width);

            while (this.deviceBitmapPool.TryDequeue(out result))
            {
                SizeInt32 pixelSize = result.PixelSize;
                if (((pixelSize.Width >= num5.Width) && (pixelSize.Width <= (num5.Width * 2))) && ((pixelSize.Height >= num5.Height) && (pixelSize.Height <= (num5.Height * 2))))
                {
                    break;
                }
                DisposableUtil.Free <IDeviceBitmap>(ref result);
            }
            if (result == null)
            {
                result = factory.CreateDeviceBitmap(desiredPixelSize, maskBitmapProperties);
                AttachedData.SetValue(result, isPooledBitmapAttachedKey, BooleanUtil.GetBoxed(true));
            }
            return(result);
        }
Ejemplo n.º 2
0
 private void GetInitializedRenderBitmaps(IDeviceResourceFactory factory, out IDeviceBitmap interiorDeviceBitmap, out IDeviceBitmap blackDashedOutlineDeviceBitmap, out IDeviceBitmap whiteDashedOutlineDeviceBitmap)
 {
     interiorDeviceBitmap           = this.InitializeDeviceBitmap(factory, this.renderedInteriorMask, ref this.renderedInteriorDeviceBitmap);
     blackDashedOutlineDeviceBitmap = null;
     whiteDashedOutlineDeviceBitmap = null;
     if (this.renderedDashedOutlineMasks != null)
     {
         int num   = this.renderedRenderParams.IsOutlineAnimated ? base.Owner.GetOutlineDashOffset(base.CanvasView) : 0;
         int index = num % SelectionCanvasLayer.DashLength;
         int num3  = (num + (SelectionCanvasLayer.DashLength / 2)) % SelectionCanvasLayer.DashLength;
         if (this.renderedDashedOutlineDeviceBitmaps == null)
         {
             this.renderedDashedOutlineDeviceBitmaps = new IDeviceBitmap[this.renderedDashedOutlineMasks.Length];
         }
         blackDashedOutlineDeviceBitmap = this.InitializeDeviceBitmap(factory, this.renderedDashedOutlineMasks[index], ref this.renderedDashedOutlineDeviceBitmaps[index]);
         whiteDashedOutlineDeviceBitmap = this.InitializeDeviceBitmap(factory, this.renderedDashedOutlineMasks[num3], ref this.renderedDashedOutlineDeviceBitmaps[num3]);
     }
 }
Ejemplo n.º 3
0
 private IDeviceBitmap InitializeDeviceBitmap(IDeviceResourceFactory factory, IBitmap bitmap, ref IDeviceBitmap deviceBitmap)
 {
     if (bitmap == null)
     {
         this.ReturnOrFreeDeviceBitmap(ref deviceBitmap);
         return(deviceBitmap);
     }
     if ((bitmap != null) && (deviceBitmap == null))
     {
         if (factory.IsSupported(RenderTargetType.Software, null, null, null))
         {
             SizeInt32   num        = bitmap.Size;
             IBitmapLock bitmapLock = bitmap.Lock(BitmapLockOptions.Read);
             deviceBitmap = factory.CreateSharedBitmap(bitmapLock, new BitmapProperties?(maskBitmapProperties));
             return(deviceBitmap);
         }
         SizeInt32 size = bitmap.Size;
         deviceBitmap = this.GetOrCreateDeviceBitmap(factory, size);
         deviceBitmap.CopyFromBitmap(new PointInt32?(PointInt32.Zero), bitmap, new RectInt32(PointInt32.Zero, size));
     }
     return(deviceBitmap);
 }
 public static IDeviceResourceFactory CreateRef(this IDeviceResourceFactory objectRef) =>
 ((IDeviceResourceFactory)objectRef.CreateRef(typeof(IDeviceResourceFactory)));