示例#1
1
        protected void Blit(D3D9.Device d3d9Device, HardwarePixelBuffer rsrc, BasicBox srcBox, BasicBox dstBox,
                            BufferResources srcBufferResources, BufferResources dstBufferResources)
        {
            if (dstBufferResources.Surface != null && srcBufferResources.Surface != null)
            {
                // Surface-to-surface
                var dsrcRect  = ToD3DRectangle(srcBox);
                var ddestRect = ToD3DRectangle(dstBox);

                var srcDesc = srcBufferResources.Surface.Description;

                // If we're blitting from a RTT, try GetRenderTargetData
                // if we're going to try to use GetRenderTargetData, need to use system mem pool

                // romeoxbm: not used even in Ogre
                //var tryGetRenderTargetData = false;

                if ((srcDesc.Usage & D3D9.Usage.RenderTarget) != 0 && srcDesc.MultiSampleType == D3D9.MultisampleType.None)
                {
                    // Temp texture
                    var tmptex = new D3D9.Texture(d3d9Device, srcDesc.Width, srcDesc.Height, 1,
                                                  // 1 mip level ie topmost, generate no mipmaps
                                                  0, srcDesc.Format, D3D9.Pool.SystemMemory);

                    var tmpsurface = tmptex.GetSurfaceLevel(0);

                    d3d9Device.GetRenderTargetData(srcBufferResources.Surface, tmpsurface);
                    D3D9.Surface.FromSurface(dstBufferResources.Surface, tmpsurface, D3D9.Filter.Default, 0, dsrcRect,
                                             ddestRect);
                    tmpsurface.SafeDispose();
                    tmptex.SafeDispose();
                    return;
                }

                // Otherwise, try the normal method
                D3D9.Surface.FromSurface(dstBufferResources.Surface, srcBufferResources.Surface, D3D9.Filter.Default, 0,
                                         dsrcRect, ddestRect);
            }
            else if (dstBufferResources.Volume != null && srcBufferResources.Volume != null)
            {
                // Volume-to-volume
                var dsrcBox  = ToD3DBox(srcBox);
                var ddestBox = ToD3DBox(dstBox);

                D3D9.Volume.FromVolume(dstBufferResources.Volume, srcBufferResources.Volume, D3D9.Filter.Default, 0,
                                       dsrcBox, ddestBox);
            }
            else
            {
                // Software fallback
                base.Blit(rsrc, srcBox, dstBox);
            }
        }
示例#2
0
        public void Blit(ref PixelBox src, BasicBox dstBox)
        {
            var srcBox = src;

            if (srcBox.Width != dstBox.Width || srcBox.Height != dstBox.Height)
            {
                // we need to rescale src to dst size first (also confvert format)
                var tmpData = new float[dstBox.Width * dstBox.Height];
                srcBox = new PixelBox(dstBox.Width, dstBox.Height, 1, PixelFormat.L8, BufferBase.Wrap(tmpData, tmpData.Length * sizeof(float)));
                Image.Scale(src, srcBox);
            }

            //pixel conversion
            var dstMemBox = new PixelBox(dstBox.Width, dstBox.Height, dstBox.Depth, PixelFormat.L8, BufferBase.Wrap(this.mData, mData.Length * sizeof(float)));

            PixelConverter.BulkPixelConversion(src, dstMemBox);

            if (srcBox != src)
            {
                // free temp
                srcBox = null;
            }
            var dRect = new Rectangle(dstBox.Left, dstBox.Top, dstBox.Right, dstBox.Bottom);

            DirtyRect(dRect);
        }
示例#3
0
        protected void Download()
        {
#if !AXIOM_SAFE_ONLY
            unsafe
#endif
            {
                using (var pDst = BufferBase.Wrap(this.mData, mData.Length * sizeof(float)))
                {
                    var pDstPtr = pDst.ToFloatPointer();
                    var pDstIdx = 0;
                    //download data
                    var box     = new BasicBox(0, 0, this.mBuffer.Width, this.mBuffer.Height);
                    var pBox    = this.mBuffer.Lock(box, BufferLocking.ReadOnly);
                    var pSrc    = pBox.Data.ToBytePointer();
                    var pSrcIdx = (int)this.mChannelOffset;
                    var srcInc  = PixelUtil.GetNumElemBytes(this.mBuffer.Format);
                    for (var y = box.Top; y < box.Bottom; ++y)
                    {
                        for (var x = box.Left; x < box.Right; ++x)
                        {
                            pDstPtr[pDstIdx++] = (float)((pSrc[pSrcIdx]) / 255.0f);
                            pSrcIdx           += srcInc;
                        }
                    }
                    this.mBuffer.Unlock();
                }
            }
        }
