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 #include "content/common/gpu/client/gl_helper_scaling.h" | 5 #include "content/common/gpu/client/gl_helper_scaling.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "third_party/WebKit/public/platform/WebCString.h" | 18 #include "third_party/WebKit/public/platform/WebCString.h" |
19 #include "third_party/skia/include/core/SkRegion.h" | 19 #include "third_party/skia/include/core/SkRegion.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
22 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
23 | 23 |
24 using WebKit::WebGLId; | 24 using blink::WebGLId; |
25 using WebKit::WebGraphicsContext3D; | 25 using blink::WebGraphicsContext3D; |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 GLHelperScaling::GLHelperScaling(WebKit::WebGraphicsContext3D* context, | 29 GLHelperScaling::GLHelperScaling(blink::WebGraphicsContext3D* context, |
30 GLHelper* helper) | 30 GLHelper* helper) |
31 : context_(context), | 31 : context_(context), |
32 helper_(helper), | 32 helper_(helper), |
33 vertex_attributes_buffer_(context_, context_->createBuffer()) { | 33 vertex_attributes_buffer_(context_, context_->createBuffer()) { |
34 InitBuffer(); | 34 InitBuffer(); |
35 } | 35 } |
36 | 36 |
37 GLHelperScaling::~GLHelperScaling() { | 37 GLHelperScaling::~GLHelperScaling() { |
38 } | 38 } |
39 | 39 |
40 // Used to keep track of a generated shader program. The program | 40 // Used to keep track of a generated shader program. The program |
41 // is passed in as text through Setup and is used by calling | 41 // is passed in as text through Setup and is used by calling |
42 // UseProgram() with the right parameters. Note that |context_| | 42 // UseProgram() with the right parameters. Note that |context_| |
43 // and |helper_| are assumed to live longer than this program. | 43 // and |helper_| are assumed to live longer than this program. |
44 class ShaderProgram : public base::RefCounted<ShaderProgram> { | 44 class ShaderProgram : public base::RefCounted<ShaderProgram> { |
45 public: | 45 public: |
46 ShaderProgram(WebGraphicsContext3D* context, | 46 ShaderProgram(WebGraphicsContext3D* context, |
47 GLHelper* helper) | 47 GLHelper* helper) |
48 : context_(context), | 48 : context_(context), |
49 helper_(helper), | 49 helper_(helper), |
50 program_(context, context->createProgram()) { | 50 program_(context, context->createProgram()) { |
51 } | 51 } |
52 | 52 |
53 // Compile shader program, return true if successful. | 53 // Compile shader program, return true if successful. |
54 bool Setup(const WebKit::WGC3Dchar* vertex_shader_text, | 54 bool Setup(const blink::WGC3Dchar* vertex_shader_text, |
55 const WebKit::WGC3Dchar* fragment_shader_text); | 55 const blink::WGC3Dchar* fragment_shader_text); |
56 | 56 |
57 // UseProgram must be called with GL_TEXTURE_2D bound to the | 57 // UseProgram must be called with GL_TEXTURE_2D bound to the |
58 // source texture and GL_ARRAY_BUFFER bound to a vertex | 58 // source texture and GL_ARRAY_BUFFER bound to a vertex |
59 // attribute buffer. | 59 // attribute buffer. |
60 void UseProgram(const gfx::Size& src_size, | 60 void UseProgram(const gfx::Size& src_size, |
61 const gfx::Rect& src_subrect, | 61 const gfx::Rect& src_subrect, |
62 const gfx::Size& dst_size, | 62 const gfx::Size& dst_size, |
63 bool scale_x, | 63 bool scale_x, |
64 bool flip_y, | 64 bool flip_y, |
65 GLfloat color_weights[4]); | 65 GLfloat color_weights[4]); |
66 | 66 |
67 private: | 67 private: |
68 friend class base::RefCounted<ShaderProgram>; | 68 friend class base::RefCounted<ShaderProgram>; |
69 ~ShaderProgram() {} | 69 ~ShaderProgram() {} |
70 | 70 |
71 WebGraphicsContext3D* context_; | 71 WebGraphicsContext3D* context_; |
72 GLHelper* helper_; | 72 GLHelper* helper_; |
73 | 73 |
74 // A program for copying a source texture into a destination texture. | 74 // A program for copying a source texture into a destination texture. |
75 ScopedProgram program_; | 75 ScopedProgram program_; |
76 | 76 |
77 // The location of the position in the program. | 77 // The location of the position in the program. |
78 WebKit::WGC3Dint position_location_; | 78 blink::WGC3Dint position_location_; |
79 // The location of the texture coordinate in the program. | 79 // The location of the texture coordinate in the program. |
80 WebKit::WGC3Dint texcoord_location_; | 80 blink::WGC3Dint texcoord_location_; |
81 // The location of the source texture in the program. | 81 // The location of the source texture in the program. |
82 WebKit::WGC3Dint texture_location_; | 82 blink::WGC3Dint texture_location_; |
83 // The location of the texture coordinate of | 83 // The location of the texture coordinate of |
84 // the sub-rectangle in the program. | 84 // the sub-rectangle in the program. |
85 WebKit::WGC3Dint src_subrect_location_; | 85 blink::WGC3Dint src_subrect_location_; |
86 // Location of size of source image in pixels. | 86 // Location of size of source image in pixels. |
87 WebKit::WGC3Dint src_pixelsize_location_; | 87 blink::WGC3Dint src_pixelsize_location_; |
88 // Location of size of destination image in pixels. | 88 // Location of size of destination image in pixels. |
89 WebKit::WGC3Dint dst_pixelsize_location_; | 89 blink::WGC3Dint dst_pixelsize_location_; |
90 // Location of vector for scaling direction. | 90 // Location of vector for scaling direction. |
91 WebKit::WGC3Dint scaling_vector_location_; | 91 blink::WGC3Dint scaling_vector_location_; |
92 // Location of color weights. | 92 // Location of color weights. |
93 WebKit::WGC3Dint color_weights_location_; | 93 blink::WGC3Dint color_weights_location_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(ShaderProgram); | 95 DISALLOW_COPY_AND_ASSIGN(ShaderProgram); |
96 }; | 96 }; |
97 | 97 |
98 | 98 |
99 // Implementation of a single stage in a scaler pipeline. If the pipeline has | 99 // Implementation of a single stage in a scaler pipeline. If the pipeline has |
100 // multiple stages, it calls Scale() on the subscaler, then further scales the | 100 // multiple stages, it calls Scale() on the subscaler, then further scales the |
101 // output. Caches textures and framebuffers to avoid allocating/deleting | 101 // output. Caches textures and framebuffers to avoid allocating/deleting |
102 // them once per frame, which can be expensive on some drivers. | 102 // them once per frame, which can be expensive on some drivers. |
103 class ScalerImpl : | 103 class ScalerImpl : |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 virtual ~ScalerImpl() { | 159 virtual ~ScalerImpl() { |
160 if (intermediate_texture_) { | 160 if (intermediate_texture_) { |
161 context_->deleteTexture(intermediate_texture_); | 161 context_->deleteTexture(intermediate_texture_); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 // GLHelperShader::ShaderInterface implementation. | 165 // GLHelperShader::ShaderInterface implementation. |
166 virtual void Execute( | 166 virtual void Execute( |
167 WebKit::WebGLId source_texture, | 167 blink::WebGLId source_texture, |
168 const std::vector<WebKit::WebGLId>& dest_textures) OVERRIDE { | 168 const std::vector<blink::WebGLId>& dest_textures) OVERRIDE { |
169 if (subscaler_) { | 169 if (subscaler_) { |
170 subscaler_->Scale(source_texture, intermediate_texture_); | 170 subscaler_->Scale(source_texture, intermediate_texture_); |
171 source_texture = intermediate_texture_; | 171 source_texture = intermediate_texture_; |
172 } | 172 } |
173 | 173 |
174 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( | 174 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
175 context_, | 175 context_, |
176 dst_framebuffer_); | 176 dst_framebuffer_); |
177 DCHECK_GT(dest_textures.size(), 0U); | 177 DCHECK_GT(dest_textures.size(), 0U); |
178 scoped_ptr<WebKit::WGC3Denum[]> buffers( | 178 scoped_ptr<blink::WGC3Denum[]> buffers( |
179 new WebKit::WGC3Denum[dest_textures.size()]); | 179 new blink::WGC3Denum[dest_textures.size()]); |
180 for (size_t t = 0; t < dest_textures.size(); t++) { | 180 for (size_t t = 0; t < dest_textures.size(); t++) { |
181 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, | 181 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, |
182 dest_textures[t]); | 182 dest_textures[t]); |
183 context_->framebufferTexture2D(GL_FRAMEBUFFER, | 183 context_->framebufferTexture2D(GL_FRAMEBUFFER, |
184 GL_COLOR_ATTACHMENT0 + t, | 184 GL_COLOR_ATTACHMENT0 + t, |
185 GL_TEXTURE_2D, | 185 GL_TEXTURE_2D, |
186 dest_textures[t], | 186 dest_textures[t], |
187 0); | 187 0); |
188 buffers[t] = GL_COLOR_ATTACHMENT0 + t; | 188 buffers[t] = GL_COLOR_ATTACHMENT0 + t; |
189 } | 189 } |
(...skipping 27 matching lines...) Expand all Loading... |
217 } | 217 } |
218 // Conduct texture mapping by drawing a quad composed of two triangles. | 218 // Conduct texture mapping by drawing a quad composed of two triangles. |
219 context_->drawArrays(GL_TRIANGLE_STRIP, 0, 4); | 219 context_->drawArrays(GL_TRIANGLE_STRIP, 0, 4); |
220 if (dest_textures.size() > 1) { | 220 if (dest_textures.size() > 1) { |
221 // Set the draw buffers back to not confuse others. | 221 // Set the draw buffers back to not confuse others. |
222 context_->drawBuffersEXT(1, &buffers[0]); | 222 context_->drawBuffersEXT(1, &buffers[0]); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 // GLHelper::ScalerInterface implementation. | 226 // GLHelper::ScalerInterface implementation. |
227 virtual void Scale(WebKit::WebGLId source_texture, | 227 virtual void Scale(blink::WebGLId source_texture, |
228 WebKit::WebGLId dest_texture) OVERRIDE { | 228 blink::WebGLId dest_texture) OVERRIDE { |
229 std::vector<WebKit::WebGLId> tmp(1); | 229 std::vector<blink::WebGLId> tmp(1); |
230 tmp[0] = dest_texture; | 230 tmp[0] = dest_texture; |
231 Execute(source_texture, tmp); | 231 Execute(source_texture, tmp); |
232 } | 232 } |
233 | 233 |
234 virtual const gfx::Size& SrcSize() OVERRIDE { | 234 virtual const gfx::Size& SrcSize() OVERRIDE { |
235 if (subscaler_) { | 235 if (subscaler_) { |
236 return subscaler_->SrcSize(); | 236 return subscaler_->SrcSize(); |
237 } | 237 } |
238 return spec_.src_size; | 238 return spec_.src_size; |
239 } | 239 } |
240 virtual const gfx::Rect& SrcSubrect() OVERRIDE { | 240 virtual const gfx::Rect& SrcSubrect() OVERRIDE { |
241 if (subscaler_) { | 241 if (subscaler_) { |
242 return subscaler_->SrcSubrect(); | 242 return subscaler_->SrcSubrect(); |
243 } | 243 } |
244 return spec_.src_subrect; | 244 return spec_.src_subrect; |
245 } | 245 } |
246 virtual const gfx::Size& DstSize() OVERRIDE { | 246 virtual const gfx::Size& DstSize() OVERRIDE { |
247 return spec_.dst_size; | 247 return spec_.dst_size; |
248 } | 248 } |
249 | 249 |
250 private: | 250 private: |
251 WebGraphicsContext3D* context_; | 251 WebGraphicsContext3D* context_; |
252 GLHelperScaling* scaler_helper_; | 252 GLHelperScaling* scaler_helper_; |
253 GLHelperScaling::ScalerStage spec_; | 253 GLHelperScaling::ScalerStage spec_; |
254 GLfloat color_weights_[4]; | 254 GLfloat color_weights_[4]; |
255 WebKit::WebGLId intermediate_texture_; | 255 blink::WebGLId intermediate_texture_; |
256 scoped_refptr<ShaderProgram> shader_program_; | 256 scoped_refptr<ShaderProgram> shader_program_; |
257 ScopedFramebuffer dst_framebuffer_; | 257 ScopedFramebuffer dst_framebuffer_; |
258 scoped_ptr<ScalerImpl> subscaler_; | 258 scoped_ptr<ScalerImpl> subscaler_; |
259 }; | 259 }; |
260 | 260 |
261 GLHelperScaling::ScalerStage::ScalerStage( | 261 GLHelperScaling::ScalerStage::ScalerStage( |
262 ShaderType shader_, | 262 ShaderType shader_, |
263 gfx::Size src_size_, | 263 gfx::Size src_size_, |
264 gfx::Rect src_subrect_, | 264 gfx::Rect src_subrect_, |
265 gfx::Size dst_size_, | 265 gfx::Size dst_size_, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 ScalerStage stage(shader, | 503 ScalerStage stage(shader, |
504 src_size, | 504 src_size, |
505 src_subrect, | 505 src_subrect, |
506 dst_size, | 506 dst_size, |
507 true, | 507 true, |
508 vertically_flip_texture, | 508 vertically_flip_texture, |
509 false); | 509 false); |
510 return new ScalerImpl(context_, this, stage, NULL, NULL); | 510 return new ScalerImpl(context_, this, stage, NULL, NULL); |
511 } | 511 } |
512 | 512 |
513 const WebKit::WGC3Dfloat GLHelperScaling::kVertexAttributes[] = { | 513 const blink::WGC3Dfloat GLHelperScaling::kVertexAttributes[] = { |
514 -1.0f, -1.0f, 0.0f, 0.0f, | 514 -1.0f, -1.0f, 0.0f, 0.0f, |
515 1.0f, -1.0f, 1.0f, 0.0f, | 515 1.0f, -1.0f, 1.0f, 0.0f, |
516 -1.0f, 1.0f, 0.0f, 1.0f, | 516 -1.0f, 1.0f, 0.0f, 1.0f, |
517 1.0f, 1.0f, 1.0f, 1.0f, | 517 1.0f, 1.0f, 1.0f, 1.0f, |
518 }; | 518 }; |
519 | 519 |
520 void GLHelperScaling::InitBuffer() { | 520 void GLHelperScaling::InitBuffer() { |
521 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder( | 521 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder( |
522 context_, vertex_attributes_buffer_); | 522 context_, vertex_attributes_buffer_); |
523 context_->bufferData(GL_ARRAY_BUFFER, | 523 context_->bufferData(GL_ARRAY_BUFFER, |
524 sizeof(kVertexAttributes), | 524 sizeof(kVertexAttributes), |
525 kVertexAttributes, | 525 kVertexAttributes, |
526 GL_STATIC_DRAW); | 526 GL_STATIC_DRAW); |
527 } | 527 } |
528 | 528 |
529 scoped_refptr<ShaderProgram> | 529 scoped_refptr<ShaderProgram> |
530 GLHelperScaling::GetShaderProgram(ShaderType type, | 530 GLHelperScaling::GetShaderProgram(ShaderType type, |
531 bool swizzle) { | 531 bool swizzle) { |
532 ShaderProgramKeyType key(type, swizzle); | 532 ShaderProgramKeyType key(type, swizzle); |
533 scoped_refptr<ShaderProgram>& cache_entry(shader_programs_[key]); | 533 scoped_refptr<ShaderProgram>& cache_entry(shader_programs_[key]); |
534 if (!cache_entry.get()) { | 534 if (!cache_entry.get()) { |
535 cache_entry = new ShaderProgram(context_, helper_); | 535 cache_entry = new ShaderProgram(context_, helper_); |
536 std::basic_string<WebKit::WGC3Dchar> vertex_program; | 536 std::basic_string<blink::WGC3Dchar> vertex_program; |
537 std::basic_string<WebKit::WGC3Dchar> fragment_program; | 537 std::basic_string<blink::WGC3Dchar> fragment_program; |
538 std::basic_string<WebKit::WGC3Dchar> vertex_header; | 538 std::basic_string<blink::WGC3Dchar> vertex_header; |
539 std::basic_string<WebKit::WGC3Dchar> fragment_directives; | 539 std::basic_string<blink::WGC3Dchar> fragment_directives; |
540 std::basic_string<WebKit::WGC3Dchar> fragment_header; | 540 std::basic_string<blink::WGC3Dchar> fragment_header; |
541 std::basic_string<WebKit::WGC3Dchar> shared_variables; | 541 std::basic_string<blink::WGC3Dchar> shared_variables; |
542 | 542 |
543 vertex_header.append( | 543 vertex_header.append( |
544 "precision highp float;\n" | 544 "precision highp float;\n" |
545 "attribute vec2 a_position;\n" | 545 "attribute vec2 a_position;\n" |
546 "attribute vec2 a_texcoord;\n" | 546 "attribute vec2 a_texcoord;\n" |
547 "uniform vec4 src_subrect;\n"); | 547 "uniform vec4 src_subrect;\n"); |
548 | 548 |
549 fragment_header.append( | 549 fragment_header.append( |
550 "precision mediump float;\n" | 550 "precision mediump float;\n" |
551 "uniform sampler2D s_texture;\n"); | 551 "uniform sampler2D s_texture;\n"); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 864 |
865 bool result = cache_entry->Setup(vertex_program.c_str(), | 865 bool result = cache_entry->Setup(vertex_program.c_str(), |
866 fragment_program.c_str()); | 866 fragment_program.c_str()); |
867 DCHECK(result || context_->isContextLost()) | 867 DCHECK(result || context_->isContextLost()) |
868 << "vertex_program =\n" << vertex_program | 868 << "vertex_program =\n" << vertex_program |
869 << "fragment_program =\n" << fragment_program; | 869 << "fragment_program =\n" << fragment_program; |
870 } | 870 } |
871 return cache_entry; | 871 return cache_entry; |
872 } | 872 } |
873 | 873 |
874 bool ShaderProgram::Setup(const WebKit::WGC3Dchar* vertex_shader_text, | 874 bool ShaderProgram::Setup(const blink::WGC3Dchar* vertex_shader_text, |
875 const WebKit::WGC3Dchar* fragment_shader_text) { | 875 const blink::WGC3Dchar* fragment_shader_text) { |
876 // Shaders to map the source texture to |dst_texture_|. | 876 // Shaders to map the source texture to |dst_texture_|. |
877 ScopedShader vertex_shader(context_, helper_->CompileShaderFromSource( | 877 ScopedShader vertex_shader(context_, helper_->CompileShaderFromSource( |
878 vertex_shader_text, GL_VERTEX_SHADER)); | 878 vertex_shader_text, GL_VERTEX_SHADER)); |
879 if (vertex_shader.id() == 0) { | 879 if (vertex_shader.id() == 0) { |
880 return false; | 880 return false; |
881 } | 881 } |
882 context_->attachShader(program_, vertex_shader); | 882 context_->attachShader(program_, vertex_shader); |
883 ScopedShader fragment_shader(context_, helper_->CompileShaderFromSource( | 883 ScopedShader fragment_shader(context_, helper_->CompileShaderFromSource( |
884 fragment_shader_text, GL_FRAGMENT_SHADER)); | 884 fragment_shader_text, GL_FRAGMENT_SHADER)); |
885 if (fragment_shader.id() == 0) { | 885 if (fragment_shader.id() == 0) { |
886 return false; | 886 return false; |
887 } | 887 } |
888 context_->attachShader(program_, fragment_shader); | 888 context_->attachShader(program_, fragment_shader); |
889 context_->linkProgram(program_); | 889 context_->linkProgram(program_); |
890 | 890 |
891 WebKit::WGC3Dint link_status = 0; | 891 blink::WGC3Dint link_status = 0; |
892 context_->getProgramiv(program_, GL_LINK_STATUS, &link_status); | 892 context_->getProgramiv(program_, GL_LINK_STATUS, &link_status); |
893 if (!link_status) { | 893 if (!link_status) { |
894 LOG(ERROR) << std::string(context_->getProgramInfoLog(program_).utf8()); | 894 LOG(ERROR) << std::string(context_->getProgramInfoLog(program_).utf8()); |
895 return false; | 895 return false; |
896 } | 896 } |
897 position_location_ = context_->getAttribLocation(program_, "a_position"); | 897 position_location_ = context_->getAttribLocation(program_, "a_position"); |
898 texcoord_location_ = context_->getAttribLocation(program_, "a_texcoord"); | 898 texcoord_location_ = context_->getAttribLocation(program_, "a_texcoord"); |
899 texture_location_ = context_->getUniformLocation(program_, "s_texture"); | 899 texture_location_ = context_->getUniformLocation(program_, "s_texture"); |
900 src_subrect_location_ = context_->getUniformLocation(program_, "src_subrect"); | 900 src_subrect_location_ = context_->getUniformLocation(program_, "src_subrect"); |
901 src_pixelsize_location_ = context_->getUniformLocation(program_, | 901 src_pixelsize_location_ = context_->getUniformLocation(program_, |
902 "src_pixelsize"); | 902 "src_pixelsize"); |
903 dst_pixelsize_location_ = context_->getUniformLocation(program_, | 903 dst_pixelsize_location_ = context_->getUniformLocation(program_, |
904 "dst_pixelsize"); | 904 "dst_pixelsize"); |
905 scaling_vector_location_ = context_->getUniformLocation(program_, | 905 scaling_vector_location_ = context_->getUniformLocation(program_, |
906 "scaling_vector"); | 906 "scaling_vector"); |
907 color_weights_location_ = context_->getUniformLocation(program_, | 907 color_weights_location_ = context_->getUniformLocation(program_, |
908 "color_weights"); | 908 "color_weights"); |
909 return true; | 909 return true; |
910 } | 910 } |
911 | 911 |
912 void ShaderProgram::UseProgram( | 912 void ShaderProgram::UseProgram( |
913 const gfx::Size& src_size, | 913 const gfx::Size& src_size, |
914 const gfx::Rect& src_subrect, | 914 const gfx::Rect& src_subrect, |
915 const gfx::Size& dst_size, | 915 const gfx::Size& dst_size, |
916 bool scale_x, | 916 bool scale_x, |
917 bool flip_y, | 917 bool flip_y, |
918 GLfloat color_weights[4]) { | 918 GLfloat color_weights[4]) { |
919 context_->useProgram(program_); | 919 context_->useProgram(program_); |
920 | 920 |
921 WebKit::WGC3Dintptr offset = 0; | 921 blink::WGC3Dintptr offset = 0; |
922 context_->vertexAttribPointer(position_location_, | 922 context_->vertexAttribPointer(position_location_, |
923 2, | 923 2, |
924 GL_FLOAT, | 924 GL_FLOAT, |
925 GL_FALSE, | 925 GL_FALSE, |
926 4 * sizeof(WebKit::WGC3Dfloat), | 926 4 * sizeof(blink::WGC3Dfloat), |
927 offset); | 927 offset); |
928 context_->enableVertexAttribArray(position_location_); | 928 context_->enableVertexAttribArray(position_location_); |
929 | 929 |
930 offset += 2 * sizeof(WebKit::WGC3Dfloat); | 930 offset += 2 * sizeof(blink::WGC3Dfloat); |
931 context_->vertexAttribPointer(texcoord_location_, | 931 context_->vertexAttribPointer(texcoord_location_, |
932 2, | 932 2, |
933 GL_FLOAT, | 933 GL_FLOAT, |
934 GL_FALSE, | 934 GL_FALSE, |
935 4 * sizeof(WebKit::WGC3Dfloat), | 935 4 * sizeof(blink::WGC3Dfloat), |
936 offset); | 936 offset); |
937 context_->enableVertexAttribArray(texcoord_location_); | 937 context_->enableVertexAttribArray(texcoord_location_); |
938 | 938 |
939 context_->uniform1i(texture_location_, 0); | 939 context_->uniform1i(texture_location_, 0); |
940 | 940 |
941 // Convert |src_subrect| to texture coordinates. | 941 // Convert |src_subrect| to texture coordinates. |
942 GLfloat src_subrect_texcoord[] = { | 942 GLfloat src_subrect_texcoord[] = { |
943 static_cast<float>(src_subrect.x()) / src_size.width(), | 943 static_cast<float>(src_subrect.x()) / src_size.width(), |
944 static_cast<float>(src_subrect.y()) / src_size.height(), | 944 static_cast<float>(src_subrect.y()) / src_size.height(), |
945 static_cast<float>(src_subrect.width()) / src_size.width(), | 945 static_cast<float>(src_subrect.width()) / src_size.width(), |
(...skipping 12 matching lines...) Expand all Loading... |
958 static_cast<float>(dst_size.width()), | 958 static_cast<float>(dst_size.width()), |
959 static_cast<float>(dst_size.height())); | 959 static_cast<float>(dst_size.height())); |
960 | 960 |
961 context_->uniform2f(scaling_vector_location_, | 961 context_->uniform2f(scaling_vector_location_, |
962 scale_x ? 1.0 : 0.0, | 962 scale_x ? 1.0 : 0.0, |
963 scale_x ? 0.0 : 1.0); | 963 scale_x ? 0.0 : 1.0); |
964 context_->uniform4fv(color_weights_location_, 1, color_weights); | 964 context_->uniform4fv(color_weights_location_, 1, color_weights); |
965 } | 965 } |
966 | 966 |
967 } // namespace content | 967 } // namespace content |
OLD | NEW |