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 |
21 // This class encapsulates the resources required to implement the | 43 // This class encapsulates the resources required to implement the |
22 // GL_CHROMIUM_copy_texture extension. The copy operation is performed | 44 // GL_CHROMIUM_copy_texture extension. The copy operation is performed |
23 // via glCopyTexImage2D() or a blit to a framebuffer object. | 45 // via glCopyTexImage2D() or a blit to a framebuffer object. |
24 // The target of |dest_id| texture must be GL_TEXTURE_2D. | 46 // The target of |dest_id| texture must be GL_TEXTURE_2D. |
25 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { | 47 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { |
26 public: | 48 public: |
27 CopyTextureCHROMIUMResourceManager(); | 49 CopyTextureCHROMIUMResourceManager(); |
28 ~CopyTextureCHROMIUMResourceManager(); | 50 ~CopyTextureCHROMIUMResourceManager(); |
29 | 51 |
30 void Initialize(const gles2::GLES2Decoder* decoder, | 52 void Initialize(const gles2::GLES2Decoder* decoder, |
31 const gles2::FeatureInfo::FeatureFlags& feature_flags); | 53 const gles2::FeatureInfo::FeatureFlags& feature_flags); |
32 void Destroy(); | 54 void Destroy(); |
33 | 55 |
34 void DoCopyTexture(const gles2::GLES2Decoder* decoder, | 56 void DoCopyTexture(const gles2::GLES2Decoder* decoder, |
35 GLenum source_target, | 57 GLenum source_target, |
36 GLuint source_id, | 58 GLuint source_id, |
37 GLenum source_internal_format, | 59 GLenum source_internal_format, |
38 GLenum dest_target, | 60 GLenum dest_target, |
39 GLuint dest_id, | 61 GLuint dest_id, |
40 GLenum dest_internal_format, | 62 GLenum dest_internal_format, |
41 GLsizei width, | 63 GLsizei width, |
42 GLsizei height, | 64 GLsizei height, |
43 bool flip_y, | 65 bool flip_y, |
44 bool premultiply_alpha, | 66 bool premultiply_alpha, |
45 bool unpremultiply_alpha); | 67 bool unpremultiply_alpha, |
| 68 CopyTextureMethod method); |
46 | 69 |
47 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, | 70 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, |
48 GLenum source_target, | 71 GLenum source_target, |
49 GLuint source_id, | 72 GLuint source_id, |
50 GLenum source_internal_format, | 73 GLenum source_internal_format, |
51 GLenum dest_target, | 74 GLenum dest_target, |
52 GLuint dest_id, | 75 GLuint dest_id, |
53 GLenum dest_internal_format, | 76 GLenum dest_internal_format, |
54 GLint xoffset, | 77 GLint xoffset, |
55 GLint yoffset, | 78 GLint yoffset, |
56 GLint x, | 79 GLint x, |
57 GLint y, | 80 GLint y, |
58 GLsizei width, | 81 GLsizei width, |
59 GLsizei height, | 82 GLsizei height, |
60 GLsizei dest_width, | 83 GLsizei dest_width, |
61 GLsizei dest_height, | 84 GLsizei dest_height, |
62 GLsizei source_width, | 85 GLsizei source_width, |
63 GLsizei source_height, | 86 GLsizei source_height, |
64 bool flip_y, | 87 bool flip_y, |
65 bool premultiply_alpha, | 88 bool premultiply_alpha, |
66 bool unpremultiply_alpha); | 89 bool unpremultiply_alpha, |
| 90 CopyTextureMethod method); |
67 | 91 |
68 void DoCopySubTextureWithTransform(const gles2::GLES2Decoder* decoder, | 92 void DoCopySubTextureWithTransform(const gles2::GLES2Decoder* decoder, |
69 GLenum source_target, | 93 GLenum source_target, |
70 GLuint source_id, | 94 GLuint source_id, |
71 GLenum source_internal_format, | 95 GLenum source_internal_format, |
72 GLenum dest_target, | 96 GLenum dest_target, |
73 GLuint dest_id, | 97 GLuint dest_id, |
74 GLenum dest_internal_format, | 98 GLenum dest_internal_format, |
75 GLint xoffset, | 99 GLint xoffset, |
76 GLint yoffset, | 100 GLint yoffset, |
(...skipping 10 matching lines...) Expand all Loading... |
87 bool unpremultiply_alpha, | 111 bool unpremultiply_alpha, |
88 const GLfloat transform_matrix[16]); | 112 const GLfloat transform_matrix[16]); |
89 | 113 |
90 // This will apply a transform on the texture coordinates before sampling | 114 // This will apply a transform on the texture coordinates before sampling |
91 // the source texture and copying to the destination texture. The transform | 115 // the source texture and copying to the destination texture. The transform |
92 // matrix should be given in column-major form, so it can be passed | 116 // matrix should be given in column-major form, so it can be passed |
93 // directly to GL. | 117 // directly to GL. |
94 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, | 118 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, |
95 GLenum source_target, | 119 GLenum source_target, |
96 GLuint source_id, | 120 GLuint source_id, |
| 121 GLenum source_format, |
97 GLenum dest_target, | 122 GLenum dest_target, |
98 GLuint dest_id, | 123 GLuint dest_id, |
| 124 GLenum dest_format, |
99 GLsizei width, | 125 GLsizei width, |
100 GLsizei height, | 126 GLsizei height, |
101 bool flip_y, | 127 bool flip_y, |
102 bool premultiply_alpha, | 128 bool premultiply_alpha, |
103 bool unpremultiply_alpha, | 129 bool unpremultiply_alpha, |
104 const GLfloat transform_matrix[16]); | 130 const GLfloat transform_matrix[16]); |
105 | 131 |
106 // The attributes used during invocation of the extension. | 132 // The attributes used during invocation of the extension. |
107 static const GLuint kVertexPositionAttrib = 0; | 133 static const GLuint kVertexPositionAttrib = 0; |
108 | 134 |
(...skipping 20 matching lines...) Expand all Loading... |
129 GLuint vertex_source_mult_handle; | 155 GLuint vertex_source_mult_handle; |
130 GLuint vertex_source_add_handle; | 156 GLuint vertex_source_add_handle; |
131 | 157 |
132 GLuint tex_coord_transform_handle; | 158 GLuint tex_coord_transform_handle; |
133 GLuint sampler_handle; | 159 GLuint sampler_handle; |
134 }; | 160 }; |
135 | 161 |
136 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, | 162 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, |
137 GLenum source_target, | 163 GLenum source_target, |
138 GLuint source_id, | 164 GLuint source_id, |
| 165 GLenum source_format, |
139 GLenum dest_target, | 166 GLenum dest_target, |
140 GLuint dest_id, | 167 GLuint dest_id, |
| 168 GLenum dest_format, |
141 GLint xoffset, | 169 GLint xoffset, |
142 GLint yoffset, | 170 GLint yoffset, |
143 GLint x, | 171 GLint x, |
144 GLint y, | 172 GLint y, |
145 GLsizei width, | 173 GLsizei width, |
146 GLsizei height, | 174 GLsizei height, |
147 GLsizei dest_width, | 175 GLsizei dest_width, |
148 GLsizei dest_height, | 176 GLsizei dest_height, |
149 GLsizei source_width, | 177 GLsizei source_width, |
150 GLsizei source_height, | 178 GLsizei source_height, |
(...skipping 14 matching lines...) Expand all Loading... |
165 GLuint buffer_id_; | 193 GLuint buffer_id_; |
166 GLuint framebuffer_; | 194 GLuint framebuffer_; |
167 | 195 |
168 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); | 196 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); |
169 }; | 197 }; |
170 | 198 |
171 } // namespace gles2 | 199 } // namespace gles2 |
172 } // namespace gpu | 200 } // namespace gpu |
173 | 201 |
174 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 202 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
OLD | NEW |