示例#4
0
        /// <summary>
        /// </summary>
        /// <param name="srcBox"> </param>
        /// <param name="dst"> </param>
        public override void BlitToMemory(BasicBox srcBox, PixelBox dst)
        {
            if (!this._buffer.Contains(srcBox))
            {
                throw new ArgumentOutOfRangeException("source boux out of range");
            }

            if (srcBox.Left == 0 && srcBox.Right == Width && srcBox.Top == 0 && srcBox.Bottom == Height && srcBox.Front == 0 && srcBox.Back == Depth && dst.Width == Width && dst.Height == Height && dst.Depth == Depth && GLESPixelUtil.GetGLOriginFormat(dst.Format) != 0)
            {
                // The direct case: the user wants the entire texture in a format supported by GL
                // so we don't need an intermediate buffer
                Download(dst);
            }
            else
            {
                // Use buffer for intermediate copy
                AllocateBuffer();
                //download entire buffer
                Download(this._buffer);
                if (srcBox.Width != dst.Width || srcBox.Height != dst.Height || srcBox.Depth != dst.Depth)
                {
                    // we need scaling
                    Image.Scale(this._buffer.GetSubVolume(srcBox), dst, ImageFilter.Bilinear);
                }
                else
                {
                    // Just copy the bit that we need
                    PixelConverter.BulkPixelConversion(this._buffer.GetSubVolume(srcBox), dst);
                }
                FreeBuffer();
            }
        }
示例#5
0
        ///<summary>
        ///    Internal implementation of <see cref="HardwareBuffer.Lock"/>.
        ///</summary>
        protected override PixelBox LockImpl(BasicBox lockBox, BufferLocking options)
        {
            _lockedBox = lockBox;
            // Set extents and format
            var rval        = new PixelBox(lockBox, Format);
            var sizeInBytes = PixelUtil.GetMemorySize(lockBox.Width, lockBox.Height, lockBox.Depth,
                                                      XnaHelper.Convert(surface.Format));

            if (_bufferBytes == null || _bufferBytes.Length != sizeInBytes)
            {
                _bufferBytes = new byte[sizeInBytes];
#if !SILVERLIGHT
                if (surface != null)
                {
                    surface.GetData(mipLevel, XnaHelper.ToRectangle(lockBox), _bufferBytes, 0, _bufferBytes.Length);
                }
                else if (cube != null)
                {
                    cube.GetData(face, mipLevel, XnaHelper.ToRectangle(lockBox), _bufferBytes, 0, _bufferBytes.Length);
                }
                else
                {
                    volume.GetData(mipLevel, lockBox.Left, lockBox.Top, lockBox.Right, lockBox.Bottom,
                                   lockBox.Front, lockBox.Back, _bufferBytes, 0, _bufferBytes.Length);
                }
#endif
            }

            rval.Data = BufferBase.Wrap(_bufferBytes);

            return(rval);
        }
        protected override PixelBox LockImpl(BasicBox lockBox, BufferLocking options)
        {
            //Entering critical section
            LockDeviceAccess();

            // Check for misuse
            if (((int)usage & (int)TextureUsage.RenderTarget) != 0)
            {
                throw new AxiomException(
                          "DirectX does not allow locking of or directly writing to RenderTargets. Use BlitFromMemory if you need the contents.");
            }

            // Set locking flags according to options
            var flags = D3D9Helper.ConvertEnum(options, usage);

            if (this.mapDeviceToBufferResources.Count == 0)
            {
                throw new AxiomException("There are no resources attached to this pixel buffer !!");
            }

            lockedBox      = lockBox;
            this.lockFlags = flags;

            var bufferResources = this.mapDeviceToBufferResources.First().Value;

            // Lock the source buffer.
            var lockedBuf = LockBuffer(bufferResources, lockBox, flags);

            //Leaving critical section
            UnlockDeviceAccess();

            return(lockedBuf);
        }
