1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_
10 #include "base/containers/hash_tables.h"
11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "gpu/gpu_export.h"
21 // This class encapsulates the resources required to implement the
22 // GL_CHROMIUM_copy_texture extension. The copy operation is performed
23 // via glCopyTexImage2D() or a blit to a framebuffer object.
24 // The target of |dest_id| texture must be GL_TEXTURE_2D.
25 class GPU_EXPORT CopyTextureCHROMIUMResourceManager
{
27 CopyTextureCHROMIUMResourceManager();
28 ~CopyTextureCHROMIUMResourceManager();
30 void Initialize(const gles2::GLES2Decoder
* decoder
);
33 void DoCopyTexture(const gles2::GLES2Decoder
* decoder
,
36 GLenum source_internal_format
,
38 GLenum dest_internal_format
,
42 bool premultiply_alpha
,
43 bool unpremultiply_alpha
);
45 void DoCopySubTexture(const gles2::GLES2Decoder
* decoder
,
48 GLenum source_internal_format
,
50 GLenum dest_internal_format
,
56 GLsizei source_height
,
58 bool premultiply_alpha
,
59 bool unpremultiply_alpha
);
61 // This will apply a transform on the source texture before copying to
62 // destination texture.
63 void DoCopyTextureWithTransform(const gles2::GLES2Decoder
* decoder
,
70 bool premultiply_alpha
,
71 bool unpremultiply_alpha
,
72 const GLfloat transform_matrix
[16]);
74 void DoCopySubTextureWithTransform(const gles2::GLES2Decoder
* decoder
,
83 GLsizei source_height
,
85 bool premultiply_alpha
,
86 bool unpremultiply_alpha
,
87 const GLfloat transform_matrix
[16]);
89 // The attributes used during invocation of the extension.
90 static const GLuint kVertexPositionAttrib
= 0;
101 GLuint matrix_handle
;
102 GLuint half_size_handle
;
103 GLuint sampler_handle
;
106 void DoCopyTextureInternal(const gles2::GLES2Decoder
* decoder
,
107 GLenum source_target
,
114 GLsizei source_width
,
115 GLsizei source_height
,
117 bool premultiply_alpha
,
118 bool unpremultiply_alpha
,
119 const GLfloat transform_matrix
[16]);
122 typedef std::vector
<GLuint
> ShaderVector
;
123 ShaderVector vertex_shaders_
;
124 ShaderVector fragment_shaders_
;
125 typedef std::pair
<int, int> ProgramMapKey
;
126 typedef base::hash_map
<ProgramMapKey
, ProgramInfo
> ProgramMap
;
127 ProgramMap programs_
;
131 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager
);
136 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_