Browse Source

More PixelData refactor

Marko Pintera 12 years ago
parent
commit
fb7c50e1b3

+ 5 - 0
CamelotCore/CamelotCore.vcxproj

@@ -183,6 +183,9 @@
     <ClInclude Include="Include\CmGpuParamBlockBuffer.h" />
     <ClInclude Include="Include\CmGpuParamBlockBuffer.h" />
     <ClInclude Include="Include\CmGpuResource.h" />
     <ClInclude Include="Include\CmGpuResource.h" />
     <ClInclude Include="Include\CmGpuResourceRTTI.h" />
     <ClInclude Include="Include\CmGpuResourceRTTI.h" />
+    <ClInclude Include="Include\CmPixelData.h" />
+    <ClInclude Include="Include\CmPixelDataRTTI.h" />
+    <ClInclude Include="Include\CmPixelUtil.h" />
     <ClInclude Include="Include\CmSceneObjectRTTI.h" />
     <ClInclude Include="Include\CmSceneObjectRTTI.h" />
     <ClInclude Include="Include\CmMemAllocCategories.h" />
     <ClInclude Include="Include\CmMemAllocCategories.h" />
     <ClInclude Include="Include\CmApplication.h" />
     <ClInclude Include="Include\CmApplication.h" />
@@ -328,6 +331,8 @@
     <ClCompile Include="Source\CmOcclusionQuery.cpp" />
     <ClCompile Include="Source\CmOcclusionQuery.cpp" />
     <ClCompile Include="Source\CmPixelBuffer.cpp" />
     <ClCompile Include="Source\CmPixelBuffer.cpp" />
     <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp" />
     <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp" />
+    <ClCompile Include="Source\CmPixelData.cpp" />
+    <ClCompile Include="Source\CmPixelUtil.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
     <ClCompile Include="Source\CmVertexBuffer.cpp" />
     <ClCompile Include="Source\CmVertexBuffer.cpp" />
     <ClCompile Include="Source\CmHighLevelGpuProgram.cpp" />
     <ClCompile Include="Source\CmHighLevelGpuProgram.cpp" />

+ 15 - 0
CamelotCore/CamelotCore.vcxproj.filters

@@ -426,6 +426,15 @@
     <ClInclude Include="Include\CmGpuResourceRTTI.h">
     <ClInclude Include="Include\CmGpuResourceRTTI.h">
       <Filter>Header Files\RTTI</Filter>
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\CmPixelUtil.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelDataRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPixelData.h">
+      <Filter>Header Files\Resources</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmApplication.cpp">
     <ClCompile Include="Source\CmApplication.cpp">
@@ -659,5 +668,11 @@
     <ClCompile Include="Source\CmGpuResource.cpp">
     <ClCompile Include="Source\CmGpuResource.cpp">
       <Filter>Source Files\Resources</Filter>
       <Filter>Source Files\Resources</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\CmPixelUtil.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPixelData.cpp">
+      <Filter>Source Files\Resources</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 42 - 5
CamelotCore/Include/CmGpuResourceData.h

@@ -4,25 +4,62 @@
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
+	/**
+	 * @brief	You can use this class to read and write to various GPU resources. 
+	 * 			
+	 * @note	If you allocate an internal buffer to store the resource data, the ownership of the buffer
+	 * 			will always remain with the initial instance of the class. If that initial instance
+	 * 			is deleted, any potential copies will point to garbage data.
+	 */
 	class CM_EXPORT GpuResourceData
 	class CM_EXPORT GpuResourceData
 	{
 	{
 	public:
 	public:
 		GpuResourceData();
 		GpuResourceData();
-		~GpuResourceData();
+		GpuResourceData(const GpuResourceData& copy);
+		virtual ~GpuResourceData();
+
+		UINT8* getData() const;
+
+		/**
+		 * @brief	Allocates an internal buffer of a certain size. If there is another
+		 * 			buffer already allocated, it will be freed and new one will be allocated.
+		 *
+		 * @param	size	The size of the buffer in bytes.
+		 */
+		void allocateInternalBuffer(UINT32 size);
+
+		/**
+		 * @brief	Frees the internal buffer that was allocated using "allocateInternal". Called automatically
+		 * 			when the instance of the class is destroyed.
+		 */
+		void freeInternalBuffer();
+
+		/**
+		 * @brief	Makes the internal data pointer point to some external data. No copying is done, 
+		 * 			so you must ensure that external data exists as long as this class uses it. You are also
+		 * 			responsible for deleting the data when you are done with it.
+		 *
+		 * @note	If any internal data is allocated, it is freed.
+		 */
+		void setExternalBuffer(UINT8* data);
 
 
 	protected:
 	protected:
 		friend class DeferredRenderContext;
 		friend class DeferredRenderContext;
 		friend class RenderSystem;
 		friend class RenderSystem;
 
 
-		void initialize(UINT32 size);
-
-		UINT8* getData() const;
-
+		/**
+		 * @brief	Locks the data and makes it available only to the render thread.
+		 */
 		void lock() const;
 		void lock() const;
+
+		/**
+		 * @brief	Unlocks the data and makes it available to all threads.
+		 */
 		void unlock() const;
 		void unlock() const;
 
 
 	private:
 	private:
 		UINT8* mData;
 		UINT8* mData;
+		bool mOwnsData;
 		mutable bool mLocked;
 		mutable bool mLocked;
 	};
 	};
 }
 }

+ 39 - 23
CamelotUtility/Include/CmPixelData.h → CamelotCore/Include/CmPixelData.h

@@ -1,6 +1,6 @@
 #pragma once
 #pragma once
 
 
-#include "CmPrerequisitesUtil.h"
+#include "CmPrerequisites.h"
 #include "CmBox.h"
 #include "CmBox.h"
 #include "CmIReflectable.h"
 #include "CmIReflectable.h"
 
 
@@ -119,14 +119,14 @@ namespace CamelotFramework
      	Pixels are stored as a succession of "depth" slices, each containing "height" rows of 
      	Pixels are stored as a succession of "depth" slices, each containing "height" rows of 
      	"width" pixels.
      	"width" pixels.
     */
     */