示例#7
0
        ///<summary>
        ///    @copydoc HardwarePixelBuffer.Blit
        ///</summary>
        public override void Blit(HardwarePixelBuffer _src, BasicBox srcBox, BasicBox dstBox)
        {
            D3DHardwarePixelBuffer src = (D3DHardwarePixelBuffer)_src;

            if (surface != null && src.surface != null)
            {
                // Surface-to-surface
                Rectangle dsrcRect  = ToD3DRectangle(srcBox);
                Rectangle ddestRect = ToD3DRectangle(dstBox);
                // D3DXLoadSurfaceFromSurface
                SurfaceLoader.FromSurface(surface, ddestRect, src.surface, dsrcRect, Filter.None, 0);
            }
            else if (volume != null && src.volume != null)
            {
                // Volume-to-volume
                Box dsrcBox  = ToD3DBox(srcBox);
                Box ddestBox = ToD3DBox(dstBox);
                // D3DXLoadVolumeFromVolume
                VolumeLoader.FromVolume(volume, ddestBox, src.volume, dsrcBox, Filter.None, 0);
            }
            else
            {
                // Software fallback
                base.Blit(_src, srcBox, dstBox);
            }
        }
        protected PixelBox LockBuffer(BufferResources bufferResources, BasicBox lockBox, D3D9.LockFlags flags)
        {
            // Set extents and format
            // Note that we do not carry over the left/top/front here, since the returned
            // PixelBox will be re-based from the locking point onwards
            var rval = new PixelBox(lockBox.Width, lockBox.Height, lockBox.Depth, Format);

            if (bufferResources.Surface != null)
            {
                //Surface
                DX.DataRectangle lrect;                 // Filled in by D3D

                if (lockBox.Left == 0 && lockBox.Top == 0 && lockBox.Right == Width && lockBox.Bottom == Height)
                {
                    // Lock whole surface
                    lrect = bufferResources.Surface.LockRectangle(flags);
                }
                else
                {
                    var prect = ToD3DRectangle(lockBox);
                    lrect = bufferResources.Surface.LockRectangle(prect, flags);
                }

                FromD3DLock(rval, lrect);
            }
            else if (bufferResources.Volume != null)
            {
                // Volume
                var pbox = ToD3DBox(lockBox);                   // specify range to lock
                var lbox = bufferResources.Volume.LockBox(pbox, flags);
                FromD3DLock(rval, lbox);
            }

            return(rval);
        }
示例#9
0
 ///<summary>
 ///  // Very fast texture-to-texture blitter and hardware bi/trilinear scaling implementation using FBO Destination texture must be 1D, 2D, 3D, or Cube Source texture must be 1D, 2D or 3D Supports compressed formats as both source and destination format, it will use the hardware DXT compressor if available. @author W.J. van der Laan
 ///</summary>
 ///<param name="src"> </param>
 ///<param name="srcBox"> </param>
 ///<param name="dstBox"> </param>
 private void BlitFromTexture(GLES2TextureBuffer src, BasicBox srcBox, BasicBox dstBox)
 {
     /*Port notes
      * Ogre immediately returns void, yet much code is provided below
      * The remaining code will ported if/when Ogre makes use of it
      */
     return;             //Ogre todo add a shader attach...
 }
示例#10
0
        protected override BufferBase LockImpl(int offset, int length, BufferLocking options)
        {
            Debug.Assert(!IsLocked, "Cannot lock this buffer, it is already locked!");
            Debug.Assert(offset == 0 && length == sizeInBytes, "Cannot lock memory region, must lock box or entire buffer");

            var myBox = new BasicBox(0, 0, 0, Width, Height, Depth);
            var rv    = Lock(myBox, options);

            return(rv.Data);
        }
示例#11
0
        public static Rectangle ToRectangle(BasicBox rectangle)
        {
            var retVal = new Rectangle();

            retVal.X      = rectangle.Left;
            retVal.Y      = rectangle.Top;
            retVal.Width  = rectangle.Width;
            retVal.Height = rectangle.Height;
            return(retVal);
        }
