OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "gpu/command_buffer/service/feature_info.h" | 12 #include "gpu/command_buffer/service/feature_info.h" |
13 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
14 #include "gpu/gpu_export.h" | 14 #include "gpu/gpu_export.h" |
15 | 15 |
16 namespace gpu { | 16 namespace gpu { |
17 namespace gles2 { | 17 namespace gles2 { |
18 | 18 |
19 class GLES2Decoder; | 19 class GLES2Decoder; |
20 | 20 |
21 enum CopyTextureMethod { | |
22 // Use CopyTex{Sub}Image2D to copy from the source to the destination. | |
23 DIRECT_COPY, | |
24 // Draw from the source to the destination texture. | |
25 DIRECT_DRAW, | |
26 // Draw to an intermediate texture, and then copy to the destination texture. | |
27 DRAW_AND_COPY, | |
28 // CopyTexture isn't available. | |
29 NOT_COPYABLE | |
30 }; | |
31 | |
32 // TODOs(qiankun.miao@intel.com): | |
33 // 1. Add readback path for RGB9_E5 and float formats (if extension isn't | |
34 // available and they are not color-renderable). | |
35 // 2. Support faces of cube map texture as valid dest target. The cube map | |
36 // texture may be incomplete currently. | |
37 // 3. Add support for levels other than 0. | |
38 // 4. Support ALPHA, LUMINANCE and LUMINANCE_ALPHA formats on core profile. | |
39 // 5. Update the extension doc after the whole work is done | |
40 // in gpu/GLES2/extensions/CHROMIUM/CHROMIUM_copy_texture.txt. We probably | |
41 // will need a ES2 version and a ES3 version. | |
42 | |
43 // This class encapsulates the resources required to implement the | 21 // This class encapsulates the resources required to implement the |
44 // GL_CHROMIUM_copy_texture extension. The copy operation is performed | 22 // GL_CHROMIUM_copy_texture extension. The copy operation is performed |
45 // via glCopyTexImage2D() or a blit to a framebuffer object. | 23 // via glCopyTexImage2D() or a blit to a framebuffer object. |
46 // The target of |dest_id| texture must be GL_TEXTURE_2D. | 24 // The target of |dest_id| texture must be GL_TEXTURE_2D. |
47 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { | 25 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { |
48 public: | 26 public: |
49 CopyTextureCHROMIUMResourceManager(); | 27 CopyTextureCHROMIUMResourceManager(); |
50 ~CopyTextureCHROMIUMResourceManager(); | 28 ~CopyTextureCHROMIUMResourceManager(); |
51 | 29 |
52 void Initialize(const gles2::GLES2Decoder* decoder, | 30 void Initialize(const gles2::GLES2Decoder* decoder, |
53 const gles2::FeatureInfo::FeatureFlags& feature_flags); | 31 const gles2::FeatureInfo::FeatureFlags& feature_flags); |
54 void Destroy(); | 32 void Destroy(); |
55 | 33 |
56 void DoCopyTexture(const gles2::GLES2Decoder* decoder, | 34 void DoCopyTexture(const gles2::GLES2Decoder* decoder, |
57 GLenum source_target, | 35 GLenum source_target, |
58 GLuint source_id, | 36 GLuint source_id, |
59 GLenum source_internal_format, | 37 GLenum source_internal_format, |
60 GLenum dest_target, | 38 GLenum dest_target, |
61 GLuint dest_id, | 39 GLuint dest_id, |
62 GLenum dest_internal_format, | 40 GLenum dest_internal_format, |
63 GLsizei width, | 41 GLsizei width, |
64 GLsizei height, | 42 GLsizei height, |
65 bool flip_y, | 43 bool flip_y, |
66 bool premultiply_alpha, | 44 bool premultiply_alpha, |
67 bool unpremultiply_alpha, | 45 bool unpremultiply_alpha); |
68 CopyTextureMethod method); | |
69 | 46 |
70 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, | 47 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, |
71 GLenum source_target, | 48 GLenum source_target, |
72 GLuint source_id, | 49 GLuint source_id, |
73 GLenum source_internal_format, | 50 GLenum source_internal_format, |
74 GLenum dest_target, | 51 GLenum dest_target, |
75 GLuint dest_id, | 52 GLuint dest_id, |
76 GLenum dest_internal_format, | 53 GLenum dest_internal_format, |
77 GLint xoffset, | 54 GLint xoffset, |
78 GLint yoffset, | 55 GLint yoffset, |
79 GLint x, | 56 GLint x, |
80 GLint y, | 57 GLint y, |
81 GLsizei width, | 58 GLsizei width, |
82 GLsizei height, | 59 GLsizei height, |
83 GLsizei dest_width, | 60 GLsizei dest_width, |
84 GLsizei dest_height, | 61 GLsizei dest_height, |
85 GLsizei source_width, | 62 GLsizei source_width, |
86 GLsizei source_height, | 63 GLsizei source_height, |
87 bool flip_y, | 64 bool flip_y, |
88 bool premultiply_alpha, | 65 bool premultiply_alpha, |
89 bool unpremultiply_alpha, | 66 bool unpremultiply_alpha); |
90 CopyTextureMethod method); | |
91 | 67 |
92 void DoCopySubTextureWithTransform(const gles2::GLES2Decoder* decoder, | 68 void DoCopySubTextureWithTransform(const gles2::GLES2Decoder* decoder, |
93 GLenum source_target, | 69 GLenum source_target, |
94 GLuint source_id, | 70 GLuint source_id, |
95 GLenum source_internal_format, | 71 GLenum source_internal_format, |
96 GLenum dest_target, | 72 GLenum dest_target, |
97 GLuint dest_id, | 73 GLuint dest_id, |
98 GLenum dest_internal_format, | 74 GLenum dest_internal_format, |
99 GLint xoffset, | 75 GLint xoffset, |
100 GLint yoffset, | 76 GLint yoffset, |
(...skipping 10 matching lines...) Expand all Loading... |
111 bool unpremultiply_alpha, | 87 bool unpremultiply_alpha, |
112 const GLfloat transform_matrix[16]); | 88 const GLfloat transform_matrix[16]); |
113 | 89 |
114 // This will apply a transform on the texture coordinates before sampling | 90 // This will apply a transform on the texture coordinates before sampling |
115 // the source texture and copying to the destination texture. The transform | 91 // the source texture and copying to the destination texture. The transform |
116 // matrix should be given in column-major form, so it can be passed | 92 // matrix should be given in column-major form, so it can be passed |
117 // directly to GL. | 93 // directly to GL. |
118 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, | 94 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, |
119 GLenum source_target, | 95 GLenum source_target, |
120 GLuint source_id, | 96 GLuint source_id, |
121 GLenum source_format, | |
122 GLenum dest_target, | 97 GLenum dest_target, |
123 GLuint dest_id, | 98 GLuint dest_id, |
124 GLenum dest_format, | |
125 GLsizei width, | 99 GLsizei width, |
126 GLsizei height, | 100 GLsizei height, |
127 bool flip_y, | 101 bool flip_y, |
128 bool premultiply_alpha, | 102 bool premultiply_alpha, |
129 bool unpremultiply_alpha, | 103 bool unpremultiply_alpha, |
130 const GLfloat transform_matrix[16]); | 104 const GLfloat transform_matrix[16]); |
131 | 105 |
132 // The attributes used during invocation of the extension. | 106 // The attributes used during invocation of the extension. |
133 static const GLuint kVertexPositionAttrib = 0; | 107 static const GLuint kVertexPositionAttrib = 0; |
134 | 108 |
(...skipping 20 matching lines...) Expand all Loading... |
155 GLuint vertex_source_mult_handle; | 129 GLuint vertex_source_mult_handle; |
156 GLuint vertex_source_add_handle; | 130 GLuint vertex_source_add_handle; |
157 | 131 |
158 GLuint tex_coord_transform_handle; | 132 GLuint tex_coord_transform_handle; |
159 GLuint sampler_handle; | 133 GLuint sampler_handle; |
160 }; | 134 }; |
161 | 135 |
162 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, | 136 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, |
163 GLenum source_target, | 137 GLenum source_target, |
164 GLuint source_id, | 138 GLuint source_id, |
165 GLenum source_format, | |
166 GLenum dest_target, | 139 GLenum dest_target, |
167 GLuint dest_id, | 140 GLuint dest_id, |
168 GLenum dest_format, | |
169 GLint xoffset, | 141 GLint xoffset, |
170 GLint yoffset, | 142 GLint yoffset, |
171 GLint x, | 143 GLint x, |
172 GLint y, | 144 GLint y, |
173 GLsizei width, | 145 GLsizei width, |
174 GLsizei height, | 146 GLsizei height, |
175 GLsizei dest_width, | 147 GLsizei dest_width, |
176 GLsizei dest_height, | 148 GLsizei dest_height, |
177 GLsizei source_width, | 149 GLsizei source_width, |
178 GLsizei source_height, | 150 GLsizei source_height, |
179 bool flip_y, | 151 bool flip_y, |
180 bool premultiply_alpha, | 152 bool premultiply_alpha, |
181 bool unpremultiply_alpha, | 153 bool unpremultiply_alpha, |
182 const GLfloat transform_matrix[16]); | 154 const GLfloat transform_matrix[16]); |
183 | 155 |
184 bool initialized_; | 156 bool initialized_; |
185 bool nv_egl_stream_consumer_external_; | 157 bool nv_egl_stream_consumer_external_; |
186 typedef std::vector<GLuint> ShaderVector; | 158 typedef std::vector<GLuint> ShaderVector; |
187 ShaderVector vertex_shaders_; | 159 GLuint vertex_shader_; |
188 ShaderVector fragment_shaders_; | 160 ShaderVector fragment_shaders_; |
189 typedef int ProgramMapKey; | 161 typedef int ProgramMapKey; |
190 typedef base::hash_map<ProgramMapKey, ProgramInfo> ProgramMap; | 162 typedef base::hash_map<ProgramMapKey, ProgramInfo> ProgramMap; |
191 ProgramMap programs_; | 163 ProgramMap programs_; |
192 GLuint vertex_array_object_id_; | 164 GLuint vertex_array_object_id_; |
193 GLuint buffer_id_; | 165 GLuint buffer_id_; |
194 GLuint framebuffer_; | 166 GLuint framebuffer_; |
195 | 167 |
196 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); | 168 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); |
197 }; | 169 }; |
198 | 170 |
199 } // namespace gles2 | 171 } // namespace gles2 |
200 } // namespace gpu | 172 } // namespace gpu |
201 | 173 |
202 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 174 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
OLD | NEW |