Chromium Code Reviews| Index: content/browser/renderer_host/compositing_iosurface_transformer_mac.h |
| diff --git a/content/browser/renderer_host/compositing_iosurface_transformer_mac.h b/content/browser/renderer_host/compositing_iosurface_transformer_mac.h |
| index d401b92d12f96e1e0c92c001b08cd2b078af25f6..48900741944157c88996db823c9c66345eb9ac38 100644 |
| --- a/content/browser/renderer_host/compositing_iosurface_transformer_mac.h |
| +++ b/content/browser/renderer_host/compositing_iosurface_transformer_mac.h |
| @@ -9,10 +9,10 @@ |
| #include "base/basictypes.h" |
| #include "content/browser/renderer_host/compositing_iosurface_shader_programs_mac.h" |
| +#include "ui/gfx/size.h" |
| namespace gfx { |
| class Rect; |
| -class Size; |
| } // namespace gfx |
| namespace content { |
| @@ -35,9 +35,15 @@ class CompositingIOSurfaceTransformer { |
| ~CompositingIOSurfaceTransformer(); |
| + // Delete any references to currently-cached OpenGL objects. This must be |
| + // called within the OpenGL context just before destruction. |
| + void ReleaseCachedGLObjects(); |
| + |
| // Resize using bilinear interpolation. Returns false on error. Otherwise, |
| - // the |texture| argument will point to the result and the caller is |
| - // responsible for calling glDeleteTexture(*texture). |
| + // the |texture| argument will point to the result. Ownership of the returned |
| + // |texture| remains with CompositingIOSurfaceTransformer (i.e., the caller |
| + // must not delete this texture). The |texture| remains valid until the next |
| + // call to ResizeBilinear() or ReleaseCachedGLObjects(). |
| // |
| // If the src and dst sizes are identical, this becomes a simple copy into a |
| // new texture. |
| @@ -51,15 +57,20 @@ class CompositingIOSurfaceTransformer { |
| // |
| // YV12 is effectively a twelve bit per pixel format consisting of a full- |
| // size y (luminance) plane and half-width, half-height u and v (blue and |
| - // red chrominance) planes. This method will allocate three off-screen |
| - // textures, one for each plane, and return them via the output arguments |
| - // |texture_y|, |texture_u|, and |texture_v|. While the textures are in |
| - // GL_RGBA format, they should be interpreted as the appropriate single-byte, |
| - // planar format after reading the pixel data. The output arguments |
| - // |packed_y_size| and |packed_uv_size| follow from these special semantics: |
| - // They represent the size of their corresponding texture, if it was to be |
| - // treated like RGBA pixel data. That means their widths are in terms of |
| - // "quads," where one quad contains 4 Y (or U or V) pixels. |
| + // red chrominance) planes. This method will return three off-screen |
| + // textures, one for each plane, via the output arguments |texture_y|, |
| + // |texture_u|, and |texture_v|. While the textures are in GL_RGBA format, |
| + // they should be interpreted as the appropriate single-byte, planar format |
| + // after reading the pixel data. The output arguments |packed_y_size| and |
| + // |packed_uv_size| follow from these special semantics: They represent the |
| + // size of their corresponding texture, if it was to be treated like RGBA |
| + // pixel data. That means their widths are in terms of "quads," where one |
| + // quad contains 4 Y (or U or V) pixels. |
| + // |
| + // Ownership of the returned textures remains with |
| + // CompositingIOSurfaceTransformer (i.e., the caller must not delete the |
| + // textures). The textures remain valid until the next call to |
| + // TransformRGBToYV12() or ReleaseCachedGLObjects(). |
| // |
| // If |src_subrect|'s size does not match |dst_size|, the source will be |
| // bilinearly interpolated during conversion. |
| @@ -73,6 +84,22 @@ class CompositingIOSurfaceTransformer { |
| gfx::Size* packed_y_size, gfx::Size* packed_uv_size); |
| private: |
| + enum CachedTexture { |
| + RGBA_OUTPUT = 0, |
| + Y_PLANE_OUTPUT, |
| + UUVV_INTERMEDIATE, |
| + U_PLANE_OUTPUT, |
| + V_PLANE_OUTPUT, |
| + NUM_CACHED_TEXTURES |
| + }; |
| + |
| + // If necessary, generate the texture and/or resize it to the given |size|. |
| + void PrepareTexture(CachedTexture which, const gfx::Size& size); |
|
ncarter (slow)
2013/04/15 23:38:19
Should this return the texture name?
miu
2013/04/16 03:51:22
If the method was public, I'd probably do that and
|
| + |
| + // If necessary, generate a framebuffer object to be used as an intermediate |
| + // destination for drawing. |
| + void PrepareFramebuffer(); |
| + |
| // Target to bind all input and output textures to (which defines the type of |
| // textures being created and read). Generally, this is |
| // GL_TEXTURE_RECTANGLE_ARB. |
| @@ -80,6 +107,11 @@ class CompositingIOSurfaceTransformer { |
| const bool src_texture_needs_y_flip_; |
| CompositingIOSurfaceShaderPrograms* const shader_program_cache_; |
| + // Cached OpenGL objects. |
| + GLuint textures_[NUM_CACHED_TEXTURES]; |
| + gfx::Size texture_sizes_[NUM_CACHED_TEXTURES]; |
| + GLuint frame_buffer_; |
| + |
| // Auto-detected and set once in the constructor. |
| bool system_supports_multiple_draw_buffers_; |