示例#12
0
        public void Bind(D3D9.Device dev, D3D9.Volume volume, D3D9.BaseTexture mipTex)
        {
            //Entering critical section
            LockDeviceAccess();

            var bufferResources = GetBufferResources(dev);
            var isNewBuffer     = false;

            if (bufferResources == null)
            {
                bufferResources = new BufferResources();
                this.mapDeviceToBufferResources.Add(dev, bufferResources);
                isNewBuffer = true;
            }

            bufferResources.MipTex = mipTex;
            bufferResources.Volume = volume;

            var desc = volume.Description;

            width  = desc.Width;
            height = desc.Height;
            depth  = desc.Depth;
            format = D3D9Helper.ConvertEnum(desc.Format);
            // Default
            rowPitch    = Width;
            slicePitch  = Height * Width;
            sizeInBytes = PixelUtil.GetMemorySize(Width, Height, Depth, Format);

            if (isNewBuffer && this.ownerTexture.IsManuallyLoaded)
            {
                foreach (var it in this.mapDeviceToBufferResources)
                {
                    if (it.Value != bufferResources && it.Value.Volume != null && it.Key.TestCooperativeLevel().Success&&
                        dev.TestCooperativeLevel().Success)
                    {
                        var fullBufferBox = new BasicBox(0, 0, 0, Width, Height, Depth);
                        var dstBox        = new PixelBox(fullBufferBox, Format);

                        var data = new byte[sizeInBytes];
                        using (var d = BufferBase.Wrap(data))
                        {
                            dstBox.Data = d;
                            BlitToMemory(fullBufferBox, dstBox, it.Value, it.Key);
                            BlitFromMemory(dstBox, fullBufferBox, bufferResources);
                            Array.Clear(data, 0, sizeInBytes);
                        }
                        break;
                    }
                }
            }

            //Leaving critical section
            UnlockDeviceAccess();
        }
示例#13
0
 ///<summary>
 ///    Convert Axiom Box to D3D box
 ///</summary>
 protected static D3D.Box ToD3DBox(BasicBox lockBox)
 {
     D3D.Box pbox = new D3D.Box();
     pbox.Left   = lockBox.Left;
     pbox.Right  = lockBox.Right;
     pbox.Top    = lockBox.Top;
     pbox.Bottom = lockBox.Bottom;
     pbox.Front  = lockBox.Front;
     pbox.Back   = lockBox.Back;
     return(pbox);
 }
示例#14
0
        protected static System.Drawing.Rectangle ToD3DRectangle(BasicBox lockBox)
        {
            Debug.Assert(lockBox.Depth == 1);
            var r = new System.Drawing.Rectangle();

            r.X      = lockBox.Left;
            r.Width  = lockBox.Width;
            r.Y      = lockBox.Top;
            r.Height = lockBox.Height;
            return(r);
        }
示例#15
0
 /// <summary>
 /// </summary>
 /// <param name="lockBox"> </param>
 /// <param name="options"> </param>
 /// <returns> </returns>
 protected override PixelBox LockImpl(BasicBox lockBox, BufferLocking options)
 {
     AllocateBuffer();
     if (options != BufferLocking.Discard && (Usage & BufferUsage.WriteOnly) == 0)
     {
         // Download the old contents of the texture
         Download(this._buffer);
     }
     this._currentLocking = options;
     return(this._buffer.GetSubVolume(lockBox));
 }
示例#16
0
        ///<summary>
        ///    Convert Ogre integer Box to D3D rectangle
        ///</summary>
        protected static Rectangle ToD3DRectangle(BasicBox lockBox)
        {
            Debug.Assert(lockBox.Depth == 1);
            Rectangle r = new Rectangle();

            r.X      = lockBox.Left;
            r.Width  = lockBox.Width;
            r.Y      = lockBox.Top;
            r.Height = lockBox.Height;
            return(r);
        }
示例#17
0
 protected static DX.Rectangle ToD3DRectangle(BasicBox lockBox)
 {
     Debug.Assert(lockBox.Depth == 1);
     return(new DX.Rectangle
     {
         X = lockBox.Left,
         Y = lockBox.Top,
         Width = lockBox.Width,
         Height = lockBox.Height
     });
 }
示例#18
0
 public override void BlitFromMemory(PixelBox src, BasicBox dstBox)
 {
     /// Fall back to normal GLHardwarePixelBuffer.BlitFromMemory in case
     /// - FBO is not supported
     /// - the source dimensions match the destination ones, in which case no scaling is needed
     if (!this._glSupport.CheckExtension("GL_EXT_framebuffer_object") ||
         (src.Width == dstBox.Width && src.Height == dstBox.Height && src.Depth == dstBox.Depth))
     {
         base.BlitFromMemory(src, dstBox);
         return;
     }
 }
示例#19
0
        public override void BlitToMemory(BasicBox srcBox, PixelBox dst)
        {
            //Entering critical section
            LockDeviceAccess();

            var pair = this.mapDeviceToBufferResources.First();

            BlitToMemory(srcBox, dst, pair.Value, pair.Key);

            //Leaving critical section
            UnlockDeviceAccess();
        }
