OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreD3D9HardwarePixelBuffer.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-2011 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 __D3D9PIXELBUFFER_H__
29 #define __D3D9PIXELBUFFER_H__
30 
31 #include "OgreD3D9Prerequisites.h"
33 
34 namespace Ogre {
35 
36  class D3D9Texture;
37  class D3D9RenderTexture;
38 
40  {
41  protected:
43  {
45  IDirect3DSurface9* surface;
47  IDirect3DSurface9* fSAASurface;
49  IDirect3DVolume9* volume;
51  IDirect3DSurface9* tempSurface;
53  IDirect3DVolume9* tempVolume;
55  IDirect3DBaseTexture9 *mipTex;
56  };
57 
59  typedef DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator;
60 
63 
66  bool mHWMipmaps;
67 
70 
71  // The owner texture if exists.
73 
74  // The current lock flags of this surface.
75  DWORD mLockFlags;
76 
77  // Device access mutex.
78  OGRE_STATIC_MUTEX(msDeviceAccessMutex)
79  protected:
81  PixelBox lockImpl(const Image::Box lockBox, LockOptions options);
82  PixelBox lockBuffer(BufferResources* bufferResources, const Image::Box &lockBox, DWORD flags);
83 
85  void unlockImpl(void);
86  void unlockBuffer(BufferResources* bufferResources);
87 
88  BufferResources* getBufferResources(IDirect3DDevice9* d3d9Device);
89  BufferResources* createBufferResources();
90 
92  void updateRenderTexture(bool writeGamma, uint fsaa, const String& srcName);
94  void destroyRenderTexture();
95 
96  void blit(IDirect3DDevice9* d3d9Device, const HardwarePixelBufferSharedPtr &src,
97  const Image::Box &srcBox, const Image::Box &dstBox,
98  BufferResources* srcBufferResources,
99  BufferResources* dstBufferResources);
100  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox, BufferResources* dstBufferResources);
101 
102  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst, BufferResources* srcBufferResources, IDirect3DDevice9* d3d9Device);
103 
104  public:
106  D3D9Texture* ownerTexture);
108 
110  void bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *mSurface, IDirect3DSurface9* fsaaSurface,
111  bool writeGamma, uint fsaa, const String& srcName, IDirect3DBaseTexture9 *mipTex);
112  void bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *mVolume, IDirect3DBaseTexture9 *mipTex);
113 
115  void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
116 
118  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
119 
121  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
122 
124  void _genMipmaps(IDirect3DBaseTexture9* mipTex);
125 
127  void _setMipmapping(bool doMipmapGen, bool HWMipmaps);
128 
129 
131  RenderTexture *getRenderTarget(size_t zoffset);
132 
134  IDirect3DSurface9 *getSurface(IDirect3DDevice9* d3d9Device);
135 
137  IDirect3DSurface9 *getFSAASurface(IDirect3DDevice9* d3d9Device);
138 
140  virtual void _clearSliceRTT(size_t zoffset);
141 
143  void releaseSurfaces(IDirect3DDevice9* d3d9Device);
144 
146  void destroyBufferResources(IDirect3DDevice9* d3d9Device);
147 
148  // Called when device state is changing. Access to any device should be locked.
149  // Relevant for multi thread application.
150  static void lockDeviceAccess();
151 
152  // Called when device state change completed. Access to any device is allowed.
153  // Relevant for multi thread application.
154  static void unlockDeviceAccess();
155  };
156 };
157 #endif
IDirect3DVolume9 * tempVolume
Temporary volume in main memory if direct locking of mVolume is not possible.
IDirect3DSurface9 * tempSurface
Temporary surface in main memory if direct locking of mSurface is not possible.
IDirect3DBaseTexture9 * mipTex
Mip map texture.
This class represents a RenderTarget that renders to a Texture.
IDirect3DSurface9 * surface
Surface abstracted by this buffer.
#define OGRE_STATIC_MUTEX(name)
LockOptions
Locking options.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:633
map< IDirect3DDevice9 *, BufferResources * >::type DeviceToBufferResourcesMap
#define _OgreD3D9Export
Usage
Enums describing buffer usage; not mutually exclusive.
IDirect3DSurface9 * fSAASurface
AA Surface abstracted by this buffer.
Shared pointer implementation used to share pixel buffers.
Class representing an image file.
Definition: OgreImage.h:61
Specialisation of HardwareBuffer for a pixel buffer.
RenderTexture implementation for D3D9.
Abstract class defining common features of hardware buffers.
D3D9RenderTexture * mRenderTexture
Render target.
IDirect3DVolume9 * volume
Volume abstracted by this buffer.
_StringBase String
DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
DeviceToBufferResourcesMap mMapDeviceToBufferResources
Map between device to buffer resources.
unsigned int uint