OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ |
7 | 7 |
| 8 #include <deque> |
| 9 #include <map> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "content/common/gpu/client/gl_helper.h" | 12 #include "content/common/gpu/client/gl_helper.h" |
| 13 #include "ui/gfx/rect.h" |
| 14 #include "ui/gfx/size.h" |
11 | 15 |
12 namespace content { | 16 namespace content { |
13 | 17 |
14 class ShaderProgram; | 18 class ShaderProgram; |
15 class ScalerImpl; | 19 class ScalerImpl; |
16 class GLHelperTest; | 20 class GLHelperTest; |
17 | 21 |
18 // Implements GPU texture scaling methods. | 22 // Implements GPU texture scaling methods. |
19 // Note that you should probably not use this class directly. | 23 // Note that you should probably not use this class directly. |
20 // See gl_helper.cc::CreateScaler instead. | 24 // See gl_helper.cc::CreateScaler instead. |
(...skipping 13 matching lines...) Expand all Loading... |
34 }; | 38 }; |
35 | 39 |
36 // Similar to ScalerInterface, but can generate multiple outputs. | 40 // Similar to ScalerInterface, but can generate multiple outputs. |
37 // Used for YUV conversion in gl_helper.c | 41 // Used for YUV conversion in gl_helper.c |
38 class CONTENT_EXPORT ShaderInterface { | 42 class CONTENT_EXPORT ShaderInterface { |
39 public: | 43 public: |
40 ShaderInterface() {} | 44 ShaderInterface() {} |
41 virtual ~ShaderInterface() {} | 45 virtual ~ShaderInterface() {} |
42 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 46 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
43 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 47 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
44 virtual void Execute(blink::WebGLId source_texture, | 48 virtual void Execute(GLuint source_texture, |
45 const std::vector<blink::WebGLId>& dest_textures) = 0; | 49 const std::vector<GLuint>& dest_textures) = 0; |
46 }; | 50 }; |
47 | 51 |
48 typedef std::pair<ShaderType, bool> ShaderProgramKeyType; | 52 typedef std::pair<ShaderType, bool> ShaderProgramKeyType; |
49 | 53 |
50 GLHelperScaling(blink::WebGraphicsContext3D* context, | 54 GLHelperScaling(gpu::gles2::GLES2Interface* gl, |
51 GLHelper* helper); | 55 GLHelper* helper); |
52 ~GLHelperScaling(); | 56 ~GLHelperScaling(); |
53 void InitBuffer(); | 57 void InitBuffer(); |
54 | 58 |
55 GLHelper::ScalerInterface* CreateScaler( | 59 GLHelper::ScalerInterface* CreateScaler( |
56 GLHelper::ScalerQuality quality, | 60 GLHelper::ScalerQuality quality, |
57 gfx::Size src_size, | 61 gfx::Size src_size, |
58 gfx::Rect src_subrect, | 62 gfx::Rect src_subrect, |
59 const gfx::Size& dst_size, | 63 const gfx::Size& dst_size, |
60 bool vertically_flip_texture, | 64 bool vertically_flip_texture, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bool swizzle, | 179 bool swizzle, |
176 std::deque<GLHelperScaling::ScaleOp>* x_ops, | 180 std::deque<GLHelperScaling::ScaleOp>* x_ops, |
177 std::deque<GLHelperScaling::ScaleOp>* y_ops, | 181 std::deque<GLHelperScaling::ScaleOp>* y_ops, |
178 std::vector<ScalerStage> *scaler_stages); | 182 std::vector<ScalerStage> *scaler_stages); |
179 | 183 |
180 | 184 |
181 scoped_refptr<ShaderProgram> GetShaderProgram(ShaderType type, bool swizzle); | 185 scoped_refptr<ShaderProgram> GetShaderProgram(ShaderType type, bool swizzle); |
182 | 186 |
183 // Interleaved array of 2-dimentional vertex positions (x, y) and | 187 // Interleaved array of 2-dimentional vertex positions (x, y) and |
184 // 2-dimentional texture coordinates (s, t). | 188 // 2-dimentional texture coordinates (s, t). |
185 static const blink::WGC3Dfloat kVertexAttributes[]; | 189 static const GLfloat kVertexAttributes[]; |
186 | 190 |
187 blink::WebGraphicsContext3D* context_; | 191 gpu::gles2::GLES2Interface* gl_; |
188 GLHelper* helper_; | 192 GLHelper* helper_; |
189 | 193 |
190 // The buffer that holds the vertices and the texture coordinates data for | 194 // The buffer that holds the vertices and the texture coordinates data for |
191 // drawing a quad. | 195 // drawing a quad. |
192 ScopedBuffer vertex_attributes_buffer_; | 196 ScopedBuffer vertex_attributes_buffer_; |
193 | 197 |
194 std::map<ShaderProgramKeyType, | 198 std::map<ShaderProgramKeyType, |
195 scoped_refptr<ShaderProgram> > shader_programs_; | 199 scoped_refptr<ShaderProgram> > shader_programs_; |
196 | 200 |
197 friend class ShaderProgram; | 201 friend class ShaderProgram; |
198 friend class ScalerImpl; | 202 friend class ScalerImpl; |
199 friend class GLHelperTest; | 203 friend class GLHelperTest; |
200 DISALLOW_COPY_AND_ASSIGN(GLHelperScaling); | 204 DISALLOW_COPY_AND_ASSIGN(GLHelperScaling); |
201 }; | 205 }; |
202 | 206 |
203 | 207 |
204 } // namespace content | 208 } // namespace content |
205 | 209 |
206 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ | 210 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_SCALING_H_ |
OLD | NEW |