| 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 "gpu/command_buffer/service/gl_utils.h" | 11 #include "gpu/command_buffer/service/gl_utils.h" |
| 12 #include "gpu/gpu_export.h" | 12 #include "gpu/gpu_export.h" |
| 13 | 13 |
| 14 namespace gpu { | 14 namespace gpu { |
| 15 namespace gles2 { | 15 namespace gles2 { |
| 16 | 16 |
| 17 struct DecoderTextureState; | |
| 18 class GLES2Decoder; | 17 class GLES2Decoder; |
| 19 | 18 |
| 20 } // namespace gles2. | 19 } // namespace gles2. |
| 21 | 20 |
| 22 // This class encapsulates the resources required to implement the | 21 // This class encapsulates the resources required to implement the |
| 23 // GL_CHROMIUM_copy_texture extension. The copy operation is performed | 22 // GL_CHROMIUM_copy_texture extension. The copy operation is performed |
| 24 // via glCopyTexImage2D() or a blit to a framebuffer object. | 23 // via glCopyTexImage2D() or a blit to a framebuffer object. |
| 25 // The target of |dest_id| texture must be GL_TEXTURE_2D. | 24 // The target of |dest_id| texture must be GL_TEXTURE_2D. |
| 26 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { | 25 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { |
| 27 public: | 26 public: |
| 28 CopyTextureCHROMIUMResourceManager(); | 27 CopyTextureCHROMIUMResourceManager(); |
| 29 ~CopyTextureCHROMIUMResourceManager(); | 28 ~CopyTextureCHROMIUMResourceManager(); |
| 30 | 29 |
| 31 void Initialize(const gles2::GLES2Decoder* decoder); | 30 void Initialize(const gles2::GLES2Decoder* decoder); |
| 32 void Destroy(); | 31 void Destroy(); |
| 33 | 32 |
| 34 void DoCopyTexture(const gles2::GLES2Decoder* decoder, | 33 void DoCopyTexture(const gles2::GLES2Decoder* decoder, |
| 35 GLenum source_target, | 34 GLenum source_target, |
| 36 GLuint source_id, | 35 GLuint source_id, |
| 37 GLenum source_internal_format, | 36 GLenum source_internal_format, |
| 38 GLenum dest_target, | |
| 39 GLuint dest_id, | 37 GLuint dest_id, |
| 40 GLenum dest_internal_format, | 38 GLenum dest_internal_format, |
| 41 GLenum dest_type, | |
| 42 GLsizei width, | 39 GLsizei width, |
| 43 GLsizei height, | 40 GLsizei height, |
| 44 bool flip_y, | 41 bool flip_y, |
| 45 bool premultiply_alpha, | 42 bool premultiply_alpha, |
| 46 bool unpremultiply_alpha, | 43 bool unpremultiply_alpha); |
| 47 const gles2::DecoderTextureState* texture_state); | |
| 48 | 44 |
| 49 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, | 45 void DoCopySubTexture(const gles2::GLES2Decoder* decoder, |
| 50 GLenum source_target, | 46 GLenum source_target, |
| 51 GLuint source_id, | 47 GLuint source_id, |
| 52 GLenum source_internal_format, | 48 GLenum source_internal_format, |
| 53 GLenum dest_target, | |
| 54 GLuint dest_id, | 49 GLuint dest_id, |
| 55 GLenum dest_internal_format, | 50 GLenum dest_internal_format, |
| 56 GLenum dest_type, | |
| 57 GLint xoffset, | 51 GLint xoffset, |
| 58 GLint yoffset, | 52 GLint yoffset, |
| 59 GLint x, | 53 GLint x, |
| 60 GLint y, | 54 GLint y, |
| 61 GLsizei width, | 55 GLsizei width, |
| 62 GLsizei height, | 56 GLsizei height, |
| 63 GLsizei dest_width, | 57 GLsizei dest_width, |
| 64 GLsizei dest_height, | 58 GLsizei dest_height, |
| 65 GLsizei source_width, | 59 GLsizei source_width, |
| 66 GLsizei source_height, | 60 GLsizei source_height, |
| 67 bool flip_y, | 61 bool flip_y, |
| 68 bool premultiply_alpha, | 62 bool premultiply_alpha, |
| 69 bool unpremultiply_alpha, | 63 bool unpremultiply_alpha); |
| 70 const gles2::DecoderTextureState* texture_state); | |
| 71 | 64 |
| 72 // This will apply a transform on the texture coordinates before sampling | 65 // This will apply a transform on the texture coordinates before sampling |
| 73 // the source texture and copying to the destination texture. The transform | 66 // the source texture and copying to the destination texture. The transform |
| 74 // matrix should be given in column-major form, so it can be passed | 67 // matrix should be given in column-major form, so it can be passed |
| 75 // directly to GL. | 68 // directly to GL. |
| 76 void DoCopyTextureWithTransform( | 69 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, |
| 77 const gles2::GLES2Decoder* decoder, | 70 GLenum source_target, |
| 78 GLenum source_target, | 71 GLuint source_id, |
| 79 GLuint source_id, | 72 GLuint dest_id, |
| 80 GLenum dest_target, | 73 GLsizei width, |
| 81 GLuint dest_id, | 74 GLsizei height, |
| 82 GLenum dest_internal_format, | 75 bool flip_y, |
| 83 GLenum dest_type, | 76 bool premultiply_alpha, |
| 84 GLsizei width, | 77 bool unpremultiply_alpha, |
| 85 GLsizei height, | 78 const GLfloat transform_matrix[16]); |
| 86 bool flip_y, | |
| 87 bool premultiply_alpha, | |
| 88 bool unpremultiply_alpha, | |
| 89 const gles2::DecoderTextureState* texture_state, | |
| 90 const GLfloat transform_matrix[16]); | |
| 91 | 79 |
| 92 // The attributes used during invocation of the extension. | 80 // The attributes used during invocation of the extension. |
| 93 static const GLuint kVertexPositionAttrib = 0; | 81 static const GLuint kVertexPositionAttrib = 0; |
| 94 | 82 |
| 95 private: | 83 private: |
| 96 struct ProgramInfo { | 84 struct ProgramInfo { |
| 97 ProgramInfo() | 85 ProgramInfo() |
| 98 : program(0u), | 86 : program(0u), |
| 99 vertex_translate_handle(0u), | 87 vertex_translate_handle(0u), |
| 100 tex_coord_transform_handle(0u), | 88 tex_coord_transform_handle(0u), |
| 101 half_size_handle(0u), | 89 half_size_handle(0u), |
| 102 sampler_handle(0u) {} | 90 sampler_handle(0u) {} |
| 103 | 91 |
| 104 GLuint program; | 92 GLuint program; |
| 105 GLuint vertex_translate_handle; | 93 GLuint vertex_translate_handle; |
| 106 GLuint tex_coord_transform_handle; | 94 GLuint tex_coord_transform_handle; |
| 107 GLuint half_size_handle; | 95 GLuint half_size_handle; |
| 108 GLuint sampler_handle; | 96 GLuint sampler_handle; |
| 109 }; | 97 }; |
| 110 | 98 |
| 111 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, | 99 void DoCopyTextureInternal(const gles2::GLES2Decoder* decoder, |
| 112 GLenum source_target, | 100 GLenum source_target, |
| 113 GLuint source_id, | 101 GLuint source_id, |
| 114 GLenum dest_target, | |
| 115 GLuint dest_id, | 102 GLuint dest_id, |
| 116 GLint xoffset, | 103 GLint xoffset, |
| 117 GLint yoffset, | 104 GLint yoffset, |
| 118 GLint x, | 105 GLint x, |
| 119 GLint y, | 106 GLint y, |
| 120 GLsizei width, | 107 GLsizei width, |
| 121 GLsizei height, | 108 GLsizei height, |
| 122 GLsizei dest_width, | 109 GLsizei dest_width, |
| 123 GLsizei dest_height, | 110 GLsizei dest_height, |
| 124 GLsizei source_width, | 111 GLsizei source_width, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 137 ProgramMap programs_; | 124 ProgramMap programs_; |
| 138 GLuint buffer_id_; | 125 GLuint buffer_id_; |
| 139 GLuint framebuffer_; | 126 GLuint framebuffer_; |
| 140 | 127 |
| 141 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); | 128 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); |
| 142 }; | 129 }; |
| 143 | 130 |
| 144 } // namespace gpu. | 131 } // namespace gpu. |
| 145 | 132 |
| 146 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 133 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
| OLD | NEW |