summaryrefslogtreecommitdiffstats
path: root/o3d/converter
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 22:56:18 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 22:56:18 +0000
commitaa078b67d3d8e976ffeee26e2dcccb6e938b7008 (patch)
tree3f9edf829005027d107a5f20527a78780386f135 /o3d/converter
parent04c2262254185379aa762a69ab4410f3aedab9af (diff)
downloadchromium_src-aa078b67d3d8e976ffeee26e2dcccb6e938b7008.zip
chromium_src-aa078b67d3d8e976ffeee26e2dcccb6e938b7008.tar.gz
chromium_src-aa078b67d3d8e976ffeee26e2dcccb6e938b7008.tar.bz2
Add SetRect to Texture2d and TextureCUBE
Originally I was going to replace Lock/Unlock with only SetRect (and maybe GetRect) and I did that. But then as I was going through the code things started not being so cool. The JavaScript texture.SetRect where as before it allocated no memory, now it needed to allocate a temporary buffer just to be able to write the texture. DrawImage also would have have required copying the original texture out using GetRect, then modifying it, then copying it back even in D3D or it would have required a temporary buffer. That's what happens under the hood in the GL implementation of Texture2D but why should D3D suffer because of the of GL? Or maybe it's a reasonable compomise the D3D should go slower so that GL isn't twice as slow as it it could be? So, I left Lock/Unlock and added SetRect as well. This CL should help the video guys and we can decide if we want to get rid of Lock/Unlock later. SetRect is really only there because trying to make GL act like D3D makes GL slow since we had to get a copy of the texture from GL before Locking. SetRect, since it is not exposing the original data doesn't need to do that. So, now there are both. If need to read (and write) to the texture use Lock. If you only need to write use SetRect. I also fixed Lock/Unlock so they return a pitch which is required for D3D. While I did that I made Lock/Unlock private so you have to use the TextureXXXLockHelpers to access the data. I didn't do the command buffer versions. I also added stubs for texture tests. We need to add more tests. I feel like a lot of clean up needs to happen. It seesm like Bitmap should be split into Bitmap2D BitmapCUBE BitmapVolume Possibly. And maybe BitmapCube should effectively just be typedef Bitmap2D BitmapCUBE[6] and BitmapVolume would be std::vector<Bitmap2D> Then we wouldn't need face and volume versions of various functions. You'd just get the face or the slice Bitma2D and then use the 2D functions. We should decide if that's what we want before pushing a new release. Otherwise we should remove bitmap.idl from idl_scons.lst and the one sample And ship without exposing Bitmap until we are sure they API we are exposing is the one we want. Review URL: http://codereview.chromium.org/159725 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/converter')
-rw-r--r--o3d/converter/cross/texture_stub.h54
1 files changed, 40 insertions, 14 deletions
diff --git a/o3d/converter/cross/texture_stub.h b/o3d/converter/cross/texture_stub.h
index 78e971c..43888d4 100644
--- a/o3d/converter/cross/texture_stub.h
+++ b/o3d/converter/cross/texture_stub.h
@@ -62,12 +62,15 @@ class Texture2DStub : public Texture2D {
enable_render_surfaces) {}
virtual ~Texture2DStub() {}
- // Locks the image buffer of a given mipmap level for writing from main
- // memory.
- virtual bool Lock(int level, void** texture_data) { return true; }
-
- // Unlocks this texture and returns it to Stub control.
- virtual bool Unlock(int level) { return true; }
+ // Overridden from Texture2D
+ virtual void SetRect(int level,
+ unsigned left,
+ unsigned top,
+ unsigned width,
+ unsigned height,
+ const void* src_data,
+ int src_pitch) {
+ }
// Returns a RenderSurface object associated with a mip_level of a texture.
// Parameters:
@@ -88,6 +91,16 @@ class Texture2DStub : public Texture2D {
// RGBA to the internal format used by the rendering API.
virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices();
+ protected:
+ // Locks the image buffer of a given mipmap level for writing from main
+ // memory.
+ virtual bool Lock(int level, void** texture_data, int* pitch) {
+ return false;
+ }
+
+ // Unlocks this texture and returns it to Stub control.
+ virtual bool Unlock(int level) { return true; }
+
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DStub);
};
@@ -111,14 +124,16 @@ class TextureCUBEStub : public TextureCUBE {
enable_render_surfaces) {}
virtual ~TextureCUBEStub() {}
- // Locks the image buffer of a given face and mipmap level for loading
- // from main memory.
- virtual bool Lock(CubeFace face, int level, void** texture_data) {
- return true;
- }
-
- // Unlocks the image buffer of a given face and mipmap level.
- virtual bool Unlock(CubeFace face, int level) { return true; }
+ // Overridden from TextureCUBE
+ virtual void SetRect(CubeFace face,
+ int level,
+ unsigned dst_left,
+ unsigned dst_top,
+ unsigned width,
+ unsigned height,
+ const void* src_data,
+ int src_pitch) {
+ };
// Returns a RenderSurface object associated with a given cube face and
// mip_level of a texture.
@@ -143,6 +158,17 @@ class TextureCUBEStub : public TextureCUBE {
// RGBA to the internal format used by the rendering API.
virtual const RGBASwizzleIndices& GetABGR32FSwizzleIndices();
+ protected:
+ // Locks the image buffer of a given face and mipmap level for loading
+ // from main memory.
+ virtual bool Lock(
+ CubeFace face, int level, void** texture_data, int* pitch) {
+ return false;
+ }
+
+ // Unlocks the image buffer of a given face and mipmap level.
+ virtual bool Unlock(CubeFace face, int level) { return true; }
+
private:
DISALLOW_COPY_AND_ASSIGN(TextureCUBEStub);
};