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 <map> | |
9 | |
8 #include "gpu/command_buffer/service/gl_utils.h" | 10 #include "gpu/command_buffer/service/gl_utils.h" |
9 #include "gpu/gpu_export.h" | 11 #include "gpu/gpu_export.h" |
10 | 12 |
11 namespace gpu { | 13 namespace gpu { |
12 namespace gles2 { | 14 namespace gles2 { |
13 | 15 |
14 class GLES2Decoder; | 16 class GLES2Decoder; |
15 | 17 |
16 } // namespace gles2. | 18 } // namespace gles2. |
17 | 19 |
18 // This class encapsulates the resources required to implement the | 20 // This class encapsulates the resources required to implement the |
19 // GL_CHROMIUM_copy_texture extension. The copy operation is performed | 21 // GL_CHROMIUM_copy_texture extension. The copy operation is performed |
20 // via a blit to a framebuffer object. | 22 // via a blit to a framebuffer object. |
21 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { | 23 class GPU_EXPORT CopyTextureCHROMIUMResourceManager { |
22 public: | 24 public: |
23 CopyTextureCHROMIUMResourceManager(); | 25 CopyTextureCHROMIUMResourceManager(); |
26 ~CopyTextureCHROMIUMResourceManager(); | |
24 | 27 |
25 void Initialize(const gles2::GLES2Decoder* decoder); | 28 void Initialize(const gles2::GLES2Decoder* decoder); |
26 void Destroy(); | 29 void Destroy(); |
27 | 30 |
28 void DoCopyTexture(const gles2::GLES2Decoder* decoder, GLenum source_target, | 31 void DoCopyTexture(const gles2::GLES2Decoder* decoder, GLenum source_target, |
29 GLenum dest_target, GLuint source_id, GLuint dest_id, | 32 GLenum dest_target, GLuint source_id, GLuint dest_id, |
30 GLint level, GLsizei width, GLsizei height, | 33 GLint level, GLsizei width, GLsizei height, |
31 bool flip_y, bool premultiply_alpha, | 34 bool flip_y, bool premultiply_alpha, |
32 bool unpremultiply_alpha); | 35 bool unpremultiply_alpha); |
33 | 36 |
34 // This will apply a transform on the source texture before copying to | 37 // This will apply a transform on the source texture before copying to |
35 // destination texture. | 38 // destination texture. |
36 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, | 39 void DoCopyTextureWithTransform(const gles2::GLES2Decoder* decoder, |
37 GLenum source_target, GLenum dest_target, | 40 GLenum source_target, GLenum dest_target, |
38 GLuint source_id, GLuint dest_id, GLint level, | 41 GLuint source_id, GLuint dest_id, GLint level, |
39 GLsizei width, GLsizei height, bool flip_y, | 42 GLsizei width, GLsizei height, bool flip_y, |
40 bool premultiply_alpha, | 43 bool premultiply_alpha, |
41 bool unpremultiply_alpha, | 44 bool unpremultiply_alpha, |
42 const GLfloat transform_matrix[16]); | 45 const GLfloat transform_matrix[16]); |
43 | 46 |
44 // The attributes used during invocation of the extension. | 47 // The attributes used during invocation of the extension. |
45 static const GLuint kVertexPositionAttrib = 0; | 48 static const GLuint kVertexPositionAttrib = 0; |
46 | 49 |
47 private: | 50 private: |
51 struct ProgramInfo { | |
52 ProgramInfo() : program(0u), matrix_handle(0u), sampler_locations(0u) {} | |
53 | |
54 GLuint program; | |
55 GLuint matrix_handle; | |
56 GLuint sampler_locations; | |
57 }; | |
58 | |
48 bool initialized_; | 59 bool initialized_; |
49 | 60 typedef std::pair<int, int> ProgramMapKey; |
50 static const int kNumPrograms = 12; | 61 typedef std::map<ProgramMapKey, ProgramInfo> ProgramMap; |
piman
2014/04/25 03:30:40
nit: hash_map, or even SmallMap.
reveman
2014/04/25 20:27:10
Done.
| |
51 GLuint programs_[kNumPrograms]; | 62 ProgramMap programs_; |
52 GLuint buffer_id_; | 63 GLuint buffer_id_; |
53 GLuint framebuffer_; | 64 GLuint framebuffer_; |
54 GLuint matrix_handle_[kNumPrograms]; | 65 GLuint vertex_shader_; |
55 GLuint sampler_locations_[kNumPrograms]; | |
56 | 66 |
57 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); | 67 DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); |
58 }; | 68 }; |
59 | 69 |
60 } // namespace gpu. | 70 } // namespace gpu. |
61 | 71 |
62 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ | 72 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_COPY_TEXTURE_CHROMIUM_H_ |
63 | 73 |
64 | 74 |
OLD | NEW |