Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: gpu/command_buffer/service/texture_manager.h

Issue 1154053002: gpu: Use a rectangle to keep track of the cleared area of each texture level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: v2 Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/texture_manager.h
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index d9576f7e58755cb6b3138759e950d97d32ddd8c5..b1f80d0c2ca4c6f97ff022889239c82cca0f0995 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -17,6 +17,7 @@
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/gpu_export.h"
+#include "ui/gfx/geometry/rect.h"
#include "ui/gl/gl_image.h"
namespace gpu {
@@ -92,10 +93,6 @@ class GPU_EXPORT Texture {
return max_level_;
}
- int num_uncleared_mips() const {
- return num_uncleared_mips_;
- }
-
uint32 estimated_size() const {
return estimated_size_;
}
@@ -182,6 +179,10 @@ class GPU_EXPORT Texture {
return immutable_;
}
+ // Get the cleared rectangle for a particular level. Returns an empty
+ // rectangle if level does not exist.
+ gfx::Rect GetLevelClearedRect(GLenum target, GLint level) const;
+
// Whether a particular level/face is cleared.
bool IsLevelCleared(GLenum target, GLint level) const;
@@ -227,7 +228,7 @@ class GPU_EXPORT Texture {
LevelInfo(const LevelInfo& rhs);
~LevelInfo();
- bool cleared;
+ gfx::Rect cleared_rect;
GLenum target;
GLint level;
GLenum internal_format;
@@ -250,18 +251,17 @@ class GPU_EXPORT Texture {
};
// Set the info for a particular level.
- void SetLevelInfo(
- const FeatureInfo* feature_info,
- GLenum target,
- GLint level,
- GLenum internal_format,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLenum format,
- GLenum type,
- bool cleared);
+ void SetLevelInfo(const FeatureInfo* feature_info,
+ GLenum target,
+ GLint level,
+ GLenum internal_format,
+ GLsizei width,
+ GLsizei height,
+ GLsizei depth,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ const gfx::Rect& cleared_rect);
// In GLES2 "texture complete" means it has all required mips for filtering
// down to a 1x1 pixel texture, they are in the correct order, they are all
@@ -281,12 +281,14 @@ class GPU_EXPORT Texture {
return npot_;
}
+ // Marks a |rect| of a particular level as cleared.
+ void SetLevelClearedRect(GLenum target,
+ GLint level,
+ const gfx::Rect& cleared_rect);
+
// Marks a particular level as cleared or uncleared.
void SetLevelCleared(GLenum target, GLint level, bool cleared);
- // Updates the cleared flag for this texture by inspecting all the mips.
- void UpdateCleared();
-
// Clears any renderable uncleared levels.
// Returns false if a GL error was generated.
bool ClearRenderableLevels(GLES2Decoder* decoder);
@@ -370,11 +372,7 @@ class GPU_EXPORT Texture {
// Updates the unsafe textures count in all the managers referencing this
// texture.
- void UpdateSafeToRenderFrom(bool cleared);
-
- // Updates the uncleared mip count in all the managers referencing this
- // texture.
- void UpdateMipCleared(LevelInfo* info, bool cleared);
+ void UpdateSafeToRenderFrom();
// Computes the CanRenderCondition flag.
CanRenderCondition GetCanRenderCondition() const;
@@ -410,7 +408,6 @@ class GPU_EXPORT Texture {
// Whether all renderable mips of this texture have been cleared.
bool cleared_;
- int num_uncleared_mips_;
int num_npot_faces_;
// The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
@@ -649,27 +646,25 @@ class GPU_EXPORT TextureManager {
GLenum target);
// Set the info for a particular level in a TexureInfo.
- void SetLevelInfo(
- TextureRef* ref,
- GLenum target,
- GLint level,
- GLenum internal_format,
- GLsizei width,
- GLsizei height,
- GLsizei depth,
- GLint border,
- GLenum format,
- GLenum type,
- bool cleared);
+ void SetLevelInfo(TextureRef* ref,
+ GLenum target,
+ GLint level,
+ GLenum internal_format,
+ GLsizei width,
+ GLsizei height,
+ GLsizei depth,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ const gfx::Rect& cleared_rect);
// Adapter to call above function.
void SetLevelInfoFromParams(TextureRef* ref,
const gpu::AsyncTexImage2DParams& params) {
- SetLevelInfo(
- ref, params.target, params.level, params.internal_format,
- params.width, params.height, 1 /* depth */,
- params.border, params.format,
- params.type, true /* cleared */);
+ SetLevelInfo(ref, params.target, params.level, params.internal_format,
+ params.width, params.height, 1 /* depth */, params.border,
+ params.format, params.type,
+ gfx::Rect(params.width, params.height) /* cleared_rect */);
}
Texture* Produce(TextureRef* ref);
@@ -677,6 +672,12 @@ class GPU_EXPORT TextureManager {
// Maps an existing texture into the texture manager, at a given client ID.
TextureRef* Consume(GLuint client_id, Texture* texture);
+ // Sets |rect| of mip as cleared.
+ void SetLevelClearedRect(TextureRef* ref,
+ GLenum target,
+ GLint level,
+ const gfx::Rect& cleared_rect);
+
// Sets a mip as cleared.
void SetLevelCleared(TextureRef* ref, GLenum target,
GLint level, bool cleared);
@@ -739,10 +740,6 @@ class GPU_EXPORT TextureManager {
return num_unsafe_textures_ > 0;
}
- bool HaveUnclearedMips() const {
- return num_uncleared_mips_ > 0;
- }
-
bool HaveImages() const {
return num_images_ > 0;
}
@@ -862,7 +859,6 @@ class GPU_EXPORT TextureManager {
void StopTracking(TextureRef* texture);
void UpdateSafeToRenderFrom(int delta);
- void UpdateUnclearedMips(int delta);
void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition,
Texture::CanRenderCondition new_condition);
void UpdateNumImages(int delta);
@@ -894,7 +890,6 @@ class GPU_EXPORT TextureManager {
int num_unrenderable_textures_;
int num_unsafe_textures_;
- int num_uncleared_mips_;
int num_images_;
// Counts the number of Textures allocated with 'this' as its manager.

Powered by Google App Engine
This is Rietveld 408576698