00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __HardwarePixelBuffer__ 00029 #define __HardwarePixelBuffer__ 00030 00031 // Precompiler options 00032 #include "OgrePrerequisites.h" 00033 #include "OgreHardwareBuffer.h" 00034 #include "OgreSharedPtr.h" 00035 #include "OgrePixelFormat.h" 00036 #include "OgreImage.h" 00037 #include "OgreHeaderPrefix.h" 00038 00039 namespace Ogre { 00040 00053 class _OgreExport HardwarePixelBuffer : public HardwareBuffer 00054 { 00055 protected: 00057 uint32 mWidth, mHeight, mDepth; 00059 size_t mRowPitch, mSlicePitch; 00061 PixelFormat mFormat; 00063 PixelBox mCurrentLock; 00065 Image::Box mLockedBox; 00066 00067 00069 virtual PixelBox lockImpl(const Image::Box lockBox, LockOptions options) = 0; 00070 00073 virtual void* lockImpl(size_t offset, size_t length, LockOptions options); 00074 00078 virtual void _clearSliceRTT(size_t zoffset); 00079 friend class RenderTexture; 00080 public: 00082 HardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth, 00083 PixelFormat mFormat, 00084 HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer); 00085 ~HardwarePixelBuffer(); 00086 00090 using HardwareBuffer::lock; 00091 00098 virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options); 00100 virtual void* lock(size_t offset, size_t length, LockOptions options); 00101 00106 const PixelBox& getCurrentLock(); 00107 00109 virtual void readData(size_t offset, size_t length, void* pDest); 00111 virtual void writeData(size_t offset, size_t length, const void* pSource, 00112 bool discardWholeBuffer = false); 00113 00124 virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox); 00125 00131 void blit(const HardwarePixelBufferSharedPtr &src); 00132 00142 virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0; 00143 00149 void blitFromMemory(const PixelBox &src) 00150 { 00151 blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth)); 00152 } 00153 00161 virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0; 00162 00168 void blitToMemory(const PixelBox &dst) 00169 { 00170 blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst); 00171 } 00172 00180 virtual RenderTexture *getRenderTarget(size_t slice=0); 00181 00183 uint32 getWidth() const { return mWidth; } 00185 uint32 getHeight() const { return mHeight; } 00187 uint32 getDepth() const { return mDepth; } 00189 PixelFormat getFormat() const { return mFormat; } 00190 }; 00191 00193 class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer> 00194 { 00195 public: 00196 HardwarePixelBufferSharedPtr() : SharedPtr<HardwarePixelBuffer>() {} 00197 explicit HardwarePixelBufferSharedPtr(HardwarePixelBuffer* buf); 00198 00199 00200 }; 00201 00204 } 00205 00206 #include "OgreHeaderSuffix.h" 00207 00208 #endif 00209
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:43