示例#20
0
        /// <summary>
        /// </summary>
        /// <param name="src"> </param>
        /// <param name="srcBox"> </param>
        /// <param name="dstBox"> </param>
        public void BlitFromTexture(GLESTextureBuffer src, BasicBox srcBox, BasicBox dstBox)
        {
            if (!Root.Instance.RenderSystem.HardwareCapabilities.HasCapability(Capabilities.FrameBufferObjects))
            {
                // the following code depends on FBO support, it crashes if FBO is not supported.
                // TODO - write PBUFFER version of this function or a version that doesn't require FBO
                return;
            }

            /// Store reference to FBO manager
            throw new NotImplementedException();
        }
示例#21
0
        public override void BlitFromMemory(PixelBox src, BasicBox dstBox)
        {
            //Entering critical section
            LockDeviceAccess();

            foreach (var it in this.mapDeviceToBufferResources)
            {
                BlitFromMemory(src, dstBox, it.Value);
            }

            //Leaving critical section
            UnlockDeviceAccess();
        }
示例#22
0
        private void Update( )
        {
            if (_storedMeshes.Count <= 0)
            {
                return;
            }

            Bounds   tempBounds = _storedMeshes.EncapsulateBounds( );
            BasicBox tempBox    = new BasicBox(tempBounds.center, tempBounds.extents, tempBounds.size);

            GetComponent <MeshFilter>( ).mesh       = MeshHelper.GenerateMesh(xVerts, yVerts, tempBox.Size.x, tempBox.Size.z, tempBox.Bot_BL);
            GetComponent <MeshRenderer>( ).material = MeshMaterial;
        }
示例#23
0
        protected static D3D9.Box ToD3DBox(BasicBox lockBox)
        {
            var pbox = new D3D9.Box
            {
                Left   = lockBox.Left,
                Right  = lockBox.Right,
                Top    = lockBox.Top,
                Bottom = lockBox.Bottom,
                Front  = lockBox.Front,
                Back   = lockBox.Back
            };

            return(pbox);
        }
示例#24
0
 public void DirtyRect(Rectangle rect)
 {
     if (this.mDirty)
     {
         this.mDirtyBox.Left   = System.Math.Min(this.mDirtyBox.Left, (int)rect.Left);
         this.mDirtyBox.Top    = System.Math.Min(this.mDirtyBox.Top, (int)rect.Top);
         this.mDirtyBox.Right  = System.Math.Max(this.mDirtyBox.Right, (int)rect.Right);
         this.mDirtyBox.Bottom = System.Math.Max(this.mDirtyBox.Bottom, (int)rect.Bottom);
     }
     else
     {
         this.mDirtyBox = new BasicBox((int)rect.Left, (int)rect.Top, (int)rect.Right, (int)rect.Bottom);
         this.mDirty    = true;
     }
 }
示例#25
0
        public static BasicBox Show(Area area)
        {
            if (!area.IsValid)
            {
                throw new ArgumentException("Area contained NaN values");
            }
            var form = new BasicBox(area, Color.Red);

            form.OnShow += () => {
                form.Window.SetOpacity(0.3);
                form.Window.SetAlwaysOnTop(true);
            };

            form.Launch();
            return(form);
        }
示例#26
0
        /// <summary>
        /// </summary>
        /// <param name="src"> </param>
        /// <param name="srcBox"> </param>
        /// <param name="dstBox"> </param>
        public override void Blit(HardwarePixelBuffer src, BasicBox srcBox, BasicBox dstBox)
        {
            var srct = (GLESTextureBuffer)src;

            /// TODO: Check for FBO support first
            /// Destination texture must be 2D
            /// Source texture must be 2D
            if ((((int)src.Usage & (int)TextureUsage.RenderTarget) != (int)TextureUsage.RenderTarget) && (srct._target == All.Texture2D))
            {
                BlitFromTexture(srct, srcBox, dstBox);
            }
            else
            {
                base.Blit(src, srcBox, dstBox);
            }
        }
