Chromium Code Reviews| Index: cc/resources/resource_provider.h |
| diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h |
| index 8b4b01b6acaa49c0741d5daf000cdb65b5edd6c1..b553eba01c25592b886b43f3e40619f5a78315e3 100644 |
| --- a/cc/resources/resource_provider.h |
| +++ b/cc/resources/resource_provider.h |
| @@ -18,6 +18,7 @@ |
| #include "cc/base/cc_export.h" |
| #include "cc/output/context_provider.h" |
| #include "cc/output/output_surface.h" |
| +#include "cc/resources/resource_format.h" |
| #include "cc/resources/texture_mailbox.h" |
| #include "cc/resources/transferable_resource.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| @@ -54,8 +55,8 @@ class CC_EXPORT ResourceProvider { |
| }; |
| static scoped_ptr<ResourceProvider> Create(OutputSurface* output_surface, |
| - int highp_threshold_min); |
| - |
| + int highp_threshold_min, |
| + bool use_rgba_4444_texture_format); |
|
epenner
2013/09/17 19:29:28
Nit: Can we remove this and just pass in both 'bes
|
| virtual ~ResourceProvider(); |
| void InitializeSoftware(); |
| @@ -64,7 +65,10 @@ class CC_EXPORT ResourceProvider { |
| void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| int max_texture_size() const { return max_texture_size_; } |
| - GLenum best_texture_format() const { return best_texture_format_; } |
| + ResourceFormat memory_efficient_texture_format() const { |
| + return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
| + } |
| + ResourceFormat best_texture_format() const { return best_texture_format_; } |
| size_t num_resources() const { return resources_.size(); } |
| // Checks whether a resource is in use by a consumer. |
| @@ -78,23 +82,23 @@ class CC_EXPORT ResourceProvider { |
| // Creates a resource of the default resource type. |
| ResourceId CreateResource(gfx::Size size, |
| - GLenum format, |
| GLint wrap_mode, |
| - TextureUsageHint hint); |
| + TextureUsageHint hint, |
| + ResourceFormat format); |
| // Creates a resource which is tagged as being managed for GPU memory |
| // accounting purposes. |
| ResourceId CreateManagedResource(gfx::Size size, |
| - GLenum format, |
| GLint wrap_mode, |
| - TextureUsageHint hint); |
| + TextureUsageHint hint, |
| + ResourceFormat format); |
| // You can also explicitly create a specific resource type. |
| ResourceId CreateGLTexture(gfx::Size size, |
| - GLenum format, |
| GLenum texture_pool, |
| GLint wrap_mode, |
| - TextureUsageHint hint); |
| + TextureUsageHint hint, |
| + ResourceFormat format); |
| ResourceId CreateBitmap(gfx::Size size); |
| // Wraps an external texture into a GL resource. |
| @@ -330,6 +334,10 @@ class CC_EXPORT ResourceProvider { |
| bool CanLockForWrite(ResourceId id); |
| static GLint GetActiveTextureUnit(WebKit::WebGraphicsContext3D* context); |
| + static size_t BytesPerPixel(ResourceFormat format); |
| + static GLenum GetGLDataType(ResourceFormat format); |
| + static GLenum GetGLDataFormat(ResourceFormat format); |
| + static GLenum GetGLInternalFormat(ResourceFormat format); |
| private: |
| struct Resource { |
| @@ -337,14 +345,13 @@ class CC_EXPORT ResourceProvider { |
| ~Resource(); |
| Resource(unsigned texture_id, |
| gfx::Size size, |
| - GLenum format, |
| GLenum filter, |
| GLenum texture_pool, |
| GLint wrap_mode, |
| - TextureUsageHint hint); |
| + TextureUsageHint hint, |
| + ResourceFormat format); |
| Resource(uint8_t* pixels, |
| gfx::Size size, |
| - GLenum format, |
| GLenum filter, |
| GLint wrap_mode); |
| @@ -368,7 +375,6 @@ class CC_EXPORT ResourceProvider { |
| bool enable_read_lock_fences; |
| scoped_refptr<Fence> read_lock_fence; |
| gfx::Size size; |
| - GLenum format; |
| // TODO(skyostil): Use a separate sampler object for filter state. |
| GLenum original_filter; |
| GLenum filter; |
| @@ -378,6 +384,7 @@ class CC_EXPORT ResourceProvider { |
| GLint wrap_mode; |
| TextureUsageHint hint; |
| ResourceType type; |
| + ResourceFormat format; |
| }; |
| typedef base::hash_map<ResourceId, Resource> ResourceMap; |
| struct Child { |
| @@ -394,8 +401,9 @@ class CC_EXPORT ResourceProvider { |
| resource->read_lock_fence->HasPassed(); |
| } |
| - explicit ResourceProvider(OutputSurface* output_surface, |
| - int highp_threshold_min); |
| + ResourceProvider(OutputSurface* output_surface, |
| + int highp_threshold_min, |
| + bool use_rgba_4444_texture_format); |
| void CleanUpGLIfNeeded(); |
| @@ -446,11 +454,12 @@ class CC_EXPORT ResourceProvider { |
| bool use_shallow_flush_; |
| scoped_ptr<TextureUploader> texture_uploader_; |
| int max_texture_size_; |
| - GLenum best_texture_format_; |
| + ResourceFormat best_texture_format_; |
| base::ThreadChecker thread_checker_; |
| scoped_refptr<Fence> current_read_lock_fence_; |
| + bool use_rgba_4444_texture_format_; |
| DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| }; |