-    class CM_UTILITY_EXPORT PixelData: public Box, public IReflectable
+    class CM_EXPORT PixelData : public IReflectable
 	{
 	{
     public:
     public:
     	/// Parameter constructor for setting the members manually
     	/// Parameter constructor for setting the members manually
     	PixelData() {}
     	PixelData() {}
 		~PixelData() 
 		~PixelData() 
 		{
 		{
-			freeData();
+			freeInternalBuffer();
 		}
 		}
 		/** Constructor providing extents in the form of a Box object. This constructor
 		/** Constructor providing extents in the form of a Box object. This constructor
     		assumes the pixel data is laid out consecutively in memory. (this
     		assumes the pixel data is laid out consecutively in memory. (this
@@ -135,8 +135,8 @@ namespace CamelotFramework
     		@param pixelFormat	Format of this buffer
     		@param pixelFormat	Format of this buffer
     		@param pixelData	Pointer to the actual data
     		@param pixelData	Pointer to the actual data
     	*/
     	*/
-		PixelData(const Box &extents, PixelFormat pixelFormat):
-			Box(extents), data(nullptr), format(pixelFormat), ownsData(false)
+		PixelData(const Box &extents, PixelFormat pixelFormat)
+			:mExtents(extents), data(nullptr), format(pixelFormat), ownsData(false)
 		{
 		{
 			setConsecutive();
 			setConsecutive();
 		}
 		}
@@ -150,8 +150,8 @@ namespace CamelotFramework
     		@param pixelFormat	Format of this buffer
     		@param pixelFormat	Format of this buffer
     		@param pixelData    Pointer to the actual data
     		@param pixelData    Pointer to the actual data
     	*/
     	*/
-    	PixelData(UINT32 width, UINT32 height, UINT32 depth, PixelFormat pixelFormat):
-    		Box(0, 0, 0, width, height, depth),
+    	PixelData(UINT32 width, UINT32 height, UINT32 depth, PixelFormat pixelFormat)
+			: mExtents(0, 0, 0, width, height, depth),
     		data(nullptr), format(pixelFormat), ownsData(false)
     		data(nullptr), format(pixelFormat), ownsData(false)
     	{
     	{
     		setConsecutive();
     		setConsecutive();
@@ -162,15 +162,15 @@ namespace CamelotFramework
 		/**
 		/**
 		 * @brief	Allocates an internal buffer for storing data.
 		 * @brief	Allocates an internal buffer for storing data.
 		 */
 		 */
-		UINT8* allocData(UINT32 size);
+		UINT8* allocateInternalBuffer(UINT32 size);
 
 
 		/**
 		/**
 		 * @brief	Frees the buffer data. Normally you don't need to call this manually as the
 		 * @brief	Frees the buffer data. Normally you don't need to call this manually as the
 		 * 			data will be freed automatically when an instance of PixelData is freed.
 		 * 			data will be freed automatically when an instance of PixelData is freed.
 		 */
 		 */
-		void freeData();
+		void freeInternalBuffer();
 
 
-		void setExternalDataPtr(UINT8* data);
+		void setExternalBuffer(UINT8* data);
 
 
 		void* getData() const { return data; }
 		void* getData() const { return data; }
 
 
@@ -187,20 +187,7 @@ namespace CamelotFramework
 			for compressed formats.
 			for compressed formats.
         */
         */
         UINT32 slicePitch;
         UINT32 slicePitch;
-
-		/**
-		 * @brief	If true then PixelData owns the data buffer and will release it when destroyed.
-		 */
-		bool ownsData;
         
         
-        /** Set the rowPitch and slicePitch so that the buffer is laid out consecutive 
-         	in memory.
-        */        
-        void setConsecutive()
-        {
-            rowPitch = getWidth();
-            slicePitch = getWidth()*getHeight();
-        }
         /**	Get the number of elements between one past the rightmost pixel of 
         /**	Get the number of elements between one past the rightmost pixel of 
          	one row and the leftmost pixel of the next row. (IE this is zero if rows
          	one row and the leftmost pixel of the next row. (IE this is zero if rows
          	are consecutive).
          	are consecutive).
@@ -214,6 +201,19 @@ namespace CamelotFramework
 
 
 		PixelFormat getFormat() const { return format; }
 		PixelFormat getFormat() const { return format; }
 
 
+		UINT32 getWidth() const { return mExtents.getWidth(); }
+		UINT32 getHeight() const { return mExtents.getHeight(); }
+		UINT32 getDepth() const { return mExtents.getDepth(); }
+
+		UINT32 getLeft() const { return mExtents.left; }
+		UINT32 getRight() const { return mExtents.right; }
+		UINT32 getTop() const { return mExtents.top; }
+		UINT32 getBottom() const { return mExtents.bottom; }
+		UINT32 getFront() const { return mExtents.front; }
+		UINT32 getBack() const { return mExtents.back; }
+
+		Box getExtents() const { return mExtents; }
+
         /** Return whether this buffer is laid out consecutive in memory (ie the pitches
         /** Return whether this buffer is laid out consecutive in memory (ie the pitches
          	are equal to the dimensions)
          	are equal to the dimensions)
         */        
         */        
@@ -253,6 +253,22 @@ namespace CamelotFramework
 		/// The data pointer 
 		/// The data pointer 
 		void *data;
 		void *data;
 
 
+		/**
+		 * @brief	If true then PixelData owns the data buffer and will release it when destroyed.
+		 */
+		bool ownsData;
+
+		Box mExtents;
+
+		/** Set the rowPitch and slicePitch so that the buffer is laid out consecutive 
+         	in memory.
+        */        
+        void setConsecutive()
+        {
+            rowPitch = getWidth();
+            slicePitch = getWidth()*getHeight();
+        }
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/* 								SERIALIZATION                      		*/
 		/************************************************************************/
 		/************************************************************************/

+ 14 - 14
CamelotUtility/Include/CmPixelDataRTTI.h → CamelotCore/Include/CmPixelDataRTTI.h

@@ -1,31 +1,31 @@
 #pragma once
 #pragma once
 
 
-#include "CmPrerequisitesUtil.h"
+#include "CmPrerequisites.h"
 #include "CmPixelData.h"
 #include "CmPixelData.h"
 #include "CmRTTIType.h"
 #include "CmRTTIType.h"
 #include "CmManagedDataBlock.h"
 #include "CmManagedDataBlock.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
-	class CM_UTILITY_EXPORT PixelDataRTTI : public RTTIType<PixelData, IReflectable, PixelDataRTTI>
+	class CM_EXPORT PixelDataRTTI : public RTTIType<PixelData, IReflectable, PixelDataRTTI>
 	{
 	{
-		UINT32& getLeft(PixelData* obj) { return obj->left; }
-		void setLeft(PixelData* obj, UINT32& val) { obj->left = val; }
+		UINT32& getLeft(PixelData* obj) { return obj->mExtents.left; }
+		void setLeft(PixelData* obj, UINT32& val) { obj->mExtents.left = val; }
 
 
-		UINT32& getTop(PixelData* obj) { return obj->top; }
-		void setTop(PixelData* obj, UINT32& val) { obj->top = val; }
+		UINT32& getTop(PixelData* obj) { return obj->mExtents.top; }
+		void setTop(PixelData* obj, UINT32& val) { obj->mExtents.top = val; }
 
 
-		UINT32& getRight(PixelData* obj) { return obj->right; }
-		void setRight(PixelData* obj, UINT32& val) { obj->right = val; }
+		UINT32& getRight(PixelData* obj) { return obj->mExtents.right; }
+		void setRight(PixelData* obj, UINT32& val) { obj->mExtents.right = val; }
 
 
-		UINT32& getBottom(PixelData* obj) { return obj->bottom; }
-		void setBottom(PixelData* obj, UINT32& val) { obj->bottom = val; }
+		UINT32& getBottom(PixelData* obj) { return obj->mExtents.bottom; }
+		void setBottom(PixelData* obj, UINT32& val) { obj->mExtents.bottom = val; }
 
 
-		UINT32& getFront(PixelData* obj) { return obj->front; }
-		void setFront(PixelData* obj, UINT32& val) { obj->front = val; }
+		UINT32& getFront(PixelData* obj) { return obj->mExtents.front; }
+		void setFront(PixelData* obj, UINT32& val) { obj->mExtents.front = val; }
 
 
-		UINT32& getBack(PixelData* obj) { return obj->back; }
-		void setBack(PixelData* obj, UINT32& val) { obj->back = val; }
+		UINT32& getBack(PixelData* obj) { return obj->mExtents.back; }
+		void setBack(PixelData* obj, UINT32& val) { obj->mExtents.back = val; }
 
 
 		UINT32& getRowPitch(PixelData* obj) { return obj->rowPitch; }
 		UINT32& getRowPitch(PixelData* obj) { return obj->rowPitch; }
 		void setRowPitch(PixelData* obj, UINT32& val) { obj->rowPitch = val; }
 		void setRowPitch(PixelData* obj, UINT32& val) { obj->rowPitch = val; }

+ 2 - 2
CamelotUtility/Include/CmPixelUtil.h → CamelotCore/Include/CmPixelUtil.h

@@ -28,14 +28,14 @@ THE SOFTWARE.
 #ifndef _PixelFormat_H__
 #ifndef _PixelFormat_H__
 #define _PixelFormat_H__
 #define _PixelFormat_H__
 
 
-#include "CmPrerequisitesUtil.h"
+#include "CmPrerequisites.h"
 #include "CmPixelData.h"
 #include "CmPixelData.h"
 
 
 namespace CamelotFramework {
 namespace CamelotFramework {
     /**
     /**
      * Some utility functions for packing and unpacking pixel data
      * Some utility functions for packing and unpacking pixel data
      */
      */
-    class CM_UTILITY_EXPORT PixelUtil {
+    class CM_EXPORT PixelUtil {
     public:
     public:
         /** Returns the size in bytes of an element of the given pixel format.
         /** Returns the size in bytes of an element of the given pixel format.
          @returns
          @returns

+ 2 - 1
CamelotCore/Include/CmPrerequisites.h

@@ -281,7 +281,8 @@ namespace CamelotFramework
 		TID_IndexElementData = 1058,
 		TID_IndexElementData = 1058,
 		TID_SceneObject = 1059,
 		TID_SceneObject = 1059,
 		TID_GameObject = 1060,
 		TID_GameObject = 1060,
-		TID_GpuResource = 1061
+		TID_GpuResource = 1061,
+		TID_PixelData = 1062
 	};
 	};
 
 
 	/**
 	/**

+ 0 - 1
CamelotCore/Include/CmTextureRTTI.h

@@ -101,7 +101,6 @@ namespace CamelotFramework
 				UINT32 mipmap = i % (texture->getNumMipmaps() + 1);
 				UINT32 mipmap = i % (texture->getNumMipmaps() + 1);
 
 
 				PixelData data(*pixelData->at(i));
 				PixelData data(*pixelData->at(i));
-				data.ownsData = false;
 
 
 				texture->setRawPixels(data, face, mipmap);
 				texture->setRawPixels(data, face, mipmap);
 			}
 			}

+ 61 - 6
CamelotCore/Source/CmGpuResourceData.cpp

@@ -1,31 +1,87 @@
 #include "CmGpuResourceData.h"
 #include "CmGpuResourceData.h"
+#include "CmRenderSystem.h"
 #include "CmException.h"
 #include "CmException.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
 	GpuResourceData::GpuResourceData()
 	GpuResourceData::GpuResourceData()
-		:mData(nullptr), mLocked(false)
+		:mData(nullptr), mLocked(false), mOwnsData(false)
 	{
 	{
 
 
 	}
 	}
 
 
+	GpuResourceData::GpuResourceData(const GpuResourceData& copy)
+	{
+		mData = copy.mData;
+		mLocked = copy.mLocked; // TODO - This should be shared by all copies pointing to the same data?
+		mOwnsData = false;
+	}
+
 	GpuResourceData::~GpuResourceData()
 	GpuResourceData::~GpuResourceData()
 	{
 	{
-		if(mData != nullptr)
-			CM_DELETE_BYTES(mData, ScratchAlloc);
+		freeInternalBuffer();
 	}
 	}
 
 
 	UINT8* GpuResourceData::getData() const
 	UINT8* GpuResourceData::getData() const
 	{
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
 		if(mLocked)
 		if(mLocked)
-			CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data when the buffer is locked.");
+		{
+			if(CM_THREAD_CURRENT_ID != RenderSystem::instance().getRenderThreadId())
+				CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data from non-render thread when the buffer is locked.");
+		}
+#endif
 
 
 		return mData;
 		return mData;
 	}
 	}
 
 
-	void GpuResourceData::initialize(UINT32 size)
+	void GpuResourceData::allocateInternalBuffer(UINT32 size)
 	{
 	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
+		if(mLocked)
+		{
+			if(CM_THREAD_CURRENT_ID != RenderSystem::instance().getRenderThreadId())
+				CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data from non-render thread when the buffer is locked.");
+		}
+#endif
+
+		freeInternalBuffer();
+
 		mData = CM_NEW_BYTES(size, ScratchAlloc);
 		mData = CM_NEW_BYTES(size, ScratchAlloc);
+		mOwnsData = true;
+	}
+
+	void GpuResourceData::freeInternalBuffer()
+	{
+		if(mData == nullptr || !mOwnsData)
+			return;
+
+#if !CM_FORCE_SINGLETHREADED_RENDERING
+		if(mLocked)
+		{
+			if(CM_THREAD_CURRENT_ID != RenderSystem::instance().getRenderThreadId())
+				CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data from non-render thread when the buffer is locked.");
+		}
+#endif
+
+		CM_DELETE_BYTES(mData, ScratchAlloc);
+		mData = nullptr;
+	}
+
+	void GpuResourceData::setExternalBuffer(UINT8* data)
+	{
+#if !CM_FORCE_SINGLETHREADED_RENDERING
+		if(mLocked)
+		{
+			if(CM_THREAD_CURRENT_ID != RenderSystem::instance().getRenderThreadId())
+				CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data from non-render thread when the buffer is locked.");
+		}
+#endif
+
+		freeInternalBuffer();
+
+		mData = data;
+		mOwnsData = false;
 	}
 	}
 
 
 	void GpuResourceData::lock() const
 	void GpuResourceData::lock() const
@@ -37,5 +93,4 @@ namespace CamelotFramework
 	{
 	{
 		mLocked = false;
 		mLocked = false;
 	}
 	}
-
 }
 }

+ 6 - 5
CamelotUtility/Source/CmPixelData.cpp → CamelotCore/Source/CmPixelData.cpp

@@ -5,16 +5,17 @@
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
 	PixelData::PixelData(const PixelData& copy)
 	PixelData::PixelData(const PixelData& copy)
-		:Box(copy), IReflectable(copy)
+		:IReflectable(copy)
 	{
 	{
 		data = copy.data;
 		data = copy.data;
 		format = copy.format;
 		format = copy.format;
 		rowPitch = copy.rowPitch;
 		rowPitch = copy.rowPitch;
 		slicePitch = copy.slicePitch;
 		slicePitch = copy.slicePitch;
+		mExtents = copy.mExtents;
 		ownsData = false;
 		ownsData = false;
 	}
 	}
 
 
-	UINT8* PixelData::allocData(UINT32 size)
+	UINT8* PixelData::allocateInternalBuffer(UINT32 size)
 	{
 	{
 		data = CM_NEW_BYTES(size, ScratchAlloc);
 		data = CM_NEW_BYTES(size, ScratchAlloc);
 		ownsData = true;
 		ownsData = true;
@@ -22,7 +23,7 @@ namespace CamelotFramework
 		return (UINT8*)data;
 		return (UINT8*)data;
 	}
 	}
 
 
-	void PixelData::freeData()
+	void PixelData::freeInternalBuffer()
 	{
 	{
 		if(ownsData && getData() != nullptr)
 		if(ownsData && getData() != nullptr)
 		{
 		{
@@ -32,9 +33,9 @@ namespace CamelotFramework
 		}
 		}
 	}
 	}
 
 
-	void PixelData::setExternalDataPtr(UINT8* data)
+	void PixelData::setExternalBuffer(UINT8* data)
 	{
 	{
-		freeData();
+		freeInternalBuffer();
 
 
 		this->data = data;
 		this->data = data;
 		ownsData = false;
 		ownsData = false;

+ 32 - 32
CamelotUtility/Source/CmPixelUtil.cpp → CamelotCore/Source/CmPixelUtil.cpp

@@ -67,15 +67,15 @@ namespace CamelotFramework {
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// for the center of the destination pixel, not the top-left corner
 			// for the center of the destination pixel, not the top-left corner
 			UINT64 sz_48 = (stepz >> 1) - 1;
 			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48 += stepz) {
+			for (size_t z = dst.getFront(); z < dst.getBack(); z++, sz_48 += stepz) {
 				size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
 				size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
 
 
 				UINT64 sy_48 = (stepy >> 1) - 1;
 				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48 += stepy) {
+				for (size_t y = dst.getTop(); y < dst.getBottom(); y++, sy_48 += stepy) {
 					size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
 					size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
 
 
 					UINT64 sx_48 = (stepx >> 1) - 1;
 					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48 += stepx) {
+					for (size_t x = dst.getLeft(); x < dst.getRight(); x++, sx_48 += stepx) {
 						UINT8* psrc = srcdata +
 						UINT8* psrc = srcdata +
 							elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
 							elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
 						memcpy(pdst, psrc, elemsize);
 						memcpy(pdst, psrc, elemsize);
@@ -114,7 +114,7 @@ namespace CamelotFramework {
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// for the center of the destination pixel, not the top-left corner
 			// for the center of the destination pixel, not the top-left corner
 			UINT64 sz_48 = (stepz >> 1) - 1;
 			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
+			for (size_t z = dst.getFront(); z < dst.getBack(); z++, sz_48+=stepz) {
 				temp = static_cast<unsigned int>(sz_48 >> 32);
 				temp = static_cast<unsigned int>(sz_48 >> 32);
 				temp = (temp > 0x8000)? temp - 0x8000 : 0;
 				temp = (temp > 0x8000)? temp - 0x8000 : 0;
 				size_t sz1 = temp >> 16;				 // src z, sample #1
 				size_t sz1 = temp >> 16;				 // src z, sample #1
@@ -122,7 +122,7 @@ namespace CamelotFramework {
 				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
 				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
 
 
 				UINT64 sy_48 = (stepy >> 1) - 1;
 				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+				for (size_t y = dst.getTop(); y < dst.getBottom(); y++, sy_48+=stepy) {
 					temp = static_cast<unsigned int>(sy_48 >> 32);
 					temp = static_cast<unsigned int>(sy_48 >> 32);
 					temp = (temp > 0x8000)? temp - 0x8000 : 0;
 					temp = (temp > 0x8000)? temp - 0x8000 : 0;
 					size_t sy1 = temp >> 16;					// src y #1
 					size_t sy1 = temp >> 16;					// src y #1
@@ -130,7 +130,7 @@ namespace CamelotFramework {
 					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
 					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
 
 
 					UINT64 sx_48 = (stepx >> 1) - 1;
 					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+					for (size_t x = dst.getLeft(); x < dst.getRight(); x++, sx_48+=stepx) {
 						temp = static_cast<unsigned int>(sx_48 >> 32);
 						temp = static_cast<unsigned int>(sx_48 >> 32);
 						temp = (temp > 0x8000)? temp - 0x8000 : 0;
 						temp = (temp > 0x8000)? temp - 0x8000 : 0;
 						size_t sx1 = temp >> 16;					// src x #1
 						size_t sx1 = temp >> 16;					// src x #1
@@ -199,7 +199,7 @@ namespace CamelotFramework {
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
 			// for the center of the destination pixel, not the top-left corner
 			// for the center of the destination pixel, not the top-left corner
 			UINT64 sz_48 = (stepz >> 1) - 1;
 			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
+			for (size_t z = dst.getFront(); z < dst.getBack(); z++, sz_48+=stepz) {
 				temp = static_cast<unsigned int>(sz_48 >> 32);
 				temp = static_cast<unsigned int>(sz_48 >> 32);
 				temp = (temp > 0x8000)? temp - 0x8000 : 0;
 				temp = (temp > 0x8000)? temp - 0x8000 : 0;
 				size_t sz1 = temp >> 16;				 // src z, sample #1
 				size_t sz1 = temp >> 16;				 // src z, sample #1
@@ -207,7 +207,7 @@ namespace CamelotFramework {
 				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
 				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
 
 
 				UINT64 sy_48 = (stepy >> 1) - 1;
 				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+				for (size_t y = dst.getTop(); y < dst.getBottom(); y++, sy_48+=stepy) {
 					temp = static_cast<unsigned int>(sy_48 >> 32);
 					temp = static_cast<unsigned int>(sy_48 >> 32);
 					temp = (temp > 0x8000)? temp - 0x8000 : 0;
 					temp = (temp > 0x8000)? temp - 0x8000 : 0;
 					size_t sy1 = temp >> 16;					// src y #1
 					size_t sy1 = temp >> 16;					// src y #1
@@ -215,7 +215,7 @@ namespace CamelotFramework {
 					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
 					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
 
 
 					UINT64 sx_48 = (stepx >> 1) - 1;
 					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+					for (size_t x = dst.getLeft(); x < dst.getRight(); x++, sx_48+=stepx) {
 						temp = static_cast<unsigned int>(sx_48 >> 32);
 						temp = static_cast<unsigned int>(sx_48 >> 32);
 						temp = (temp > 0x8000)? temp - 0x8000 : 0;
 						temp = (temp > 0x8000)? temp - 0x8000 : 0;
 						size_t sx1 = temp >> 16;					// src x #1
 						size_t sx1 = temp >> 16;					// src x #1
@@ -307,22 +307,22 @@ namespace CamelotFramework {
 			unsigned int temp;
 			unsigned int temp;
 
 
 			UINT64 sy_48 = (stepy >> 1) - 1;
 			UINT64 sy_48 = (stepy >> 1) - 1;
-			for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
+			for (size_t y = dst.getTop(); y < dst.getBottom(); y++, sy_48+=stepy) {
 				temp = static_cast<unsigned int>(sy_48 >> 36);
 				temp = static_cast<unsigned int>(sy_48 >> 36);
 				temp = (temp > 0x800)? temp - 0x800: 0;
 				temp = (temp > 0x800)? temp - 0x800: 0;
 				unsigned int syf = temp & 0xFFF;
 				unsigned int syf = temp & 0xFFF;
 				size_t sy1 = temp >> 12;
 				size_t sy1 = temp >> 12;
-				size_t sy2 = std::min(sy1+1, (size_t)src.bottom-src.top-1);
+				size_t sy2 = std::min(sy1+1, (size_t)src.getBottom()-src.getTop()-1);
 				size_t syoff1 = sy1 * src.rowPitch;
 				size_t syoff1 = sy1 * src.rowPitch;
 				size_t syoff2 = sy2 * src.rowPitch;
 				size_t syoff2 = sy2 * src.rowPitch;
 
 
 				UINT64 sx_48 = (stepx >> 1) - 1;
 				UINT64 sx_48 = (stepx >> 1) - 1;
-				for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
+				for (size_t x = dst.getLeft(); x < dst.getRight(); x++, sx_48+=stepx) {
 					temp = static_cast<unsigned int>(sx_48 >> 36);
 					temp = static_cast<unsigned int>(sx_48 >> 36);
 					temp = (temp > 0x800)? temp - 0x800 : 0;
 					temp = (temp > 0x800)? temp - 0x800 : 0;
 					unsigned int sxf = temp & 0xFFF;
 					unsigned int sxf = temp & 0xFFF;
 					size_t sx1 = temp >> 12;
 					size_t sx1 = temp >> 12;
-					size_t sx2 = std::min(sx1+1, (size_t)src.right-src.left-1);
+					size_t sx2 = std::min(sx1+1, (size_t)src.getRight()-src.getLeft()-1);
 
 
 					unsigned int sxfsyf = sxf*syf;
 					unsigned int sxfsyf = sxf*syf;
 					for (unsigned int k = 0; k < channels; k++) {
 					for (unsigned int k = 0; k < channels; k++) {
@@ -783,15 +783,15 @@ namespace CamelotFramework {
 	{
 	{
 		if(PixelUtil::isCompressed(format))
 		if(PixelUtil::isCompressed(format))
 		{
 		{
-			if(def.left == left && def.top == top && def.front == front &&
-			   def.right == right && def.bottom == bottom && def.back == back)
+			if(def.left == getLeft() && def.top == getTop() && def.front == getFront() &&
+			   def.right == getRight() && def.bottom == getBottom() && def.back == getBack())
 			{
 			{
 				// Entire buffer is being queried
 				// Entire buffer is being queried
 				return *this;
 				return *this;
 			}
 			}
 			CM_EXCEPT(InvalidParametersException, "Cannot return subvolume of compressed PixelBuffer");
 			CM_EXCEPT(InvalidParametersException, "Cannot return subvolume of compressed PixelBuffer");
 		}
 		}
-		if(!contains(def))
+		if(!mExtents.contains(def))
 		{
 		{
 			CM_EXCEPT(InvalidParametersException, "Bounds out of range");
 			CM_EXCEPT(InvalidParametersException, "Bounds out of range");
 		}
 		}
@@ -802,9 +802,9 @@ namespace CamelotFramework {
 		// the returned pointer is already offset
 		// the returned pointer is already offset
 		PixelData rval(def.getWidth(), def.getHeight(), def.getDepth(), format);
 		PixelData rval(def.getWidth(), def.getHeight(), def.getDepth(), format);
 
 
-		rval.setExternalDataPtr(((UINT8*)getData()) + ((def.left-left)*elemSize)
-			+ ((def.top-top)*rowPitch*elemSize)
-			+ ((def.front-front)*slicePitch*elemSize));
+		rval.setExternalBuffer(((UINT8*)getData()) + ((def.left-getLeft())*elemSize)
+			+ ((def.top-getTop())*rowPitch*elemSize)
+			+ ((def.front-getFront())*slicePitch*elemSize));
 
 
 		rval.rowPitch = rowPitch;
 		rval.rowPitch = rowPitch;
 		rval.slicePitch = slicePitch;
 		rval.slicePitch = slicePitch;
@@ -1261,9 +1261,9 @@ namespace CamelotFramework {
             const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
             const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
             const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
             const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
             UINT8 *srcptr = static_cast<UINT8*>(src.getData())
             UINT8 *srcptr = static_cast<UINT8*>(src.getData())
-                + (src.left + src.top * src.rowPitch + src.front * src.slicePitch) * srcPixelSize;
+                + (src.getLeft() + src.getTop() * src.rowPitch + src.getFront() * src.slicePitch) * srcPixelSize;
             UINT8 *dstptr = static_cast<UINT8*>(dst.getData())
             UINT8 *dstptr = static_cast<UINT8*>(dst.getData())
-				+ (dst.left + dst.top * dst.rowPitch + dst.front * dst.slicePitch) * dstPixelSize;
+				+ (dst.getLeft() + dst.getTop() * dst.rowPitch + dst.getFront() * dst.slicePitch) * dstPixelSize;
 
 
             // Calculate pitches+skips in bytes
             // Calculate pitches+skips in bytes
             const size_t srcRowPitchBytes = src.rowPitch*srcPixelSize;
             const size_t srcRowPitchBytes = src.rowPitch*srcPixelSize;
@@ -1276,9 +1276,9 @@ namespace CamelotFramework {
 
 
             // Otherwise, copy per row
             // Otherwise, copy per row
             const size_t rowSize = src.getWidth()*srcPixelSize;
             const size_t rowSize = src.getWidth()*srcPixelSize;
-            for(size_t z=src.front; z<src.back; z++)
+            for(size_t z=src.getFront(); z<src.getBack(); z++)
             {
             {
-                for(size_t y=src.top; y<src.bottom; y++)
+                for(size_t y=src.getTop(); y<src.getBottom(); y++)
                 {
                 {
 					memcpy(dstptr, srcptr, rowSize);
 					memcpy(dstptr, srcptr, rowSize);
                     srcptr += srcRowPitchBytes;
                     srcptr += srcRowPitchBytes;
@@ -1315,9 +1315,9 @@ namespace CamelotFramework {
         const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
         const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
         const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
         const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
         UINT8 *srcptr = static_cast<UINT8*>(src.getData())
         UINT8 *srcptr = static_cast<UINT8*>(src.getData())
-            + (src.left + src.top * src.rowPitch + src.front * src.slicePitch) * srcPixelSize;
+            + (src.getLeft() + src.getTop() * src.rowPitch + src.getFront() * src.slicePitch) * srcPixelSize;
         UINT8 *dstptr = static_cast<UINT8*>(dst.getData())
         UINT8 *dstptr = static_cast<UINT8*>(dst.getData())
-            + (dst.left + dst.top * dst.rowPitch + dst.front * dst.slicePitch) * dstPixelSize;
+            + (dst.getLeft() + dst.getTop() * dst.rowPitch + dst.getFront() * dst.slicePitch) * dstPixelSize;
 		
 		
 		// Old way, not taking into account box dimensions
 		// Old way, not taking into account box dimensions
 		//UINT8 *srcptr = static_cast<UINT8*>(src.data), *dstptr = static_cast<UINT8*>(dst.data);
 		//UINT8 *srcptr = static_cast<UINT8*>(src.data), *dstptr = static_cast<UINT8*>(dst.data);
@@ -1330,11 +1330,11 @@ namespace CamelotFramework {
 
 
         // The brute force fallback
         // The brute force fallback
         float r,g,b,a;
         float r,g,b,a;
-        for(size_t z=src.front; z<src.back; z++)
+        for(size_t z=src.getFront(); z<src.getBack(); z++)
         {
         {
-            for(size_t y=src.top; y<src.bottom; y++)
+            for(size_t y=src.getTop(); y<src.getBottom(); y++)
             {
             {
-                for(size_t x=src.left; x<src.right; x++)
+                for(size_t x=src.getLeft(); x<src.getRight(); x++)
                 {
                 {
                     unpackColour(&r, &g, &b, &a, src.format, srcptr);
                     unpackColour(&r, &g, &b, &a, src.format, srcptr);
                     packColour(r, g, b, a, dst.format, dstptr);
                     packColour(r, g, b, a, dst.format, dstptr);
@@ -1368,7 +1368,7 @@ namespace CamelotFramework {
 			{
 			{
 				// Allocate temporary buffer of destination size in source format 
 				// Allocate temporary buffer of destination size in source format 
 				temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
 				temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
-				temp.allocData(temp.getConsecutiveSize());
+				temp.allocateInternalBuffer(temp.getConsecutiveSize());
 			}
 			}
 			// super-optimized: no conversion
 			// super-optimized: no conversion
 			switch (PixelUtil::getNumElemBytes(src.format)) 
 			switch (PixelUtil::getNumElemBytes(src.format)) 
@@ -1390,7 +1390,7 @@ namespace CamelotFramework {
 				// Blit temp buffer
 				// Blit temp buffer
 				PixelUtil::bulkPixelConversion(temp, scaled);
 				PixelUtil::bulkPixelConversion(temp, scaled);
 
 
-				temp.freeData();
+				temp.freeInternalBuffer();
 			}
 			}
 			break;
 			break;
 
 
@@ -1412,7 +1412,7 @@ namespace CamelotFramework {
 				{
 				{
 					// Allocate temp buffer of destination size in source format 
 					// Allocate temp buffer of destination size in source format 
 					temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
 					temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
-					temp.allocData(temp.getConsecutiveSize());
+					temp.allocateInternalBuffer(temp.getConsecutiveSize());
 				}
 				}
 				// super-optimized: byte-oriented math, no conversion
 				// super-optimized: byte-oriented math, no conversion
 				switch (PixelUtil::getNumElemBytes(src.format)) 
 				switch (PixelUtil::getNumElemBytes(src.format)) 
@@ -1429,7 +1429,7 @@ namespace CamelotFramework {
 				{
 				{
 					// Blit temp buffer
 					// Blit temp buffer
 					PixelUtil::bulkPixelConversion(temp, scaled);
 					PixelUtil::bulkPixelConversion(temp, scaled);
-					temp.freeData();
+					temp.freeInternalBuffer();
 				}
 				}
 				break;
 				break;
 			case PF_FLOAT32_RGB:
 			case PF_FLOAT32_RGB:

+ 1 - 1
CamelotCore/Source/CmTexture.cpp

@@ -140,7 +140,7 @@ namespace CamelotFramework {
 
 
 		PixelDataPtr dst(CM_NEW(PixelData, PoolAlloc) PixelData(width, height, depth, getFormat()),
 		PixelDataPtr dst(CM_NEW(PixelData, PoolAlloc) PixelData(width, height, depth, getFormat()),
 			&MemAllocDeleter<PixelData, PoolAlloc>::deleter);
 			&MemAllocDeleter<PixelData, PoolAlloc>::deleter);
-		UINT8* buffer = (UINT8*)dst->allocData(totalSize);
+		UINT8* buffer = (UINT8*)dst->allocateInternalBuffer(totalSize);
 
 
 		PixelData myData = lock(GBL_READ_ONLY, mip, face);
 		PixelData myData = lock(GBL_READ_ONLY, mip, face);
 
 

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -523,7 +523,7 @@ namespace CamelotFramework
 
 
 		// copy the the texture to the dest
 		// copy the the texture to the dest
 		PixelData src(mWidth, mHeight, 1, PF_A8B8G8R8);
 		PixelData src(mWidth, mHeight, 1, PF_A8B8G8R8);
-		src.setExternalDataPtr((UINT8*)mappedTex2D.pData);
+		src.setExternalBuffer((UINT8*)mappedTex2D.pData);
 		PixelUtil::bulkPixelConversion(src, dst);
 		PixelUtil::bulkPixelConversion(src, dst);
 
 
 		// unmap the temp buffer
 		// unmap the temp buffer

+ 4 - 4
CamelotD3D11RenderSystem/Source/CmD3D11Texture.cpp

@@ -61,15 +61,15 @@ namespace CamelotFramework
 
 
 		if(flags == D3D11_MAP_READ || flags == D3D11_MAP_READ_WRITE)
 		if(flags == D3D11_MAP_READ || flags == D3D11_MAP_READ_WRITE)
 		{
 		{
-			lockedArea.setExternalDataPtr((UINT8*)_mapstagingbuffer(flags, face, mipLevel));
+			lockedArea.setExternalBuffer((UINT8*)_mapstagingbuffer(flags, face, mipLevel));
 			mLockedForReading = true;
 			mLockedForReading = true;
 		}
 		}
 		else
 		else
 		{
 		{
 			if(mUsage == TU_DYNAMIC)
 			if(mUsage == TU_DYNAMIC)
-				lockedArea.setExternalDataPtr((UINT8*)_map(mTex, flags, face, mipLevel));
+				lockedArea.setExternalBuffer((UINT8*)_map(mTex, flags, face, mipLevel));
 			else
 			else
-				lockedArea.setExternalDataPtr((UINT8*)_mapstaticbuffer(lockedArea, mipLevel, face));
+				lockedArea.setExternalBuffer((UINT8*)_mapstaticbuffer(lockedArea, mipLevel, face));
 
 
 			mLockedForReading = false;
 			mLockedForReading = false;
 		}
 		}
@@ -520,7 +520,7 @@ namespace CamelotFramework
 
 
 		mStaticBuffer = CM_NEW(PixelData, PoolAlloc) PixelData(lock.getWidth(), lock.getHeight(), lock.getDepth(), lock.getFormat());
 		mStaticBuffer = CM_NEW(PixelData, PoolAlloc) PixelData(lock.getWidth(), lock.getHeight(), lock.getDepth(), lock.getFormat());
 
 
-		return mStaticBuffer->allocData(sizeOfImage);
+		return mStaticBuffer->allocateInternalBuffer(sizeOfImage);
 	}
 	}
 
 
 	void D3D11Texture::_unmapstaticbuffer()
 	void D3D11Texture::_unmapstaticbuffer()

+ 18 - 20
CamelotD3D9Renderer/Source/CmD3D9Device.cpp

@@ -1136,11 +1136,9 @@ namespace CamelotFramework
 		RenderWindowResources* resources = it->second;
 		RenderWindowResources* resources = it->second;
 		bool swapChain = isSwapChainWindow(renderWindow);
 		bool swapChain = isSwapChainWindow(renderWindow);
 
 
-
-
-		if ((dst.left < 0) || (dst.right > renderWindow->getWidth()) ||
-			(dst.top < 0) || (dst.bottom > renderWindow->getHeight()) ||
-			(dst.front != 0) || (dst.back != 1))
+		if ((dst.getLeft() < 0) || (dst.getRight() > renderWindow->getWidth()) ||
+			(dst.getTop() < 0) || (dst.getBottom() > renderWindow->getHeight()) ||
+			(dst.getFront() != 0) || (dst.getBack() != 1))
 		{
 		{
 			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 		}
 		}
@@ -1188,7 +1186,7 @@ namespace CamelotFramework
 
 
 			if(renderWindow->isFullScreen())
 			if(renderWindow->isFullScreen())
 			{
 			{
-				if ((dst.left == 0) && (dst.right == renderWindow->getWidth()) && (dst.top == 0) && (dst.bottom == renderWindow->getHeight()))
+				if ((dst.getLeft() == 0) && (dst.getRight() == renderWindow->getWidth()) && (dst.getTop() == 0) && (dst.getBottom() == renderWindow->getHeight()))
 				{
 				{
 					hr = pTempSurf->LockRect(&lockedRect, 0, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 					hr = pTempSurf->LockRect(&lockedRect, 0, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 				}
 				}
@@ -1196,10 +1194,10 @@ namespace CamelotFramework
 				{
 				{
 					RECT rect;
 					RECT rect;
 
 
-					rect.left = static_cast<LONG>(dst.left);
-					rect.right = static_cast<LONG>(dst.right);
-					rect.top = static_cast<LONG>(dst.top);
-					rect.bottom = static_cast<LONG>(dst.bottom);
+					rect.left = static_cast<LONG>(dst.getLeft());
+					rect.right = static_cast<LONG>(dst.getRight());
+					rect.top = static_cast<LONG>(dst.getTop());
+					rect.bottom = static_cast<LONG>(dst.getBottom());
 
 
 					hr = pTempSurf->LockRect(&lockedRect, &rect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 					hr = pTempSurf->LockRect(&lockedRect, &rect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 				}
 				}
@@ -1213,10 +1211,10 @@ namespace CamelotFramework
 			{
 			{
 				RECT srcRect;
 				RECT srcRect;
 				//GetClientRect(mHWnd, &srcRect);
 				//GetClientRect(mHWnd, &srcRect);
-				srcRect.left = static_cast<LONG>(dst.left);
-				srcRect.top = static_cast<LONG>(dst.top);
-				srcRect.right = static_cast<LONG>(dst.right);
-				srcRect.bottom = static_cast<LONG>(dst.bottom);
+				srcRect.left = static_cast<LONG>(dst.getLeft());
+				srcRect.top = static_cast<LONG>(dst.getTop());
+				srcRect.right = static_cast<LONG>(dst.getRight());
+				srcRect.bottom = static_cast<LONG>(dst.getBottom());
 				POINT point;
 				POINT point;
 				point.x = srcRect.left;
 				point.x = srcRect.left;
 				point.y = srcRect.top;
 				point.y = srcRect.top;
@@ -1298,7 +1296,7 @@ namespace CamelotFramework
 				SAFE_RELEASE(pStretchSurf);
 				SAFE_RELEASE(pStretchSurf);
 			}
 			}
 
 
-			if ((dst.left == 0) && (dst.right == renderWindow->getWidth()) && (dst.top == 0) && (dst.bottom == renderWindow->getHeight()))
+			if ((dst.getLeft() == 0) && (dst.getRight() == renderWindow->getWidth()) && (dst.getTop() == 0) && (dst.getBottom() == renderWindow->getHeight()))
 			{
 			{
 				hr = pTempSurf->LockRect(&lockedRect, 0, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 				hr = pTempSurf->LockRect(&lockedRect, 0, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 			}
 			}
@@ -1306,10 +1304,10 @@ namespace CamelotFramework
 			{
 			{
 				RECT rect;
 				RECT rect;
 
 
-				rect.left = static_cast<LONG>(dst.left);
-				rect.right = static_cast<LONG>(dst.right);
-				rect.top = static_cast<LONG>(dst.top);
-				rect.bottom = static_cast<LONG>(dst.bottom);
+				rect.left = static_cast<LONG>(dst.getLeft());
+				rect.right = static_cast<LONG>(dst.getRight());
+				rect.top = static_cast<LONG>(dst.getTop());
+				rect.bottom = static_cast<LONG>(dst.getBottom());
 
 
 				hr = pTempSurf->LockRect(&lockedRect, &rect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 				hr = pTempSurf->LockRect(&lockedRect, &rect, D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK);
 			}
 			}
@@ -1329,7 +1327,7 @@ namespace CamelotFramework
 		}
 		}
 
 
 		PixelData src(dst.getWidth(), dst.getHeight(), 1, format);
 		PixelData src(dst.getWidth(), dst.getHeight(), 1, format);
-		src.setExternalDataPtr((UINT8*)lockedRect.pBits);
+		src.setExternalBuffer((UINT8*)lockedRect.pBits);
 		src.rowPitch = lockedRect.Pitch / PixelUtil::getNumElemBytes(format);
 		src.rowPitch = lockedRect.Pitch / PixelUtil::getNumElemBytes(format);
 		src.slicePitch = desc.Height * src.rowPitch;
 		src.slicePitch = desc.Height * src.rowPitch;
 
 

+ 10 - 10
CamelotD3D9Renderer/Source/CmD3D9PixelBuffer.cpp

@@ -110,12 +110,12 @@ namespace CamelotFramework
 				{
 				{
 					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 					PixelData dstBox(fullBufferBox, mFormat);
 					PixelData dstBox(fullBufferBox, mFormat);
-					dstBox.allocData(getSizeInBytes());
+					dstBox.allocateInternalBuffer(getSizeInBytes());
 
 
 					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 					blitFromMemory(dstBox, fullBufferBox, bufferResources);
 					blitFromMemory(dstBox, fullBufferBox, bufferResources);
 
 
-					dstBox.freeData();
+					dstBox.freeInternalBuffer();
 
 
 					break;
 					break;
 				}
 				}
@@ -169,12 +169,12 @@ namespace CamelotFramework
 				{
 				{
 					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 					Box fullBufferBox(0,0,0,mWidth,mHeight,mDepth);
 					PixelData dstBox(fullBufferBox, mFormat);
 					PixelData dstBox(fullBufferBox, mFormat);
-					dstBox.allocData(getSizeInBytes());
+					dstBox.allocateInternalBuffer(getSizeInBytes());
 
 
 					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 					blitToMemory(fullBufferBox, dstBox, it->second, it->first);
 					blitFromMemory(dstBox, fullBufferBox, bufferResources);
 					blitFromMemory(dstBox, fullBufferBox, bufferResources);
 					
 					
-					dstBox.freeData();
+					dstBox.freeInternalBuffer();
 
 
 					break;
 					break;
 				}
 				}
@@ -256,7 +256,7 @@ namespace CamelotFramework
 			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 		}
 		}
 
 
-		rval.setExternalDataPtr((UINT8*)lrect.pBits);
+		rval.setExternalBuffer((UINT8*)lrect.pBits);
 	}
 	}
 	void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
 	void fromD3DLock(PixelData &rval, const D3DLOCKED_BOX &lbox)
 	{
 	{
@@ -277,7 +277,7 @@ namespace CamelotFramework
 		{
 		{
 			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 			CM_EXCEPT(InvalidParametersException, "Invalid pixel format");
 		}
 		}
-		rval.setExternalDataPtr((UINT8*)lbox.pBits);
+		rval.setExternalBuffer((UINT8*)lbox.pBits);
 	}
 	}
 	// Convert Ogre integer Box to D3D rectangle
 	// Convert Ogre integer Box to D3D rectangle
 	RECT toD3DRECT(const Box &lockBox)
 	RECT toD3DRECT(const Box &lockBox)
@@ -604,7 +604,7 @@ namespace CamelotFramework
 		if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
 		if (D3D9Mappings::_getPF(src.format) == D3DFMT_UNKNOWN)
 		{
 		{
 			converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat);
 			converted = PixelData(src.getWidth(), src.getHeight(), src.getDepth(), mFormat);
-			converted.allocData(PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat));
+			converted.allocateInternalBuffer(PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat));
 			PixelUtil::bulkPixelConversion(src, converted);
 			PixelUtil::bulkPixelConversion(src, converted);
 		}
 		}
 
 
@@ -632,7 +632,7 @@ namespace CamelotFramework
 		if (dstBufferResources->surface)
 		if (dstBufferResources->surface)
 		{
 		{
 			RECT destRect, srcRect;
 			RECT destRect, srcRect;
-			srcRect = toD3DRECT(converted);
+			srcRect = toD3DRECT(converted.getExtents());
 			destRect = toD3DRECT(dstBox);
 			destRect = toD3DRECT(dstBox);
 
 
 			if(D3DXLoadSurfaceFromMemory(dstBufferResources->surface, NULL, &destRect, 
 			if(D3DXLoadSurfaceFromMemory(dstBufferResources->surface, NULL, &destRect, 
@@ -646,7 +646,7 @@ namespace CamelotFramework
 		else if (dstBufferResources->volume)
 		else if (dstBufferResources->volume)
 		{
 		{
 			D3DBOX destBox, srcBox;
 			D3DBOX destBox, srcBox;
-			srcBox = toD3DBOX(converted);
+			srcBox = toD3DBOX(converted.getExtents());
 			destBox = toD3DBOX(dstBox);
 			destBox = toD3DBOX(dstBox);
 			UINT32 sliceWidth;
 			UINT32 sliceWidth;
 			if (PixelUtil::isCompressed(converted.format))
 			if (PixelUtil::isCompressed(converted.format))
@@ -681,7 +681,7 @@ namespace CamelotFramework
 		if(mDoMipmapGen)
 		if(mDoMipmapGen)
 			_genMipmaps(dstBufferResources->mipTex);
 			_genMipmaps(dstBufferResources->mipTex);
 
 
-		converted.freeData();
+		converted.freeInternalBuffer();
 	}
 	}
 
 
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -76,7 +76,7 @@ namespace CamelotFramework
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 
 
 		mLockedBuffer = getBuffer(face, mipLevel);
 		mLockedBuffer = getBuffer(face, mipLevel);
-		lockedArea.setExternalDataPtr((UINT8*)mLockedBuffer->lock(options));
+		lockedArea.setExternalBuffer((UINT8*)mLockedBuffer->lock(options));
 
 
 		return lockedArea;
 		return lockedArea;
 	}
 	}

+ 1 - 1
CamelotFontImporter/Source/CmFontImporter.cpp

@@ -133,7 +133,7 @@ namespace CamelotFramework
 
 
 				PixelData pixelData(pageIter->width, pageIter->height, 1, PF_R8G8);
 				PixelData pixelData(pageIter->width, pageIter->height, 1, PF_R8G8);
 
 
-				UINT8* pixelBuffer = pixelData.allocData(bufferSize);
+				UINT8* pixelBuffer = pixelData.allocateInternalBuffer(bufferSize);
 				memset(pixelBuffer, 0, bufferSize);
 				memset(pixelBuffer, 0, bufferSize);
 
 
 				for(size_t elementIdx = 0; elementIdx < atlasElements.size(); elementIdx++)
 				for(size_t elementIdx = 0; elementIdx < atlasElements.size(); elementIdx++)

+ 1 - 1
CamelotFreeImgImporter/Source/CmTextureData.cpp

@@ -53,7 +53,7 @@ namespace CamelotFramework
 
 
 		// Return subface as pixelbox
 		// Return subface as pixelbox
 		PixelData src(finalWidth, finalHeight, finalDepth, getFormat());
 		PixelData src(finalWidth, finalHeight, finalDepth, getFormat());
-		src.setExternalDataPtr(offset);
+		src.setExternalBuffer(offset);
 		return src;
 		return src;
 	}
 	}
 }
 }

+ 11 - 11
CamelotGLRenderer/Source/CmGLPixelBuffer.cpp

@@ -50,7 +50,7 @@ namespace CamelotFramework
 	GLPixelBuffer::~GLPixelBuffer()
 	GLPixelBuffer::~GLPixelBuffer()
 	{
 	{
 		// Force free buffer
 		// Force free buffer
-		mBuffer.freeData();
+		mBuffer.freeInternalBuffer();
 	}
 	}
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
 	void GLPixelBuffer::allocateBuffer()
 	void GLPixelBuffer::allocateBuffer()
@@ -59,7 +59,7 @@ namespace CamelotFramework
 			// Already allocated
 			// Already allocated
 			return;
 			return;
 
 
-		mBuffer.allocData(mSizeInBytes);
+		mBuffer.allocateInternalBuffer(mSizeInBytes);
 		// TODO: use PBO if we're HBU_DYNAMIC
 		// TODO: use PBO if we're HBU_DYNAMIC
 	}
 	}
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
@@ -68,7 +68,7 @@ namespace CamelotFramework
 		// Free buffer if we're STATIC to save memory
 		// Free buffer if we're STATIC to save memory
 		if(mUsage & GBU_STATIC)
 		if(mUsage & GBU_STATIC)
 		{
 		{
-			mBuffer.freeData();
+			mBuffer.freeInternalBuffer();
 		}
 		}
 	}
 	}
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
@@ -99,7 +99,7 @@ namespace CamelotFramework
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
 	void GLPixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 	void GLPixelBuffer::blitFromMemory(const PixelData &src, const Box &dstBox)
 	{
 	{
-		if(!mBuffer.contains(dstBox))
+		if(!mBuffer.getExtents().contains(dstBox))
 			CM_EXCEPT(InvalidParametersException, "destination box out of range");
 			CM_EXCEPT(InvalidParametersException, "destination box out of range");
 		PixelData scaled;
 		PixelData scaled;
 	
 	
@@ -135,7 +135,7 @@ namespace CamelotFramework
 	//-----------------------------------------------------------------------------  
 	//-----------------------------------------------------------------------------  
 	void GLPixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 	void GLPixelBuffer::blitToMemory(const Box &srcBox, const PixelData &dst)
 	{
 	{
-		if(!mBuffer.contains(srcBox))
+		if(!mBuffer.getExtents().contains(srcBox))
 			CM_EXCEPT(InvalidParametersException, "source box out of range");
 			CM_EXCEPT(InvalidParametersException, "source box out of range");
 		if(srcBox.left == 0 && srcBox.right == getWidth() &&
 		if(srcBox.left == 0 && srcBox.right == getWidth() &&
 		   srcBox.top == 0 && srcBox.bottom == getHeight() &&
 		   srcBox.top == 0 && srcBox.bottom == getHeight() &&
@@ -333,8 +333,8 @@ namespace CamelotFramework
 				glPixelStorei(GL_UNPACK_ROW_LENGTH, data.rowPitch);
 				glPixelStorei(GL_UNPACK_ROW_LENGTH, data.rowPitch);
 			if(data.getHeight()*data.getWidth() != data.slicePitch)
 			if(data.getHeight()*data.getWidth() != data.slicePitch)
 				glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, (data.slicePitch/data.getWidth()));
 				glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, (data.slicePitch/data.getWidth()));
-			if(data.left > 0 || data.top > 0 || data.front > 0)
-				glPixelStorei(GL_UNPACK_SKIP_PIXELS, data.left + data.rowPitch * data.top + data.slicePitch * data.front);
+			if(data.getLeft() > 0 || data.getTop() > 0 || data.getFront() > 0)
+				glPixelStorei(GL_UNPACK_SKIP_PIXELS, data.getLeft() + data.rowPitch * data.getTop() + data.slicePitch * data.getFront());
 			if((data.getWidth()*PixelUtil::getNumElemBytes(data.format)) & 3) {
 			if((data.getWidth()*PixelUtil::getNumElemBytes(data.format)) & 3) {
 				// Standard alignment of 4 is not right
 				// Standard alignment of 4 is not right
 				glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 				glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -401,8 +401,8 @@ namespace CamelotFramework
 				glPixelStorei(GL_PACK_ROW_LENGTH, data.rowPitch);
 				glPixelStorei(GL_PACK_ROW_LENGTH, data.rowPitch);
 			if(data.getHeight()*data.getWidth() != data.slicePitch)
 			if(data.getHeight()*data.getWidth() != data.slicePitch)
 				glPixelStorei(GL_PACK_IMAGE_HEIGHT, (data.slicePitch/data.getWidth()));
 				glPixelStorei(GL_PACK_IMAGE_HEIGHT, (data.slicePitch/data.getWidth()));
-			if(data.left > 0 || data.top > 0 || data.front > 0)
-				glPixelStorei(GL_PACK_SKIP_PIXELS, data.left + data.rowPitch * data.top + data.slicePitch * data.front);
+			if(data.getLeft() > 0 || data.getTop() > 0 || data.getFront() > 0)
+				glPixelStorei(GL_PACK_SKIP_PIXELS, data.getLeft() + data.rowPitch * data.getTop() + data.slicePitch * data.getFront());
 			if((data.getWidth()*PixelUtil::getNumElemBytes(data.format)) & 3) {
 			if((data.getWidth()*PixelUtil::getNumElemBytes(data.format)) & 3) {
 				// Standard alignment of 4 is not right
 				// Standard alignment of 4 is not right
 				glPixelStorei(GL_PACK_ALIGNMENT, 1);
 				glPixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -687,7 +687,7 @@ namespace CamelotFramework
 			GLPixelBuffer::blitFromMemory(src_orig, dstBox);
 			GLPixelBuffer::blitFromMemory(src_orig, dstBox);
 			return;
 			return;
 		}
 		}
-		if(!mBuffer.contains(dstBox))
+		if(!mBuffer.getExtents().contains(dstBox))
 			CM_EXCEPT(InvalidParametersException, "destination box out of range");
 			CM_EXCEPT(InvalidParametersException, "destination box out of range");
 		/// For scoped deletion of conversion buffer
 		/// For scoped deletion of conversion buffer
 		PixelData src;
 		PixelData src;
@@ -697,7 +697,7 @@ namespace CamelotFramework
 		{
 		{
 			/// Convert to buffer internal format
 			/// Convert to buffer internal format
 			src = PixelData(src_orig.getWidth(), src_orig.getHeight(), src_orig.getDepth(), mFormat);
 			src = PixelData(src_orig.getWidth(), src_orig.getHeight(), src_orig.getDepth(), mFormat);
-			src.allocData(PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat));
+			src.allocateInternalBuffer(PixelUtil::getMemorySize(src.getWidth(), src.getHeight(), src.getDepth(), mFormat));
 			PixelUtil::bulkPixelConversion(src_orig, src);
 			PixelUtil::bulkPixelConversion(src_orig, src);
 		}
 		}
 		else
 		else

+ 1 - 1
CamelotGLRenderer/Source/CmGLTexture.cpp

@@ -251,7 +251,7 @@ namespace CamelotFramework {
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 		PixelData lockedArea(mipWidth, mipHeight, mipDepth, mFormat);
 
 
 		mLockedBuffer = getBuffer(face, mipLevel);
 		mLockedBuffer = getBuffer(face, mipLevel);
-		lockedArea.setExternalDataPtr((UINT8*)mLockedBuffer->lock(options));
+		lockedArea.setExternalBuffer((UINT8*)mLockedBuffer->lock(options));
 
 
 		return lockedArea;
 		return lockedArea;
 	}
 	}

+ 4 - 4
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -626,9 +626,9 @@ namespace CamelotFramework {
 
 
 	void Win32Window::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	void Win32Window::copyContentsToMemory(const PixelData &dst, FrameBuffer buffer)
 	{
 	{
-		if ((dst.left < 0) || (dst.right > mWidth) ||
-			(dst.top < 0) || (dst.bottom > mHeight) ||
-			(dst.front != 0) || (dst.back != 1))
+		if ((dst.getLeft() < 0) || (dst.getRight() > mWidth) ||
+			(dst.getTop() < 0) || (dst.getBottom() > mHeight) ||
+			(dst.getFront() != 0) || (dst.getBack() != 1))
 		{
 		{
 			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 			CM_EXCEPT(InvalidParametersException, "Invalid box.");
 		}
 		}
@@ -650,7 +650,7 @@ namespace CamelotFramework {
 		glPixelStorei(GL_PACK_ALIGNMENT, 1);
 		glPixelStorei(GL_PACK_ALIGNMENT, 1);
 
 
 		glReadBuffer((buffer == FB_FRONT)? GL_FRONT : GL_BACK);
 		glReadBuffer((buffer == FB_FRONT)? GL_FRONT : GL_BACK);
-		glReadPixels((GLint)dst.left, (GLint)dst.top,
+		glReadPixels((GLint)dst.getLeft(), (GLint)dst.getTop(),
 					 (GLsizei)dst.getWidth(), (GLsizei)dst.getHeight(),
 					 (GLsizei)dst.getWidth(), (GLsizei)dst.getHeight(),
 					 format, type, dst.getData());
 					 format, type, dst.getData());
 
 

+ 1 - 5
CamelotUtility/CamelotUtility.vcxproj

@@ -161,10 +161,10 @@
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmBitmapWriter.cpp" />
     <ClCompile Include="Source\CmBitmapWriter.cpp" />
+    <ClCompile Include="Source\CmBox.cpp" />
     <ClCompile Include="Source\CmInt2.cpp" />
     <ClCompile Include="Source\CmInt2.cpp" />
     <ClCompile Include="Source\CmManagedDataBlock.cpp" />
     <ClCompile Include="Source\CmManagedDataBlock.cpp" />
     <ClCompile Include="Source\CmORect.cpp" />
     <ClCompile Include="Source\CmORect.cpp" />
-    <ClCompile Include="Source\CmPixelData.cpp" />
     <ClCompile Include="Source\CmTexAtlasGenerator.cpp" />
     <ClCompile Include="Source\CmTexAtlasGenerator.cpp" />
     <ClCompile Include="Source\CmUUID.cpp" />
     <ClCompile Include="Source\CmUUID.cpp" />
     <ClCompile Include="Source\CmWorkQueue.cpp" />
     <ClCompile Include="Source\CmWorkQueue.cpp" />
@@ -190,9 +190,6 @@
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmORect.h" />
     <ClInclude Include="Include\CmORect.h" />
     <ClInclude Include="Include\CmPath.h" />
     <ClInclude Include="Include\CmPath.h" />
-    <ClInclude Include="Include\CmPixelData.h" />
-    <ClInclude Include="Include\CmPixelDataRTTI.h" />
-    <ClInclude Include="Include\CmPixelUtil.h" />
     <ClInclude Include="Include\CmPoint.h" />
     <ClInclude Include="Include\CmPoint.h" />
     <ClInclude Include="Include\CmRect.h" />
     <ClInclude Include="Include\CmRect.h" />
     <ClInclude Include="Include\CmRTTIField.h" />
     <ClInclude Include="Include\CmRTTIField.h" />
@@ -245,7 +242,6 @@
     <ClCompile Include="Source\CmMath.cpp" />
     <ClCompile Include="Source\CmMath.cpp" />
     <ClCompile Include="Source\CmMatrix3.cpp" />
     <ClCompile Include="Source\CmMatrix3.cpp" />
     <ClCompile Include="Source\CmMatrix4.cpp" />
     <ClCompile Include="Source\CmMatrix4.cpp" />
-    <ClCompile Include="Source\CmPixelUtil.cpp" />
     <ClCompile Include="Source\CmPlane.cpp" />
     <ClCompile Include="Source\CmPlane.cpp" />
     <ClCompile Include="Source\CmQuaternion.cpp" />
     <ClCompile Include="Source\CmQuaternion.cpp" />
     <ClCompile Include="Source\CmString.cpp" />
     <ClCompile Include="Source\CmString.cpp" />

+ 3 - 15
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -117,9 +117,6 @@
     <ClInclude Include="Include\CmBitwise.h">
     <ClInclude Include="Include\CmBitwise.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmPixelUtil.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmBox.h">
     <ClInclude Include="Include\CmBox.h">
       <Filter>Header Files\Math</Filter>
       <Filter>Header Files\Math</Filter>
     </ClInclude>
     </ClInclude>
@@ -201,12 +198,6 @@
     <ClInclude Include="Include\CmAsyncOp.h">
     <ClInclude Include="Include\CmAsyncOp.h">
       <Filter>Header Files\Threading</Filter>
       <Filter>Header Files\Threading</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\CmPixelData.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmPixelDataRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmUtil.h">
     <ClInclude Include="Include\CmUtil.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
@@ -266,9 +257,6 @@
     <ClCompile Include="Source\CmColor.cpp">
     <ClCompile Include="Source\CmColor.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\CmPixelUtil.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmDynLibManager.cpp">
     <ClCompile Include="Source\CmDynLibManager.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
@@ -314,9 +302,6 @@
     <ClCompile Include="Source\CmInt2.cpp">
     <ClCompile Include="Source\CmInt2.cpp">
       <Filter>Source Files\Math</Filter>
       <Filter>Source Files\Math</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\CmPixelData.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmManagedDataBlock.cpp">
     <ClCompile Include="Source\CmManagedDataBlock.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
@@ -329,5 +314,8 @@
     <ClCompile Include="Source\CmORect.cpp">
     <ClCompile Include="Source\CmORect.cpp">
       <Filter>Source Files\Math</Filter>
       <Filter>Source Files\Math</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\CmBox.cpp">
+      <Filter>Source Files\Math</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 1 - 1
CamelotUtility/Include/CmDebug.h

@@ -18,7 +18,7 @@ namespace CamelotFramework
 
 
 		Log& getLog() { return mLog; }
 		Log& getLog() { return mLog; }
 
 
-		void writeAsBMP(const PixelData& pixelData, const String& filePath, bool overwrite = true) const;
+		void writeAsBMP(UINT8* rawPixels, UINT32 bytesPerPixel, UINT32 width, UINT32 height, const String& filePath, bool overwrite = true) const;
 
 
 	private:
 	private:
 		Log mLog;
 		Log mLog;

+ 1 - 2
CamelotUtility/Include/CmTypes.h

@@ -22,7 +22,6 @@ namespace CamelotFramework
 
 
 	enum TypeID_Utility
 	enum TypeID_Utility
 	{
 	{
-		TID_Abstract = 50, // Special type ID used for Abstract classes. Only type ID that may be used by more than one class.
-		TID_PixelData = 51
+		TID_Abstract = 50 // Special type ID used for Abstract classes. Only type ID that may be used by more than one class.
 	};
 	};
 }
 }

+ 0 - 1
CamelotUtility/Source/CmBitmapWriter.cpp

@@ -1,5 +1,4 @@
 #include "CmBitmapWriter.h"
 #include "CmBitmapWriter.h"
-#include "CmPixelData.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {

+ 1 - 0
CamelotUtility/Source/CmBox.cpp

@@ -0,0 +1 @@
+#include "CmBox.h"

+ 3 - 7
CamelotUtility/Source/CmDebug.cpp

@@ -4,8 +4,6 @@
 #include "CmBitmapWriter.h"
 #include "CmBitmapWriter.h"
 #include "CmFileSystem.h"
 #include "CmFileSystem.h"
 #include "CmDataStream.h"
 #include "CmDataStream.h"
-#include "CmPixelData.h"
-#include "CmPixelUtil.h"
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
@@ -34,7 +32,7 @@ namespace CamelotFramework
 		mLog.logMsg(msg, channel);
 		mLog.logMsg(msg, channel);
 	}
 	}
 
 
-	void Debug::writeAsBMP(const PixelData& pixelData, const String& filePath, bool overwrite) const
+	void Debug::writeAsBMP(UINT8* rawPixels, UINT32 bytesPerPixel, UINT32 width, UINT32 height, const String& filePath, bool overwrite) const
 	{
 	{
 		if(FileSystem::fileExists(filePath))
 		if(FileSystem::fileExists(filePath))
 		{
 		{
@@ -46,12 +44,10 @@ namespace CamelotFramework
 
 
 		DataStreamPtr ds = FileSystem::create(filePath);
 		DataStreamPtr ds = FileSystem::create(filePath);
 
 
-		UINT32 bytesPerPixel = PixelUtil::getNumElemBytes(pixelData.format);
-
-		UINT32 bmpDataSize = BitmapWriter::getBMPSize(pixelData.getWidth(), pixelData.getHeight(), bytesPerPixel);
+		UINT32 bmpDataSize = BitmapWriter::getBMPSize(width, height, bytesPerPixel);
 		UINT8* bmpBuffer = CM_NEW_ARRAY(UINT8, bmpDataSize, ScratchAlloc);
 		UINT8* bmpBuffer = CM_NEW_ARRAY(UINT8, bmpDataSize, ScratchAlloc);
 
 
-		BitmapWriter::rawPixelsToBMP((UINT8*)pixelData.getData(), bmpBuffer, pixelData.getWidth(), pixelData.getHeight(), bytesPerPixel);
+		BitmapWriter::rawPixelsToBMP(rawPixels, bmpBuffer, width, height, bytesPerPixel);
 
 
 		ds->write(bmpBuffer, bmpDataSize);
 		ds->write(bmpBuffer, bmpDataSize);
 		ds->close();
 		ds->close();

+ 2 - 0
TODO.txt

@@ -17,6 +17,8 @@ DeferredContext
  - readSubresource - how to avoid casting returned value to either MeshData or PixelData?
  - readSubresource - how to avoid casting returned value to either MeshData or PixelData?
    - Have it as a parameter, that is created on main thread, using the source resource. (e.g. Texture::createCPUBuffer)
    - Have it as a parameter, that is created on main thread, using the source resource. (e.g. Texture::createCPUBuffer)
 
 
+Remove PixelData::ownsData and instead use a shared_ptr for GpuResourceData. 
+Otherwise it gets very difficult handling the sharing of "mLocked" variable, and also PixelData creation.
 
 
 All data classes (MeshData, PixelData, etc) derive from GpuBufferData class. 
 All data classes (MeshData, PixelData, etc) derive from GpuBufferData class. 
  - It contains basically just raw bytes.
  - It contains basically just raw bytes.