OgreHardwarePixelBuffer.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __HardwarePixelBuffer__
29 #define __HardwarePixelBuffer__
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreHardwareBuffer.h"
34 #include "OgreSharedPtr.h"
35 #include "OgrePixelFormat.h"
36 #include "OgreImage.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
54  {
55  protected:
57  uint32 mWidth, mHeight, mDepth;
59  size_t mRowPitch, mSlicePitch;
66 
67 
69  virtual PixelBox lockImpl(const Image::Box lockBox, LockOptions options) = 0;
70 
73  virtual void* lockImpl(size_t offset, size_t length, LockOptions options);
74 
78  virtual void _clearSliceRTT(size_t zoffset);
79  friend class RenderTexture;
80  public:
82  HardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth,
83  PixelFormat mFormat,
84  HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
86 
90  using HardwareBuffer::lock;
91 
98  virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options);
100  virtual void* lock(size_t offset, size_t length, LockOptions options);
101 
107 
109  virtual void readData(size_t offset, size_t length, void* pDest);
111  virtual void writeData(size_t offset, size_t length, const void* pSource,
112  bool discardWholeBuffer = false);
113 
124  virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
125 
132 
142  virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0;
143 
149  void blitFromMemory(const PixelBox &src)
150  {
151  blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
152  }
153 
161  virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0;
162 
168  void blitToMemory(const PixelBox &dst)
169  {
170  blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
171  }
172 
180  virtual RenderTexture *getRenderTarget(size_t slice=0);
181 
183  uint32 getWidth() const { return mWidth; }
185  uint32 getHeight() const { return mHeight; }
187  uint32 getDepth() const { return mDepth; }
189  PixelFormat getFormat() const { return mFormat; }
190  };
191 
193  class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer>
194  {
195  public:
198 
199 
200  };
201 
204 }
205 
206 #include "OgreHeaderSuffix.h"
207 
208 #endif
209 
OgreSharedPtr.h
OgreHeaderSuffix.h
Ogre::HardwarePixelBuffer::blitFromMemory
virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox)=0
Copies a region from normal memory to a region of this pixelbuffer.
Ogre
Definition: OgreAndroidLogListener.h:35
OgrePixelFormat.h
Ogre::HardwarePixelBuffer::mCurrentLock
PixelBox mCurrentLock
Currently locked region (local coords)
Definition: OgreHardwarePixelBuffer.h:63
Ogre::HardwarePixelBuffer::~HardwarePixelBuffer
~HardwarePixelBuffer()
Ogre::HardwarePixelBuffer::mLockedBox
Image::Box mLockedBox
The current locked box of this surface (entire surface coords)
Definition: OgreHardwarePixelBuffer.h:65
Ogre::HardwarePixelBuffer::_clearSliceRTT
virtual void _clearSliceRTT(size_t zoffset)
Notify TextureBuffer of destruction of render target.
Ogre::HardwarePixelBuffer::getRenderTarget
virtual RenderTexture * getRenderTarget(size_t slice=0)
Get a render target for this PixelBuffer, or a slice of it.
Ogre::HardwarePixelBuffer::getHeight
uint32 getHeight() const
Gets the height of this buffer.
Definition: OgreHardwarePixelBuffer.h:185
Ogre::HardwarePixelBuffer
Specialisation of HardwareBuffer for a pixel buffer.
Definition: OgreHardwarePixelBuffer.h:54
OgreImage.h
Ogre::HardwarePixelBufferSharedPtr::HardwarePixelBufferSharedPtr
HardwarePixelBufferSharedPtr()
Definition: OgreHardwarePixelBuffer.h:196
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::HardwarePixelBuffer::getFormat
PixelFormat getFormat() const
Gets the native pixel format of this buffer.
Definition: OgreHardwarePixelBuffer.h:189
Ogre::HardwarePixelBuffer::writeData
virtual void writeData(size_t offset, size_t length, const void *pSource, bool discardWholeBuffer=false)
Writes data to the buffer from an area of system memory; note that you must ensure that your buffer i...
Ogre::HardwarePixelBuffer::mFormat
PixelFormat mFormat
Internal format.
Definition: OgreHardwarePixelBuffer.h:61
Ogre::HardwarePixelBuffer::readData
virtual void readData(size_t offset, size_t length, void *pDest)
Reads data from the buffer and places it in the memory pointed to by pDest.
Ogre::HardwarePixelBuffer::lock
virtual void * lock(size_t offset, size_t length, LockOptions options)
Lock the buffer for (potentially) reading / writing.
OgreHeaderPrefix.h
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:44
Ogre::HardwarePixelBuffer::mWidth
uint32 mWidth
Extents.
Definition: OgreHardwarePixelBuffer.h:57
OgrePrerequisites.h
Ogre::HardwarePixelBuffer::lock
virtual const PixelBox & lock(const Image::Box &lockBox, LockOptions options)
Lock the buffer for (potentially) reading / writing.
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Box
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:660
Ogre::HardwarePixelBuffer::blit
virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox)
Copies a box from another PixelBuffer to a region of the this PixelBuffer.
Ogre::HardwarePixelBufferSharedPtr::HardwarePixelBufferSharedPtr
HardwarePixelBufferSharedPtr(HardwarePixelBuffer *buf)
Ogre::HardwarePixelBuffer::lockImpl
virtual PixelBox lockImpl(const Image::Box lockBox, LockOptions options)=0
Internal implementation of lock(), must be overridden in subclasses.
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:112
Ogre::HardwarePixelBuffer::blitToMemory
void blitToMemory(const PixelBox &dst)
Convenience function that blits this entire buffer to a pixelbox.
Definition: OgreHardwarePixelBuffer.h:168
Ogre::HardwarePixelBuffer::lockImpl
virtual void * lockImpl(size_t offset, size_t length, LockOptions options)
Internal implementation of lock(), do not OVERRIDE or CALL this for HardwarePixelBuffer implementatio...
Ogre::HardwarePixelBuffer::mSlicePitch
size_t mSlicePitch
Definition: OgreHardwarePixelBuffer.h:59
Ogre::HardwareBuffer
Abstract class defining common features of hardware buffers.
Definition: OgreHardwareBuffer.h:75
Ogre::HardwarePixelBuffer::blitFromMemory
void blitFromMemory(const PixelBox &src)
Convenience function that blits a pixelbox from memory to the entire buffer.
Definition: OgreHardwarePixelBuffer.h:149
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::HardwarePixelBuffer::HardwarePixelBuffer
HardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth, PixelFormat mFormat, HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer)
Should be called by HardwareBufferManager.
Ogre::HardwarePixelBufferSharedPtr
Shared pointer implementation used to share pixel buffers.
Definition: OgreHardwarePixelBuffer.h:194
Ogre::HardwarePixelBuffer::getWidth
uint32 getWidth() const
Gets the width of this buffer.
Definition: OgreHardwarePixelBuffer.h:183
Ogre::HardwarePixelBuffer::getDepth
uint32 getDepth() const
Gets the depth of this buffer.
Definition: OgreHardwarePixelBuffer.h:187
Ogre::RenderTexture
This class represents a RenderTarget that renders to a Texture.
Definition: OgreRenderTexture.h:49
Ogre::HardwareBuffer::Usage
Usage
Enums describing buffer usage; not mutually exclusive.
Definition: OgreHardwareBuffer.h:80
Ogre::HardwareBuffer::lock
virtual void * lock(size_t offset, size_t length, LockOptions options)
Lock the buffer for (potentially) reading / writing.
Definition: OgreHardwareBuffer.h:183
Ogre::HardwareBuffer::LockOptions
LockOptions
Locking options.
Definition: OgreHardwareBuffer.h:122
OgreHardwareBuffer.h
Ogre::HardwarePixelBuffer::blitToMemory
virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst)=0
Copies a region of this pixelbuffer to normal memory.
Ogre::HardwarePixelBuffer::blit
void blit(const HardwarePixelBufferSharedPtr &src)
Convenience function that blits the entire source pixel buffer to this buffer.
Ogre::HardwarePixelBuffer::getCurrentLock
const PixelBox & getCurrentLock()
Get the current locked region.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.