示例#27
0
        ///<summary>
        ///    Copies a region from normal memory to a region of this pixelbuffer. The source
        ///    image can be in any pixel format supported by Axiom, and in any size.
        ///</summary>
        ///<param name="src">PixelBox containing the source pixels and format in memory</param>
        ///<param name="dstBox">Image.BasicBox describing the destination region in this buffer</param>
        ///<remarks>
        ///    The source and destination regions dimensions don't have to match, in which
        ///    case scaling is done. This scaling is generally done using a bilinear filter in hardware,
        ///    but it is faster to pass the source image in the right dimensions.
        ///    Only call this function when both buffers are unlocked.
        ///</remarks>
        public override void BlitFromMemory(PixelBox src, BasicBox dstBox)
        {
            var converted   = src;
            var bufGCHandle = new GCHandle();
            var bufSize     = 0;

            // Get src.Data as byte[]
            bufSize = PixelUtil.GetMemorySize(src.Width, src.Height, src.Depth, Format);
            var newBuffer = new byte[bufSize];

            //bufGCHandle = GCHandle.Alloc( newBuffer, GCHandleType.Pinned );
            //XnaHelper.Convert(XFG.SurfaceFormat) would never have returned SurfaceFormat.Unknown anyway...
            //if (XnaHelper.Convert(src.Format) != XFG.SurfaceFormat.Unknown)
            {
                converted = new PixelBox(src.Width, src.Height, src.Depth, Format, BufferBase.Wrap(newBuffer));
                PixelConverter.BulkPixelConversion(src, converted);
            }
            //else
            //{
            //    Memory.Copy(converted.Data, BufferBase.Wrap(newBuffer), bufSize);
            //}

            if (surface != null)
            {
                surface.SetData(mipLevel, XnaHelper.ToRectangle(dstBox), newBuffer, 0, bufSize);
            }
            else if (cube != null)
            {
                cube.SetData(face, mipLevel, XnaHelper.ToRectangle(dstBox), newBuffer, 0, bufSize);
            }
            else
            {
                throw new NotSupportedException("BlitFromMemory on Volume Textures not supported.");
            }

            // If we allocated a buffer for the temporary conversion, free it here
            if (bufGCHandle.IsAllocated)
            {
                bufGCHandle.Free();
            }

            if (doMipmapGen)
            {
                GenMipmaps();
            }
        }
示例#28
0
        public override void Blit(HardwarePixelBuffer src, BasicBox srcBox, BasicBox dstBox)
        {
            var srct = (src as GLES2TextureBuffer);

            //Ogre TODO: Check for FBO support first
            //Destination texture must be 2D or Cube
            //Source texture must be 2D
            //Todo: src.Usage is a BufferUsage, but Ogre uses it as a TextureUsage
            if (false && (srct.target == All.Texture2D))
            {
                this.BlitFromTexture(srct, srcBox, dstBox);
            }
            else
            {
                base.Blit(src, srcBox, dstBox);
            }
        }
示例#29
0
        public override void BlitFromMemory(PixelBox src, BasicBox dstBox)
        {
            PixelBox scaled;

            if (!this._buffer.Contains(dstBox))
            {
                throw new ArgumentException("Destination box out of range.");
            }

            if (src.Width != dstBox.Width || src.Height != dstBox.Height || src.Depth != dstBox.Depth)
            {
                // Scale to destination size. Use DevIL and not iluScale because ILU screws up for
                // floating point textures and cannot cope with 3D images.
                // This also does pixel format conversion if needed
                allocateBuffer();
                scaled = this._buffer.GetSubVolume(dstBox);

                Image.Scale(src, scaled, ImageFilter.Bilinear);
            }
            else if (GLPixelUtil.GetGLOriginFormat(src.Format) == 0)
            {
                // Extents match, but format is not accepted as valid source format for GL
                // do conversion in temporary buffer
                allocateBuffer();
                scaled = this._buffer.GetSubVolume(dstBox);
                PixelConverter.BulkPixelConversion(src, scaled);
            }
            else
            {
                // No scaling or conversion needed
                scaled = src;
                // Set extents for upload
                scaled.Left   = dstBox.Left;
                scaled.Right  = dstBox.Right;
                scaled.Top    = dstBox.Top;
                scaled.Bottom = dstBox.Bottom;
                scaled.Front  = dstBox.Front;
                scaled.Back   = dstBox.Back;
            }

            upload(scaled);
            freeBuffer();
        }
示例#30
0
        public virtual PixelBox Lock(BasicBox lockBox, BufferLocking options)
        {
            if (useShadowBuffer)
            {
                if (options != BufferLocking.ReadOnly)
                {
                    // we have to assume a read / write lock so we use the shadow buffer
                    // and tag for sync on unlock()
                    shadowUpdated = true;
                }
                this.currentLock = ((HardwarePixelBuffer)shadowBuffer).Lock(lockBox, options);
            }
            else
            {
                // Lock the real buffer if there is no shadow buffer
                this.currentLock = LockImpl(lockBox, options);
                isLocked         = true;
            }

            return(this.currentLock);
        }