summaryrefslogtreecommitdiffstats
path: root/o3d/core/cross/texture.h
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 02:59:36 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 02:59:36 +0000
commit38570a4a25452eaa63d0556456f80d33c0e231df (patch)
treede13ded36a0a39340587de17ea8c3a3f712d8080 /o3d/core/cross/texture.h
parent240c058e978c761a1c2ab644e01b8d383988f2b3 (diff)
downloadchromium_src-38570a4a25452eaa63d0556456f80d33c0e231df.zip
chromium_src-38570a4a25452eaa63d0556456f80d33c0e231df.tar.gz
chromium_src-38570a4a25452eaa63d0556456f80d33c0e231df.tar.bz2
Update Texture::Lock to take an AccessMode.
Also, split Lock/Unlock into common and platform specific parts. This is needed to work around an apparent bug in mac drivers where glGetTexImage apparently doesn't always work. This doesn't solve the issue unless we disallow READ completely. Not sure what to about that except make a small GL sample and report the bug to Apple. Review URL: http://codereview.chromium.org/173640 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross/texture.h')
-rw-r--r--o3d/core/cross/texture.h65
1 files changed, 48 insertions, 17 deletions
diff --git a/o3d/core/cross/texture.h b/o3d/core/cross/texture.h
index fcaf75a..f25a162 100644
--- a/o3d/core/cross/texture.h
+++ b/o3d/core/cross/texture.h
@@ -54,7 +54,7 @@ class Texture2D : public Texture {
// Class to help lock Texture2D. Automatically unlocks texture in destructor.
class LockHelper {
public:
- explicit LockHelper(Texture2D* texture, int level);
+ explicit LockHelper(Texture2D* texture, int level, AccessMode mode);
~LockHelper();
int pitch() const {
@@ -74,6 +74,7 @@ class Texture2D : public Texture {
}
private:
+ AccessMode mode_;
Texture2D* texture_;
int level_;
int pitch_;
@@ -182,9 +183,10 @@ class Texture2D : public Texture {
// texture_data: [out] a pointer to the current texture data
// pitch: bytes across 1 row of pixels if uncompressed format. bytes across 1
// row of blocks if compressed format.
+ // mode: The access mode.
// Returns:
// true if the operation succeeds
- virtual bool Lock(int level, void** texture_data, int* pitch) = 0;
+ bool Lock(int level, void** texture_data, int* pitch, AccessMode mode);
// Notifies the texture object that the internal texture data has been
// been modified. Unlock must be called in conjunction with Lock. Modifying
@@ -194,20 +196,30 @@ class Texture2D : public Texture {
// level: [in] the mipmap level that was modified
// Returns:
// true if the operation succeeds
- virtual bool Unlock(int level) = 0;
+ bool Unlock(int level);
+
+ // The platform specific part of Lock.
+ virtual bool PlatformSpecificLock(int level, void** texture_data, int* pitch,
+ AccessMode mode) = 0;
+
+ // The platform specific part of Unlock.
+ virtual bool PlatformSpecificUnlock(int level) = 0;
// The platform specific part of GetRenderSurface.
virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(
int mip_level) = 0;
+ // Returns the current locked mode.
+ AccessMode LockedMode(unsigned int level) {
+ DCHECK_LT(static_cast<int>(level), levels());
+ return locked_levels_[level];
+ }
+
// Returns true if the mip-map level has been locked.
bool IsLocked(unsigned int level) {
- DCHECK_LT(static_cast<int>(level), levels());
- return (locked_levels_ & (1 << level)) != 0;
+ return LockedMode(level) != kNone;
}
- // Bitfield that indicates mip levels that are currently locked.
- unsigned int locked_levels_;
private:
friend class IClassManager;
@@ -222,6 +234,9 @@ class Texture2D : public Texture {
// The height of the texture, in texels.
ParamInteger::Ref height_param_;
+ // Access mode for each level.
+ AccessMode locked_levels_[kMaxLevels];
+
O3D_DECL_CLASS(Texture2D, Texture);
DISALLOW_COPY_AND_ASSIGN(Texture2D);
};
@@ -244,7 +259,8 @@ class TextureCUBE : public Texture {
// Automatically unlocks texture in destructor.
class LockHelper {
public:
- explicit LockHelper(TextureCUBE* texture, CubeFace face, int level);
+ explicit LockHelper(TextureCUBE* texture, CubeFace face, int level,
+ AccessMode mode);
~LockHelper();
int pitch() const {
@@ -264,6 +280,7 @@ class TextureCUBE : public Texture {
}
private:
+ AccessMode mode_;
TextureCUBE* texture_;
CubeFace face_;
int level_;
@@ -378,10 +395,12 @@ class TextureCUBE : public Texture {
// texture_data: [out] a pointer to the current texture data
// pitch: bytes across 1 row of pixels if uncompressed format. bytes across 1
// row of blocks if compressed format.
+ // mode: The access mode.
// Returns:
// true if the operation succeeds
- virtual bool Lock(
- CubeFace face, int level, void** texture_data, int* pitch) = 0;
+ bool Lock(
+ CubeFace face, int level, void** texture_data, int* pitch,
+ AccessMode mode);
// Notifies the texture object that the internal texture data has been
// been modified. Unlock must be called in conjunction with Lock.
@@ -392,21 +411,30 @@ class TextureCUBE : public Texture {
// level: [in] the mipmap level that was modified
// Returns:
// true if the operation succeeds
- virtual bool Unlock(CubeFace face, int level) = 0;
+ bool Unlock(CubeFace face, int level);
+
+ // The platform specific part of Lock.
+ virtual bool PlatformSpecificLock(
+ CubeFace face, int level, void** texture_data, int* pitch,
+ AccessMode mode) = 0;
+
+ // The platform specific part of Unlock.
+ virtual bool PlatformSpecificUnlock(CubeFace face, int level) = 0;
// The platform specific part of GetRenderSurface.
virtual RenderSurface::Ref PlatformSpecificGetRenderSurface(
CubeFace face, int level) = 0;
- // Returns true if the mip-map level has been locked.
- bool IsLocked(unsigned int level, CubeFace face) {
+ // Returns the locked mode for a level
+ AccessMode LockedMode(CubeFace face, unsigned int level) {
DCHECK_LT(static_cast<int>(level), levels());
- return (locked_levels_[face] & (1 << level)) != 0;
+ return locked_levels_[face][level];
}
- // Bitfields that indicates mip levels that are currently locked, one per
- // face.
- unsigned int locked_levels_[NUMBER_OF_FACES];
+ // Returns true if the mip-map level has been locked.
+ bool IsLocked(CubeFace face, unsigned int level) {
+ return LockedMode(face, level) != kNone;
+ }
private:
friend class IClassManager;
@@ -419,6 +447,9 @@ class TextureCUBE : public Texture {
// The length of each edge of the cube, in texels.
ParamInteger::Ref edge_length_param_;
+ // AccessMode for each level on each face.
+ AccessMode locked_levels_[NUMBER_OF_FACES][kMaxLevels];
+
O3D_DECL_CLASS(TextureCUBE, Texture);
DISALLOW_COPY_AND_ASSIGN(TextureCUBE);
};