Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 105553003: Use GLES2Interface in GLRenderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: applies to ToT Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "third_party/skia/include/core/SkSurface.h" 49 #include "third_party/skia/include/core/SkSurface.h"
50 #include "third_party/skia/include/gpu/GrContext.h" 50 #include "third_party/skia/include/gpu/GrContext.h"
51 #include "third_party/skia/include/gpu/GrTexture.h" 51 #include "third_party/skia/include/gpu/GrTexture.h"
52 #include "third_party/skia/include/gpu/SkGpuDevice.h" 52 #include "third_party/skia/include/gpu/SkGpuDevice.h"
53 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" 53 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h"
54 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 54 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
55 #include "ui/gfx/quad_f.h" 55 #include "ui/gfx/quad_f.h"
56 #include "ui/gfx/rect_conversions.h" 56 #include "ui/gfx/rect_conversions.h"
57 57
58 using blink::WebGraphicsContext3D; 58 using blink::WebGraphicsContext3D;
59 using gpu::gles2::GLES2Interface;
59 60
60 namespace cc { 61 namespace cc {
61 62
62 namespace { 63 namespace {
63 64
64 // TODO(epenner): This should probably be moved to output surface. 65 // TODO(epenner): This should probably be moved to output surface.
65 // 66 //
66 // This implements a simple fence based on client side swaps. 67 // This implements a simple fence based on client side swaps.
67 // This is to isolate the ResourceProvider from 'frames' which 68 // This is to isolate the ResourceProvider from 'frames' which
68 // it shouldn't need to care about, while still allowing us to 69 // it shouldn't need to care about, while still allowing us to
69 // enforce good texture recycling behavior strictly throughout 70 // enforce good texture recycling behavior strictly throughout
70 // the compositor (don't recycle a texture while it's in use). 71 // the compositor (don't recycle a texture while it's in use).
71 class SimpleSwapFence : public ResourceProvider::Fence { 72 class SimpleSwapFence : public ResourceProvider::Fence {
72 public: 73 public:
73 SimpleSwapFence() : has_passed_(false) {} 74 SimpleSwapFence() : has_passed_(false) {}
74 virtual bool HasPassed() OVERRIDE { return has_passed_; } 75 virtual bool HasPassed() OVERRIDE { return has_passed_; }
75 void SetHasPassed() { has_passed_ = true; } 76 void SetHasPassed() { has_passed_ = true; }
77
76 private: 78 private:
77 virtual ~SimpleSwapFence() {} 79 virtual ~SimpleSwapFence() {}
78 bool has_passed_; 80 bool has_passed_;
79 }; 81 };
80 82
81 bool NeedsIOSurfaceReadbackWorkaround() { 83 bool NeedsIOSurfaceReadbackWorkaround() {
82 #if defined(OS_MACOSX) 84 #if defined(OS_MACOSX)
83 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, 85 // This isn't strictly required in DumpRenderTree-mode when Mesa is used,
84 // but it doesn't seem to hurt. 86 // but it doesn't seem to hurt.
85 return true; 87 return true;
86 #else 88 #else
87 return false; 89 return false;
88 #endif 90 #endif
89 } 91 }
90 92
91 Float4 UVTransform(const TextureDrawQuad* quad) { 93 Float4 UVTransform(const TextureDrawQuad* quad) {
92 gfx::PointF uv0 = quad->uv_top_left; 94 gfx::PointF uv0 = quad->uv_top_left;
93 gfx::PointF uv1 = quad->uv_bottom_right; 95 gfx::PointF uv1 = quad->uv_bottom_right;
94 Float4 xform = { { uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y() } }; 96 Float4 xform = {{uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}};
95 if (quad->flipped) { 97 if (quad->flipped) {
96 xform.data[1] = 1.0f - xform.data[1]; 98 xform.data[1] = 1.0f - xform.data[1];
97 xform.data[3] = -xform.data[3]; 99 xform.data[3] = -xform.data[3];
98 } 100 }
99 return xform; 101 return xform;
100 } 102 }
101 103
102 Float4 PremultipliedColor(SkColor color) { 104 Float4 PremultipliedColor(SkColor color) {
103 const float factor = 1.0f / 255.0f; 105 const float factor = 1.0f / 255.0f;
104 const float alpha = SkColorGetA(color) * factor; 106 const float alpha = SkColorGetA(color) * factor;
105 107
106 Float4 result = { { 108 Float4 result = {
107 SkColorGetR(color) * factor * alpha, 109 {SkColorGetR(color) * factor * alpha, SkColorGetG(color) * factor * alpha,
108 SkColorGetG(color) * factor * alpha, 110 SkColorGetB(color) * factor * alpha, alpha}};
109 SkColorGetB(color) * factor * alpha,
110 alpha
111 } };
112 return result; 111 return result;
113 } 112 }
114 113
115 SamplerType SamplerTypeFromTextureTarget(GLenum target) { 114 SamplerType SamplerTypeFromTextureTarget(GLenum target) {
116 switch (target) { 115 switch (target) {
117 case GL_TEXTURE_2D: 116 case GL_TEXTURE_2D:
118 return SamplerType2D; 117 return SamplerType2D;
119 case GL_TEXTURE_RECTANGLE_ARB: 118 case GL_TEXTURE_RECTANGLE_ARB:
120 return SamplerType2DRect; 119 return SamplerType2DRect;
121 case GL_TEXTURE_EXTERNAL_OES: 120 case GL_TEXTURE_EXTERNAL_OES:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 blend_shadow_(false), 180 blend_shadow_(false),
182 highp_threshold_min_(highp_threshold_min), 181 highp_threshold_min_(highp_threshold_min),
183 highp_threshold_cache_(0), 182 highp_threshold_cache_(0),
184 on_demand_tile_raster_resource_id_(0) { 183 on_demand_tile_raster_resource_id_(0) {
185 DCHECK(context_); 184 DCHECK(context_);
186 DCHECK(context_support_); 185 DCHECK(context_support_);
187 } 186 }
188 187
189 void GLRenderer::Initialize() { 188 void GLRenderer::Initialize() {
190 ContextProvider::Capabilities context_caps = 189 ContextProvider::Capabilities context_caps =
191 output_surface_->context_provider()->ContextCapabilities(); 190 output_surface_->context_provider()->ContextCapabilities();
192 191
193 capabilities_.using_partial_swap = 192 capabilities_.using_partial_swap =
194 settings_->partial_swap_enabled && context_caps.post_sub_buffer; 193 settings_->partial_swap_enabled && context_caps.post_sub_buffer;
195 194
196 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); 195 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle);
197 196
198 capabilities_.using_egl_image = context_caps.egl_image_external; 197 capabilities_.using_egl_image = context_caps.egl_image_external;
199 198
200 capabilities_.max_texture_size = resource_provider_->max_texture_size(); 199 capabilities_.max_texture_size = resource_provider_->max_texture_size();
201 capabilities_.best_texture_format = resource_provider_->best_texture_format(); 200 capabilities_.best_texture_format = resource_provider_->best_texture_format();
202 201
203 // The updater can access textures while the GLRenderer is using them. 202 // The updater can access textures while the GLRenderer is using them.
204 capabilities_.allow_partial_texture_updates = true; 203 capabilities_.allow_partial_texture_updates = true;
205 204
206 // Check for texture fast paths. Currently we always use MO8 textures, 205 // Check for texture fast paths. Currently we always use MO8 textures,
207 // so we only need to avoid POT textures if we have an NPOT fast-path. 206 // so we only need to avoid POT textures if we have an NPOT fast-path.
208 capabilities_.avoid_pow2_textures = context_caps.fast_npot_mo8_textures; 207 capabilities_.avoid_pow2_textures = context_caps.fast_npot_mo8_textures;
209 208
210 capabilities_.using_offscreen_context3d = true; 209 capabilities_.using_offscreen_context3d = true;
211 210
212 capabilities_.using_map_image = 211 capabilities_.using_map_image =
213 settings_->use_map_image && context_caps.map_image; 212 settings_->use_map_image && context_caps.map_image;
214 213
215 capabilities_.using_discard_framebuffer = 214 capabilities_.using_discard_framebuffer = context_caps.discard_framebuffer;
216 context_caps.discard_framebuffer;
217 215
218 InitializeSharedObjects(); 216 InitializeSharedObjects();
219 217
220 // Make sure the viewport and context gets initialized, even if it is to zero. 218 // Make sure the viewport and context gets initialized, even if it is to zero.
221 ViewportChanged(); 219 ViewportChanged();
222 } 220 }
223 221
224 GLRenderer::~GLRenderer() { 222 GLRenderer::~GLRenderer() {
225 while (!pending_async_read_pixels_.empty()) { 223 while (!pending_async_read_pixels_.empty()) {
226 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back(); 224 PendingAsyncReadPixels* pending_read = pending_async_read_pixels_.back();
227 pending_read->finished_read_pixels_callback.Cancel(); 225 pending_read->finished_read_pixels_callback.Cancel();
228 pending_async_read_pixels_.pop_back(); 226 pending_async_read_pixels_.pop_back();
229 } 227 }
230 228
231 CleanupSharedObjects(); 229 CleanupSharedObjects();
232 } 230 }
233 231
234 const RendererCapabilities& GLRenderer::Capabilities() const { 232 const RendererCapabilities& GLRenderer::Capabilities() const {
235 return capabilities_; 233 return capabilities_;
236 } 234 }
237 235
238 WebGraphicsContext3D* GLRenderer::Context() { return context_; } 236 WebGraphicsContext3D* GLRenderer::Context() { return context_; }
239 237
240 void GLRenderer::DebugGLCall(WebGraphicsContext3D* context, 238 void GLRenderer::DebugGLCall(GLES2Interface* gl,
241 const char* command, 239 const char* command,
242 const char* file, 240 const char* file,
243 int line) { 241 int line) {
244 unsigned error = context->getError(); 242 GLuint error = gl->GetError();
245 if (error != GL_NO_ERROR) 243 if (error != GL_NO_ERROR)
246 LOG(ERROR) << "GL command failed: File: " << file << "\n\tLine " << line 244 LOG(ERROR) << "GL command failed: File: " << file << "\n\tLine " << line
247 << "\n\tcommand: " << command << ", error " 245 << "\n\tcommand: " << command << ", error "
248 << static_cast<int>(error) << "\n"; 246 << static_cast<int>(error) << "\n";
249 } 247 }
250 248
251 void GLRenderer::SetVisible(bool visible) { 249 void GLRenderer::SetVisible(bool visible) {
252 if (visible_ == visible) 250 if (visible_ == visible)
253 return; 251 return;
254 visible_ = visible; 252 visible_ = visible;
(...skipping 19 matching lines...) Expand all
274 void GLRenderer::DiscardPixels(bool has_external_stencil_test, 272 void GLRenderer::DiscardPixels(bool has_external_stencil_test,
275 bool draw_rect_covers_full_surface) { 273 bool draw_rect_covers_full_surface) {
276 if (has_external_stencil_test || !draw_rect_covers_full_surface || 274 if (has_external_stencil_test || !draw_rect_covers_full_surface ||
277 !capabilities_.using_discard_framebuffer) 275 !capabilities_.using_discard_framebuffer)
278 return; 276 return;
279 bool using_default_framebuffer = 277 bool using_default_framebuffer =
280 !current_framebuffer_lock_ && 278 !current_framebuffer_lock_ &&
281 output_surface_->capabilities().uses_default_gl_framebuffer; 279 output_surface_->capabilities().uses_default_gl_framebuffer;
282 GLenum attachments[] = {static_cast<GLenum>( 280 GLenum attachments[] = {static_cast<GLenum>(
283 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; 281 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)};
284 context_->discardFramebufferEXT( 282 gl_->DiscardFramebufferEXT(
285 GL_FRAMEBUFFER, arraysize(attachments), attachments); 283 GL_FRAMEBUFFER, arraysize(attachments), attachments);
286 } 284 }
287 285
288 void GLRenderer::ClearFramebuffer(DrawingFrame* frame, 286 void GLRenderer::ClearFramebuffer(DrawingFrame* frame,
289 bool has_external_stencil_test) { 287 bool has_external_stencil_test) {
290 // It's unsafe to clear when we have a stencil test because glClear ignores 288 // It's unsafe to clear when we have a stencil test because glClear ignores
291 // stencil. 289 // stencil.
292 if (has_external_stencil_test) { 290 if (has_external_stencil_test) {
293 DCHECK(!frame->current_render_pass->has_transparent_background); 291 DCHECK(!frame->current_render_pass->has_transparent_background);
294 return; 292 return;
295 } 293 }
296 294
297 // On DEBUG builds, opaque render passes are cleared to blue to easily see 295 // On DEBUG builds, opaque render passes are cleared to blue to easily see
298 // regions that were not drawn on the screen. 296 // regions that were not drawn on the screen.
299 if (frame->current_render_pass->has_transparent_background) 297 if (frame->current_render_pass->has_transparent_background)
300 GLC(context_, context_->clearColor(0, 0, 0, 0)); 298 GLC(gl_, gl_->ClearColor(0, 0, 0, 0));
301 else 299 else
302 GLC(context_, context_->clearColor(0, 0, 1, 1)); 300 GLC(gl_, gl_->ClearColor(0, 0, 1, 1));
303 301
304 bool always_clear = false; 302 bool always_clear = false;
305 #ifndef NDEBUG 303 #ifndef NDEBUG
306 always_clear = true; 304 always_clear = true;
307 #endif 305 #endif
308 if (always_clear || frame->current_render_pass->has_transparent_background) { 306 if (always_clear || frame->current_render_pass->has_transparent_background) {
309 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; 307 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT;
310 if (always_clear) 308 if (always_clear)
311 clear_bits |= GL_STENCIL_BUFFER_BIT; 309 clear_bits |= GL_STENCIL_BUFFER_BIT;
312 context_->clear(clear_bits); 310 gl_->Clear(clear_bits);
313 } 311 }
314 } 312 }
315 313
316 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { 314 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) {
317 if (client_->DeviceViewport().IsEmpty()) 315 if (client_->DeviceViewport().IsEmpty())
318 return; 316 return;
319 317
320 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); 318 TRACE_EVENT0("cc", "GLRenderer::DrawLayers");
321 319
322 ReinitializeGLState(); 320 ReinitializeGLState();
323 } 321 }
324 322
325 void GLRenderer::DoNoOp() { 323 void GLRenderer::DoNoOp() {
326 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); 324 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
327 GLC(context_, context_->flush()); 325 GLC(gl_, gl_->Flush());
328 } 326 }
329 327
330 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { 328 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) {
331 DCHECK(quad->rect.Contains(quad->visible_rect)); 329 DCHECK(quad->rect.Contains(quad->visible_rect));
332 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 330 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
333 FlushTextureQuadCache(); 331 FlushTextureQuadCache();
334 } 332 }
335 333
336 switch (quad->material) { 334 switch (quad->material) {
337 case DrawQuad::INVALID: 335 case DrawQuad::INVALID:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 370
373 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame, 371 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
374 const CheckerboardDrawQuad* quad) { 372 const CheckerboardDrawQuad* quad) {
375 SetBlendEnabled(quad->ShouldDrawWithBlending()); 373 SetBlendEnabled(quad->ShouldDrawWithBlending());
376 374
377 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); 375 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
378 DCHECK(program && (program->initialized() || IsContextLost())); 376 DCHECK(program && (program->initialized() || IsContextLost()));
379 SetUseProgram(program->program()); 377 SetUseProgram(program->program());
380 378
381 SkColor color = quad->color; 379 SkColor color = quad->color;
382 GLC(Context(), 380 GLC(gl_,
383 Context()->uniform4f(program->fragment_shader().color_location(), 381 gl_->Uniform4f(program->fragment_shader().color_location(),
384 SkColorGetR(color) * (1.0f / 255.0f), 382 SkColorGetR(color) * (1.0f / 255.0f),
385 SkColorGetG(color) * (1.0f / 255.0f), 383 SkColorGetG(color) * (1.0f / 255.0f),
386 SkColorGetB(color) * (1.0f / 255.0f), 384 SkColorGetB(color) * (1.0f / 255.0f),
387 1)); 385 1));
388 386
389 const int checkerboard_width = 16; 387 const int checkerboard_width = 16;
390 float frequency = 1.0f / checkerboard_width; 388 float frequency = 1.0f / checkerboard_width;
391 389
392 gfx::Rect tile_rect = quad->rect; 390 gfx::Rect tile_rect = quad->rect;
393 float tex_offset_x = tile_rect.x() % checkerboard_width; 391 float tex_offset_x = tile_rect.x() % checkerboard_width;
394 float tex_offset_y = tile_rect.y() % checkerboard_width; 392 float tex_offset_y = tile_rect.y() % checkerboard_width;
395 float tex_scale_x = tile_rect.width(); 393 float tex_scale_x = tile_rect.width();
396 float tex_scale_y = tile_rect.height(); 394 float tex_scale_y = tile_rect.height();
397 GLC(Context(), 395 GLC(gl_,
398 Context()->uniform4f(program->fragment_shader().tex_transform_location(), 396 gl_->Uniform4f(program->fragment_shader().tex_transform_location(),
399 tex_offset_x, 397 tex_offset_x,
400 tex_offset_y, 398 tex_offset_y,
401 tex_scale_x, 399 tex_scale_x,
402 tex_scale_y)); 400 tex_scale_y));
403 401
404 GLC(Context(), 402 GLC(gl_,
405 Context()->uniform1f(program->fragment_shader().frequency_location(), 403 gl_->Uniform1f(program->fragment_shader().frequency_location(),
406 frequency)); 404 frequency));
407 405
408 SetShaderOpacity(quad->opacity(), 406 SetShaderOpacity(quad->opacity(),
409 program->fragment_shader().alpha_location()); 407 program->fragment_shader().alpha_location());
410 DrawQuadGeometry(frame, 408 DrawQuadGeometry(frame,
411 quad->quadTransform(), 409 quad->quadTransform(),
412 quad->rect, 410 quad->rect,
413 program->vertex_shader().matrix_location()); 411 program->vertex_shader().matrix_location());
414 } 412 }
415 413
416 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 414 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
417 const DebugBorderDrawQuad* quad) { 415 const DebugBorderDrawQuad* quad) {
418 SetBlendEnabled(quad->ShouldDrawWithBlending()); 416 SetBlendEnabled(quad->ShouldDrawWithBlending());
419 417
420 static float gl_matrix[16]; 418 static float gl_matrix[16];
421 const DebugBorderProgram* program = GetDebugBorderProgram(); 419 const DebugBorderProgram* program = GetDebugBorderProgram();
422 DCHECK(program && (program->initialized() || IsContextLost())); 420 DCHECK(program && (program->initialized() || IsContextLost()));
423 SetUseProgram(program->program()); 421 SetUseProgram(program->program());
424 422
425 // Use the full quad_rect for debug quads to not move the edges based on 423 // Use the full quad_rect for debug quads to not move the edges based on
426 // partial swaps. 424 // partial swaps.
427 gfx::Rect layer_rect = quad->rect; 425 gfx::Rect layer_rect = quad->rect;
428 gfx::Transform render_matrix = quad->quadTransform(); 426 gfx::Transform render_matrix = quad->quadTransform();
429 render_matrix.Translate(0.5f * layer_rect.width() + layer_rect.x(), 427 render_matrix.Translate(0.5f * layer_rect.width() + layer_rect.x(),
430 0.5f * layer_rect.height() + layer_rect.y()); 428 0.5f * layer_rect.height() + layer_rect.y());
431 render_matrix.Scale(layer_rect.width(), layer_rect.height()); 429 render_matrix.Scale(layer_rect.width(), layer_rect.height());
432 GLRenderer::ToGLMatrix(&gl_matrix[0], 430 GLRenderer::ToGLMatrix(&gl_matrix[0],
433 frame->projection_matrix * render_matrix); 431 frame->projection_matrix * render_matrix);
434 GLC(Context(), 432 GLC(gl_,
435 Context()->uniformMatrix4fv( 433 gl_->UniformMatrix4fv(
436 program->vertex_shader().matrix_location(), 1, false, &gl_matrix[0])); 434 program->vertex_shader().matrix_location(), 1, false, &gl_matrix[0]));
437 435
438 SkColor color = quad->color; 436 SkColor color = quad->color;
439 float alpha = SkColorGetA(color) * (1.0f / 255.0f); 437 float alpha = SkColorGetA(color) * (1.0f / 255.0f);
440 438
441 GLC(Context(), 439 GLC(gl_,
442 Context()->uniform4f(program->fragment_shader().color_location(), 440 gl_->Uniform4f(program->fragment_shader().color_location(),
443 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 441 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
444 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 442 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
445 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, 443 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
446 alpha)); 444 alpha));
447 445
448 GLC(Context(), Context()->lineWidth(quad->width)); 446 GLC(gl_, gl_->LineWidth(quad->width));
449 447
450 // The indices for the line are stored in the same array as the triangle 448 // The indices for the line are stored in the same array as the triangle
451 // indices. 449 // indices.
452 GLC(Context(), 450 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
453 Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
454 } 451 }
455 452
456 static SkBitmap ApplyImageFilter(GLRenderer* renderer, 453 static SkBitmap ApplyImageFilter(GLRenderer* renderer,
457 ContextProvider* offscreen_contexts, 454 ContextProvider* offscreen_contexts,
458 gfx::Point origin, 455 gfx::Point origin,
459 SkImageFilter* filter, 456 SkImageFilter* filter,
460 ScopedResource* source_texture_resource) { 457 ScopedResource* source_texture_resource) {
461 if (!filter) 458 if (!filter)
462 return SkBitmap(); 459 return SkBitmap();
463 460
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // storage allocation (texStorage2DEXT) for this texture. copyTexImage2D fails 705 // storage allocation (texStorage2DEXT) for this texture. copyTexImage2D fails
709 // when called on a texture having immutable storage. 706 // when called on a texture having immutable storage.
710 if (!device_background_texture->Allocate( 707 if (!device_background_texture->Allocate(
711 window_rect.size(), 708 window_rect.size(),
712 ResourceProvider::TextureUsageFramebuffer, 709 ResourceProvider::TextureUsageFramebuffer,
713 RGBA_8888)) { 710 RGBA_8888)) {
714 return scoped_ptr<ScopedResource>(); 711 return scoped_ptr<ScopedResource>();
715 } else { 712 } else {
716 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 713 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
717 device_background_texture->id()); 714 device_background_texture->id());
718 GetFramebufferTexture(lock.texture_id(), 715 GetFramebufferTexture(
719 device_background_texture->format(), 716 lock.texture_id(), device_background_texture->format(), window_rect);
720 window_rect);
721 } 717 }
722 718
723 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 719 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
724 quad->background_filters, device_background_texture->size()); 720 quad->background_filters, device_background_texture->size());
725 721
726 SkBitmap filtered_device_background; 722 SkBitmap filtered_device_background;
727 if (apply_background_filters) { 723 if (apply_background_filters) {
728 filtered_device_background = 724 filtered_device_background =
729 ApplyImageFilter(this, 725 ApplyImageFilter(this,
730 frame->offscreen_context_provider, 726 frame->offscreen_context_provider,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 gfx::Transform device_to_framebuffer_transform; 759 gfx::Transform device_to_framebuffer_transform;
764 device_to_framebuffer_transform.Translate( 760 device_to_framebuffer_transform.Translate(
765 quad->rect.width() * 0.5f + quad->rect.x(), 761 quad->rect.width() * 0.5f + quad->rect.x(),
766 quad->rect.height() * 0.5f + quad->rect.y()); 762 quad->rect.height() * 0.5f + quad->rect.y());
767 device_to_framebuffer_transform.Scale(quad->rect.width(), 763 device_to_framebuffer_transform.Scale(quad->rect.width(),
768 quad->rect.height()); 764 quad->rect.height());
769 device_to_framebuffer_transform.PreconcatTransform( 765 device_to_framebuffer_transform.PreconcatTransform(
770 contents_device_transform_inverse); 766 contents_device_transform_inverse);
771 767
772 #ifndef NDEBUG 768 #ifndef NDEBUG
773 GLC(Context(), Context()->clearColor(0, 0, 1, 1)); 769 GLC(gl_, gl_->ClearColor(0, 0, 1, 1));
774 Context()->clear(GL_COLOR_BUFFER_BIT); 770 gl_->Clear(GL_COLOR_BUFFER_BIT);
775 #endif 771 #endif
776 772
777 // The filtered_deveice_background_texture is oriented the same as the frame 773 // The filtered_deveice_background_texture is oriented the same as the frame
778 // buffer. The transform we are copying with has a vertical flip, as well as 774 // buffer. The transform we are copying with has a vertical flip, as well as
779 // the |device_to_framebuffer_transform|, which cancel each other out. So do 775 // the |device_to_framebuffer_transform|, which cancel each other out. So do
780 // not flip the contents in the shader to maintain orientation. 776 // not flip the contents in the shader to maintain orientation.
781 bool flip_vertically = false; 777 bool flip_vertically = false;
782 778
783 CopyTextureToFramebuffer(frame, 779 CopyTextureToFramebuffer(frame,
784 filtered_device_background_texture_id, 780 filtered_device_background_texture_id,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 flip_vertically); 896 flip_vertically);
901 } 897 }
902 898
903 bool clipped = false; 899 bool clipped = false;
904 gfx::QuadF device_quad = MathUtil::MapQuad( 900 gfx::QuadF device_quad = MathUtil::MapQuad(
905 contents_device_transform, SharedGeometryQuad(), &clipped); 901 contents_device_transform, SharedGeometryQuad(), &clipped);
906 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox())); 902 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox()));
907 LayerQuad device_layer_edges(device_quad); 903 LayerQuad device_layer_edges(device_quad);
908 904
909 // Use anti-aliasing programs only when necessary. 905 // Use anti-aliasing programs only when necessary.
910 bool use_aa = !clipped && 906 bool use_aa =
911 (!device_quad.IsRectilinear() || 907 !clipped && (!device_quad.IsRectilinear() ||
912 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(), 908 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
913 kAntiAliasingEpsilon)); 909 kAntiAliasingEpsilon));
914 if (use_aa) { 910 if (use_aa) {
915 device_layer_bounds.InflateAntiAliasingDistance(); 911 device_layer_bounds.InflateAntiAliasingDistance();
916 device_layer_edges.InflateAntiAliasingDistance(); 912 device_layer_edges.InflateAntiAliasingDistance();
917 } 913 }
918 914
919 scoped_ptr<ResourceProvider::ScopedReadLockGL> mask_resource_lock; 915 scoped_ptr<ResourceProvider::ScopedReadLockGL> mask_resource_lock;
920 unsigned mask_texture_id = 0; 916 unsigned mask_texture_id = 0;
921 if (quad->mask_resource_id) { 917 if (quad->mask_resource_id) {
922 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( 918 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL(
923 resource_provider_, quad->mask_resource_id)); 919 resource_provider_, quad->mask_resource_id));
924 mask_texture_id = mask_resource_lock->texture_id(); 920 mask_texture_id = mask_resource_lock->texture_id();
925 } 921 }
926 922
927 // TODO(danakj): use the background_texture and blend the background in with 923 // TODO(danakj): use the background_texture and blend the background in with
928 // this draw instead of having a separate copy of the background texture. 924 // this draw instead of having a separate copy of the background texture.
929 925
930 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; 926 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock;
931 if (filter_bitmap.getTexture()) { 927 if (filter_bitmap.getTexture()) {
932 GrTexture* texture = 928 GrTexture* texture =
933 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); 929 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture());
934 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 930 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
935 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); 931 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
936 } else { 932 } else {
937 contents_resource_lock = make_scoped_ptr( 933 contents_resource_lock =
938 new ResourceProvider::ScopedSamplerGL(resource_provider_, 934 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL(
939 contents_texture->id(), 935 resource_provider_, contents_texture->id(), GL_LINEAR));
940 GL_LINEAR));
941 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 936 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
942 contents_resource_lock->target()); 937 contents_resource_lock->target());
943 } 938 }
944 939
945 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 940 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
946 gl_, &highp_threshold_cache_, highp_threshold_min_, 941 gl_,
942 &highp_threshold_cache_,
943 highp_threshold_min_,
947 quad->shared_quad_state->visible_content_rect.bottom_right()); 944 quad->shared_quad_state->visible_content_rect.bottom_right());
948 945
949 int shader_quad_location = -1; 946 int shader_quad_location = -1;
950 int shader_edge_location = -1; 947 int shader_edge_location = -1;
951 int shader_viewport_location = -1; 948 int shader_viewport_location = -1;
952 int shader_mask_sampler_location = -1; 949 int shader_mask_sampler_location = -1;
953 int shader_mask_tex_coord_scale_location = -1; 950 int shader_mask_tex_coord_scale_location = -1;
954 int shader_mask_tex_coord_offset_location = -1; 951 int shader_mask_tex_coord_offset_location = -1;
955 int shader_matrix_location = -1; 952 int shader_matrix_location = -1;
956 int shader_alpha_location = -1; 953 int shader_alpha_location = -1;
957 int shader_color_matrix_location = -1; 954 int shader_color_matrix_location = -1;
958 int shader_color_offset_location = -1; 955 int shader_color_offset_location = -1;
959 int shader_tex_transform_location = -1; 956 int shader_tex_transform_location = -1;
960 957
961 if (use_aa && mask_texture_id && !use_color_matrix) { 958 if (use_aa && mask_texture_id && !use_color_matrix) {
962 const RenderPassMaskProgramAA* program = 959 const RenderPassMaskProgramAA* program =
963 GetRenderPassMaskProgramAA(tex_coord_precision); 960 GetRenderPassMaskProgramAA(tex_coord_precision);
964 SetUseProgram(program->program()); 961 SetUseProgram(program->program());
965 GLC(Context(), 962 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
966 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
967 963
968 shader_quad_location = program->vertex_shader().quad_location(); 964 shader_quad_location = program->vertex_shader().quad_location();
969 shader_edge_location = program->vertex_shader().edge_location(); 965 shader_edge_location = program->vertex_shader().edge_location();
970 shader_viewport_location = program->vertex_shader().viewport_location(); 966 shader_viewport_location = program->vertex_shader().viewport_location();
971 shader_mask_sampler_location = 967 shader_mask_sampler_location =
972 program->fragment_shader().mask_sampler_location(); 968 program->fragment_shader().mask_sampler_location();
973 shader_mask_tex_coord_scale_location = 969 shader_mask_tex_coord_scale_location =
974 program->fragment_shader().mask_tex_coord_scale_location(); 970 program->fragment_shader().mask_tex_coord_scale_location();
975 shader_mask_tex_coord_offset_location = 971 shader_mask_tex_coord_offset_location =
976 program->fragment_shader().mask_tex_coord_offset_location(); 972 program->fragment_shader().mask_tex_coord_offset_location();
977 shader_matrix_location = program->vertex_shader().matrix_location(); 973 shader_matrix_location = program->vertex_shader().matrix_location();
978 shader_alpha_location = program->fragment_shader().alpha_location(); 974 shader_alpha_location = program->fragment_shader().alpha_location();
979 shader_tex_transform_location = 975 shader_tex_transform_location =
980 program->vertex_shader().tex_transform_location(); 976 program->vertex_shader().tex_transform_location();
981 } else if (!use_aa && mask_texture_id && !use_color_matrix) { 977 } else if (!use_aa && mask_texture_id && !use_color_matrix) {
982 const RenderPassMaskProgram* program = 978 const RenderPassMaskProgram* program =
983 GetRenderPassMaskProgram(tex_coord_precision); 979 GetRenderPassMaskProgram(tex_coord_precision);
984 SetUseProgram(program->program()); 980 SetUseProgram(program->program());
985 GLC(Context(), 981 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
986 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
987 982
988 shader_mask_sampler_location = 983 shader_mask_sampler_location =
989 program->fragment_shader().mask_sampler_location(); 984 program->fragment_shader().mask_sampler_location();
990 shader_mask_tex_coord_scale_location = 985 shader_mask_tex_coord_scale_location =
991 program->fragment_shader().mask_tex_coord_scale_location(); 986 program->fragment_shader().mask_tex_coord_scale_location();
992 shader_mask_tex_coord_offset_location = 987 shader_mask_tex_coord_offset_location =
993 program->fragment_shader().mask_tex_coord_offset_location(); 988 program->fragment_shader().mask_tex_coord_offset_location();
994 shader_matrix_location = program->vertex_shader().matrix_location(); 989 shader_matrix_location = program->vertex_shader().matrix_location();
995 shader_alpha_location = program->fragment_shader().alpha_location(); 990 shader_alpha_location = program->fragment_shader().alpha_location();
996 shader_tex_transform_location = 991 shader_tex_transform_location =
997 program->vertex_shader().tex_transform_location(); 992 program->vertex_shader().tex_transform_location();
998 } else if (use_aa && !mask_texture_id && !use_color_matrix) { 993 } else if (use_aa && !mask_texture_id && !use_color_matrix) {
999 const RenderPassProgramAA* program = 994 const RenderPassProgramAA* program =
1000 GetRenderPassProgramAA(tex_coord_precision); 995 GetRenderPassProgramAA(tex_coord_precision);
1001 SetUseProgram(program->program()); 996 SetUseProgram(program->program());
1002 GLC(Context(), 997 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1003 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1004 998
1005 shader_quad_location = program->vertex_shader().quad_location(); 999 shader_quad_location = program->vertex_shader().quad_location();
1006 shader_edge_location = program->vertex_shader().edge_location(); 1000 shader_edge_location = program->vertex_shader().edge_location();
1007 shader_viewport_location = program->vertex_shader().viewport_location(); 1001 shader_viewport_location = program->vertex_shader().viewport_location();
1008 shader_matrix_location = program->vertex_shader().matrix_location(); 1002 shader_matrix_location = program->vertex_shader().matrix_location();
1009 shader_alpha_location = program->fragment_shader().alpha_location(); 1003 shader_alpha_location = program->fragment_shader().alpha_location();
1010 shader_tex_transform_location = 1004 shader_tex_transform_location =
1011 program->vertex_shader().tex_transform_location(); 1005 program->vertex_shader().tex_transform_location();
1012 } else if (use_aa && mask_texture_id && use_color_matrix) { 1006 } else if (use_aa && mask_texture_id && use_color_matrix) {
1013 const RenderPassMaskColorMatrixProgramAA* program = 1007 const RenderPassMaskColorMatrixProgramAA* program =
1014 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision); 1008 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision);
1015 SetUseProgram(program->program()); 1009 SetUseProgram(program->program());
1016 GLC(Context(), 1010 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1017 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1018 1011
1019 shader_matrix_location = program->vertex_shader().matrix_location(); 1012 shader_matrix_location = program->vertex_shader().matrix_location();
1020 shader_quad_location = program->vertex_shader().quad_location(); 1013 shader_quad_location = program->vertex_shader().quad_location();
1021 shader_tex_transform_location = 1014 shader_tex_transform_location =
1022 program->vertex_shader().tex_transform_location(); 1015 program->vertex_shader().tex_transform_location();
1023 shader_edge_location = program->vertex_shader().edge_location(); 1016 shader_edge_location = program->vertex_shader().edge_location();
1024 shader_viewport_location = program->vertex_shader().viewport_location(); 1017 shader_viewport_location = program->vertex_shader().viewport_location();
1025 shader_alpha_location = program->fragment_shader().alpha_location(); 1018 shader_alpha_location = program->fragment_shader().alpha_location();
1026 shader_mask_sampler_location = 1019 shader_mask_sampler_location =
1027 program->fragment_shader().mask_sampler_location(); 1020 program->fragment_shader().mask_sampler_location();
1028 shader_mask_tex_coord_scale_location = 1021 shader_mask_tex_coord_scale_location =
1029 program->fragment_shader().mask_tex_coord_scale_location(); 1022 program->fragment_shader().mask_tex_coord_scale_location();
1030 shader_mask_tex_coord_offset_location = 1023 shader_mask_tex_coord_offset_location =
1031 program->fragment_shader().mask_tex_coord_offset_location(); 1024 program->fragment_shader().mask_tex_coord_offset_location();
1032 shader_color_matrix_location = 1025 shader_color_matrix_location =
1033 program->fragment_shader().color_matrix_location(); 1026 program->fragment_shader().color_matrix_location();
1034 shader_color_offset_location = 1027 shader_color_offset_location =
1035 program->fragment_shader().color_offset_location(); 1028 program->fragment_shader().color_offset_location();
1036 } else if (use_aa && !mask_texture_id && use_color_matrix) { 1029 } else if (use_aa && !mask_texture_id && use_color_matrix) {
1037 const RenderPassColorMatrixProgramAA* program = 1030 const RenderPassColorMatrixProgramAA* program =
1038 GetRenderPassColorMatrixProgramAA(tex_coord_precision); 1031 GetRenderPassColorMatrixProgramAA(tex_coord_precision);
1039 SetUseProgram(program->program()); 1032 SetUseProgram(program->program());
1040 GLC(Context(), 1033 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1041 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1042 1034
1043 shader_matrix_location = program->vertex_shader().matrix_location(); 1035 shader_matrix_location = program->vertex_shader().matrix_location();
1044 shader_quad_location = program->vertex_shader().quad_location(); 1036 shader_quad_location = program->vertex_shader().quad_location();
1045 shader_tex_transform_location = 1037 shader_tex_transform_location =
1046 program->vertex_shader().tex_transform_location(); 1038 program->vertex_shader().tex_transform_location();
1047 shader_edge_location = program->vertex_shader().edge_location(); 1039 shader_edge_location = program->vertex_shader().edge_location();
1048 shader_viewport_location = program->vertex_shader().viewport_location(); 1040 shader_viewport_location = program->vertex_shader().viewport_location();
1049 shader_alpha_location = program->fragment_shader().alpha_location(); 1041 shader_alpha_location = program->fragment_shader().alpha_location();
1050 shader_color_matrix_location = 1042 shader_color_matrix_location =
1051 program->fragment_shader().color_matrix_location(); 1043 program->fragment_shader().color_matrix_location();
1052 shader_color_offset_location = 1044 shader_color_offset_location =
1053 program->fragment_shader().color_offset_location(); 1045 program->fragment_shader().color_offset_location();
1054 } else if (!use_aa && mask_texture_id && use_color_matrix) { 1046 } else if (!use_aa && mask_texture_id && use_color_matrix) {
1055 const RenderPassMaskColorMatrixProgram* program = 1047 const RenderPassMaskColorMatrixProgram* program =
1056 GetRenderPassMaskColorMatrixProgram(tex_coord_precision); 1048 GetRenderPassMaskColorMatrixProgram(tex_coord_precision);
1057 SetUseProgram(program->program()); 1049 SetUseProgram(program->program());
1058 GLC(Context(), 1050 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1059 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1060 1051
1061 shader_matrix_location = program->vertex_shader().matrix_location(); 1052 shader_matrix_location = program->vertex_shader().matrix_location();
1062 shader_tex_transform_location = 1053 shader_tex_transform_location =
1063 program->vertex_shader().tex_transform_location(); 1054 program->vertex_shader().tex_transform_location();
1064 shader_mask_sampler_location = 1055 shader_mask_sampler_location =
1065 program->fragment_shader().mask_sampler_location(); 1056 program->fragment_shader().mask_sampler_location();
1066 shader_mask_tex_coord_scale_location = 1057 shader_mask_tex_coord_scale_location =
1067 program->fragment_shader().mask_tex_coord_scale_location(); 1058 program->fragment_shader().mask_tex_coord_scale_location();
1068 shader_mask_tex_coord_offset_location = 1059 shader_mask_tex_coord_offset_location =
1069 program->fragment_shader().mask_tex_coord_offset_location(); 1060 program->fragment_shader().mask_tex_coord_offset_location();
1070 shader_alpha_location = program->fragment_shader().alpha_location(); 1061 shader_alpha_location = program->fragment_shader().alpha_location();
1071 shader_color_matrix_location = 1062 shader_color_matrix_location =
1072 program->fragment_shader().color_matrix_location(); 1063 program->fragment_shader().color_matrix_location();
1073 shader_color_offset_location = 1064 shader_color_offset_location =
1074 program->fragment_shader().color_offset_location(); 1065 program->fragment_shader().color_offset_location();
1075 } else if (!use_aa && !mask_texture_id && use_color_matrix) { 1066 } else if (!use_aa && !mask_texture_id && use_color_matrix) {
1076 const RenderPassColorMatrixProgram* program = 1067 const RenderPassColorMatrixProgram* program =
1077 GetRenderPassColorMatrixProgram(tex_coord_precision); 1068 GetRenderPassColorMatrixProgram(tex_coord_precision);
1078 SetUseProgram(program->program()); 1069 SetUseProgram(program->program());
1079 GLC(Context(), 1070 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1080 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1081 1071
1082 shader_matrix_location = program->vertex_shader().matrix_location(); 1072 shader_matrix_location = program->vertex_shader().matrix_location();
1083 shader_tex_transform_location = 1073 shader_tex_transform_location =
1084 program->vertex_shader().tex_transform_location(); 1074 program->vertex_shader().tex_transform_location();
1085 shader_alpha_location = program->fragment_shader().alpha_location(); 1075 shader_alpha_location = program->fragment_shader().alpha_location();
1086 shader_color_matrix_location = 1076 shader_color_matrix_location =
1087 program->fragment_shader().color_matrix_location(); 1077 program->fragment_shader().color_matrix_location();
1088 shader_color_offset_location = 1078 shader_color_offset_location =
1089 program->fragment_shader().color_offset_location(); 1079 program->fragment_shader().color_offset_location();
1090 } else { 1080 } else {
1091 const RenderPassProgram* program = 1081 const RenderPassProgram* program =
1092 GetRenderPassProgram(tex_coord_precision); 1082 GetRenderPassProgram(tex_coord_precision);
1093 SetUseProgram(program->program()); 1083 SetUseProgram(program->program());
1094 GLC(Context(), 1084 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1095 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1096 1085
1097 shader_matrix_location = program->vertex_shader().matrix_location(); 1086 shader_matrix_location = program->vertex_shader().matrix_location();
1098 shader_alpha_location = program->fragment_shader().alpha_location(); 1087 shader_alpha_location = program->fragment_shader().alpha_location();
1099 shader_tex_transform_location = 1088 shader_tex_transform_location =
1100 program->vertex_shader().tex_transform_location(); 1089 program->vertex_shader().tex_transform_location();
1101 } 1090 }
1102 float tex_scale_x = 1091 float tex_scale_x =
1103 quad->rect.width() / static_cast<float>(contents_texture->size().width()); 1092 quad->rect.width() / static_cast<float>(contents_texture->size().width());
1104 float tex_scale_y = quad->rect.height() / 1093 float tex_scale_y = quad->rect.height() /
1105 static_cast<float>(contents_texture->size().height()); 1094 static_cast<float>(contents_texture->size().height());
1106 DCHECK_LE(tex_scale_x, 1.0f); 1095 DCHECK_LE(tex_scale_x, 1.0f);
1107 DCHECK_LE(tex_scale_y, 1.0f); 1096 DCHECK_LE(tex_scale_y, 1.0f);
1108 1097
1109 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); 1098 DCHECK(shader_tex_transform_location != -1 || IsContextLost());
1110 // Flip the content vertically in the shader, as the RenderPass input 1099 // Flip the content vertically in the shader, as the RenderPass input
1111 // texture is already oriented the same way as the framebuffer, but the 1100 // texture is already oriented the same way as the framebuffer, but the
1112 // projection transform does a flip. 1101 // projection transform does a flip.
1113 GLC(Context(), Context()->uniform4f(shader_tex_transform_location, 1102 GLC(gl_,
1114 0.0f, 1103 gl_->Uniform4f(shader_tex_transform_location,
1115 tex_scale_y, 1104 0.0f,
1116 tex_scale_x, 1105 tex_scale_y,
1117 -tex_scale_y)); 1106 tex_scale_x,
1107 -tex_scale_y));
1118 1108
1119 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; 1109 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock;
1120 if (shader_mask_sampler_location != -1) { 1110 if (shader_mask_sampler_location != -1) {
1121 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); 1111 DCHECK_NE(shader_mask_tex_coord_scale_location, 1);
1122 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); 1112 DCHECK_NE(shader_mask_tex_coord_offset_location, 1);
1123 GLC(Context(), Context()->uniform1i(shader_mask_sampler_location, 1)); 1113 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1));
1124 1114
1125 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x; 1115 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x;
1126 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y; 1116 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y;
1127 1117
1128 // Mask textures are oriented vertically flipped relative to the framebuffer 1118 // Mask textures are oriented vertically flipped relative to the framebuffer
1129 // and the RenderPass contents texture, so we flip the tex coords from the 1119 // and the RenderPass contents texture, so we flip the tex coords from the
1130 // RenderPass texture to find the mask texture coords. 1120 // RenderPass texture to find the mask texture coords.
1131 GLC(Context(), 1121 GLC(gl_,
1132 Context()->uniform2f( 1122 gl_->Uniform2f(shader_mask_tex_coord_offset_location,
1133 shader_mask_tex_coord_offset_location, 1123 quad->mask_uv_rect.x(),
1134 quad->mask_uv_rect.x(), 1124 quad->mask_uv_rect.y() + quad->mask_uv_rect.height()));
1135 quad->mask_uv_rect.y() + quad->mask_uv_rect.height())); 1125 GLC(gl_,
1136 GLC(Context(), 1126 gl_->Uniform2f(shader_mask_tex_coord_scale_location,
1137 Context()->uniform2f(shader_mask_tex_coord_scale_location, 1127 mask_tex_scale_x,
1138 mask_tex_scale_x, 1128 -mask_tex_scale_y));
1139 -mask_tex_scale_y));
1140 shader_mask_sampler_lock = make_scoped_ptr( 1129 shader_mask_sampler_lock = make_scoped_ptr(
1141 new ResourceProvider::ScopedSamplerGL(resource_provider_, 1130 new ResourceProvider::ScopedSamplerGL(resource_provider_,
1142 quad->mask_resource_id, 1131 quad->mask_resource_id,
1143 GL_TEXTURE1, 1132 GL_TEXTURE1,
1144 GL_LINEAR)); 1133 GL_LINEAR));
1145 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1134 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1146 shader_mask_sampler_lock->target()); 1135 shader_mask_sampler_lock->target());
1147 } 1136 }
1148 1137
1149 if (shader_edge_location != -1) { 1138 if (shader_edge_location != -1) {
1150 float edge[24]; 1139 float edge[24];
1151 device_layer_edges.ToFloatArray(edge); 1140 device_layer_edges.ToFloatArray(edge);
1152 device_layer_bounds.ToFloatArray(&edge[12]); 1141 device_layer_bounds.ToFloatArray(&edge[12]);
1153 GLC(Context(), Context()->uniform3fv(shader_edge_location, 8, edge)); 1142 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge));
1154 } 1143 }
1155 1144
1156 if (shader_viewport_location != -1) { 1145 if (shader_viewport_location != -1) {
1157 float viewport[4] = { 1146 float viewport[4] = {static_cast<float>(viewport_.x()),
1158 static_cast<float>(viewport_.x()), 1147 static_cast<float>(viewport_.y()),
1159 static_cast<float>(viewport_.y()), 1148 static_cast<float>(viewport_.width()),
1160 static_cast<float>(viewport_.width()), 1149 static_cast<float>(viewport_.height()), };
1161 static_cast<float>(viewport_.height()), 1150 GLC(gl_, gl_->Uniform4fv(shader_viewport_location, 1, viewport));
1162 };
1163 GLC(Context(),
1164 Context()->uniform4fv(shader_viewport_location, 1, viewport));
1165 } 1151 }
1166 1152
1167 if (shader_color_matrix_location != -1) { 1153 if (shader_color_matrix_location != -1) {
1168 float matrix[16]; 1154 float matrix[16];
1169 for (int i = 0; i < 4; ++i) { 1155 for (int i = 0; i < 4; ++i) {
1170 for (int j = 0; j < 4; ++j) 1156 for (int j = 0; j < 4; ++j)
1171 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]); 1157 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]);
1172 } 1158 }
1173 GLC(Context(), 1159 GLC(gl_,
1174 Context()->uniformMatrix4fv( 1160 gl_->UniformMatrix4fv(shader_color_matrix_location, 1, false, matrix));
1175 shader_color_matrix_location, 1, false, matrix));
1176 } 1161 }
1177 static const float kScale = 1.0f / 255.0f; 1162 static const float kScale = 1.0f / 255.0f;
1178 if (shader_color_offset_location != -1) { 1163 if (shader_color_offset_location != -1) {
1179 float offset[4]; 1164 float offset[4];
1180 for (int i = 0; i < 4; ++i) 1165 for (int i = 0; i < 4; ++i)
1181 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; 1166 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale;
1182 1167
1183 GLC(Context(), 1168 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset));
1184 Context()->uniform4fv(shader_color_offset_location, 1, offset));
1185 } 1169 }
1186 1170
1187 // Map device space quad to surface space. contents_device_transform has no 3d 1171 // Map device space quad to surface space. contents_device_transform has no 3d
1188 // component since it was flattened, so we don't need to project. 1172 // component since it was flattened, so we don't need to project.
1189 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse, 1173 gfx::QuadF surface_quad = MathUtil::MapQuad(contents_device_transform_inverse,
1190 device_layer_edges.ToQuadF(), 1174 device_layer_edges.ToQuadF(),
1191 &clipped); 1175 &clipped);
1192 1176
1193 SetShaderOpacity(quad->opacity(), shader_alpha_location); 1177 SetShaderOpacity(quad->opacity(), shader_alpha_location);
1194 SetShaderQuadF(surface_quad, shader_quad_location); 1178 SetShaderQuadF(surface_quad, shader_quad_location);
1195 DrawQuadGeometry( 1179 DrawQuadGeometry(
1196 frame, quad->quadTransform(), quad->rect, shader_matrix_location); 1180 frame, quad->quadTransform(), quad->rect, shader_matrix_location);
1197 1181
1198 // Flush the compositor context before the filter bitmap goes out of 1182 // Flush the compositor context before the filter bitmap goes out of
1199 // scope, so the draw gets processed before the filter texture gets deleted. 1183 // scope, so the draw gets processed before the filter texture gets deleted.
1200 if (filter_bitmap.getTexture()) 1184 if (filter_bitmap.getTexture())
1201 GLC(context_, context_->flush()); 1185 GLC(gl_, gl_->Flush());
1202 } 1186 }
1203 1187
1204 struct SolidColorProgramUniforms { 1188 struct SolidColorProgramUniforms {
1205 unsigned program; 1189 unsigned program;
1206 unsigned matrix_location; 1190 unsigned matrix_location;
1207 unsigned viewport_location; 1191 unsigned viewport_location;
1208 unsigned quad_location; 1192 unsigned quad_location;
1209 unsigned edge_location; 1193 unsigned edge_location;
1210 unsigned color_location; 1194 unsigned color_location;
1211 }; 1195 };
1212 1196
1213 template<class T> 1197 template <class T>
1214 static void SolidColorUniformLocation(T program, 1198 static void SolidColorUniformLocation(T program,
1215 SolidColorProgramUniforms* uniforms) { 1199 SolidColorProgramUniforms* uniforms) {
1216 uniforms->program = program->program(); 1200 uniforms->program = program->program();
1217 uniforms->matrix_location = program->vertex_shader().matrix_location(); 1201 uniforms->matrix_location = program->vertex_shader().matrix_location();
1218 uniforms->viewport_location = program->vertex_shader().viewport_location(); 1202 uniforms->viewport_location = program->vertex_shader().viewport_location();
1219 uniforms->quad_location = program->vertex_shader().quad_location(); 1203 uniforms->quad_location = program->vertex_shader().quad_location();
1220 uniforms->edge_location = program->vertex_shader().edge_location(); 1204 uniforms->edge_location = program->vertex_shader().edge_location();
1221 uniforms->color_location = program->fragment_shader().color_location(); 1205 uniforms->color_location = program->fragment_shader().color_location();
1222 } 1206 }
1223 1207
1224 // static 1208 // static
1225 bool GLRenderer::SetupQuadForAntialiasing( 1209 bool GLRenderer::SetupQuadForAntialiasing(
1226 const gfx::Transform& device_transform, 1210 const gfx::Transform& device_transform,
1227 const DrawQuad* quad, 1211 const DrawQuad* quad,
1228 gfx::QuadF* local_quad, 1212 gfx::QuadF* local_quad,
1229 float edge[24]) { 1213 float edge[24]) {
1230 gfx::Rect tile_rect = quad->visible_rect; 1214 gfx::Rect tile_rect = quad->visible_rect;
1231 1215
1232 bool clipped = false; 1216 bool clipped = false;
1233 gfx::QuadF device_layer_quad = MathUtil::MapQuad( 1217 gfx::QuadF device_layer_quad = MathUtil::MapQuad(
1234 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped); 1218 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped);
1235 1219
1236 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear(); 1220 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear();
1237 bool is_nearest_rect_within_epsilon = is_axis_aligned_in_target && 1221 bool is_nearest_rect_within_epsilon =
1222 is_axis_aligned_in_target &&
1238 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), 1223 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(),
1239 kAntiAliasingEpsilon); 1224 kAntiAliasingEpsilon);
1240 // AAing clipped quads is not supported by the code yet. 1225 // AAing clipped quads is not supported by the code yet.
1241 bool use_aa = !clipped && !is_nearest_rect_within_epsilon && quad->IsEdge(); 1226 bool use_aa = !clipped && !is_nearest_rect_within_epsilon && quad->IsEdge();
1242 if (!use_aa) 1227 if (!use_aa)
1243 return false; 1228 return false;
1244 1229
1245 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox())); 1230 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox()));
1246 device_layer_bounds.InflateAntiAliasingDistance(); 1231 device_layer_bounds.InflateAntiAliasingDistance();
1247 1232
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 left_edge.scale(sign); 1271 left_edge.scale(sign);
1287 top_edge.scale(sign); 1272 top_edge.scale(sign);
1288 right_edge.scale(sign); 1273 right_edge.scale(sign);
1289 1274
1290 // Create device space quad. 1275 // Create device space quad.
1291 LayerQuad device_quad(left_edge, top_edge, right_edge, bottom_edge); 1276 LayerQuad device_quad(left_edge, top_edge, right_edge, bottom_edge);
1292 1277
1293 // Map device space quad to local space. device_transform has no 3d 1278 // Map device space quad to local space. device_transform has no 3d
1294 // component since it was flattened, so we don't need to project. We should 1279 // component since it was flattened, so we don't need to project. We should
1295 // have already checked that the transform was uninvertible above. 1280 // have already checked that the transform was uninvertible above.
1296 gfx::Transform inverse_device_transform( 1281 gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization);
1297 gfx::Transform::kSkipInitialization);
1298 bool did_invert = device_transform.GetInverse(&inverse_device_transform); 1282 bool did_invert = device_transform.GetInverse(&inverse_device_transform);
1299 DCHECK(did_invert); 1283 DCHECK(did_invert);
1300 *local_quad = MathUtil::MapQuad( 1284 *local_quad = MathUtil::MapQuad(
1301 inverse_device_transform, device_quad.ToQuadF(), &clipped); 1285 inverse_device_transform, device_quad.ToQuadF(), &clipped);
1302 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may 1286 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may
1303 // cause device_quad to become clipped. To our knowledge this scenario does 1287 // cause device_quad to become clipped. To our knowledge this scenario does
1304 // not need to be handled differently than the unclipped case. 1288 // not need to be handled differently than the unclipped case.
1305 1289
1306 return true; 1290 return true;
1307 } 1291 }
(...skipping 23 matching lines...) Expand all
1331 settings_->allow_antialiasing && !quad->force_anti_aliasing_off && 1315 settings_->allow_antialiasing && !quad->force_anti_aliasing_off &&
1332 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); 1316 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1333 1317
1334 SolidColorProgramUniforms uniforms; 1318 SolidColorProgramUniforms uniforms;
1335 if (use_aa) 1319 if (use_aa)
1336 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); 1320 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms);
1337 else 1321 else
1338 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); 1322 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
1339 SetUseProgram(uniforms.program); 1323 SetUseProgram(uniforms.program);
1340 1324
1341 GLC(Context(), 1325 GLC(gl_,
1342 Context()->uniform4f(uniforms.color_location, 1326 gl_->Uniform4f(uniforms.color_location,
1343 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1327 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1344 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1328 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
1345 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, 1329 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
1346 alpha)); 1330 alpha));
1347 if (use_aa) { 1331 if (use_aa) {
1348 float viewport[4] = { 1332 float viewport[4] = {static_cast<float>(viewport_.x()),
1349 static_cast<float>(viewport_.x()), 1333 static_cast<float>(viewport_.y()),
1350 static_cast<float>(viewport_.y()), 1334 static_cast<float>(viewport_.width()),
1351 static_cast<float>(viewport_.width()), 1335 static_cast<float>(viewport_.height()), };
1352 static_cast<float>(viewport_.height()), 1336 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
1353 }; 1337 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
1354 GLC(Context(),
1355 Context()->uniform4fv(uniforms.viewport_location, 1, viewport));
1356 GLC(Context(), Context()->uniform3fv(uniforms.edge_location, 8, edge));
1357 } 1338 }
1358 1339
1359 // Enable blending when the quad properties require it or if we decided 1340 // Enable blending when the quad properties require it or if we decided
1360 // to use antialiasing. 1341 // to use antialiasing.
1361 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1342 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1362 1343
1363 // Normalize to tile_rect. 1344 // Normalize to tile_rect.
1364 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1345 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1365 1346
1366 SetShaderQuadF(local_quad, uniforms.quad_location); 1347 SetShaderQuadF(local_quad, uniforms.quad_location);
1367 1348
1368 // The transform and vertex data are used to figure out the extents that the 1349 // The transform and vertex data are used to figure out the extents that the
1369 // un-antialiased quad should have and which vertex this is and the float 1350 // un-antialiased quad should have and which vertex this is and the float
1370 // quad passed in via uniform is the actual geometry that gets used to draw 1351 // quad passed in via uniform is the actual geometry that gets used to draw
1371 // it. This is why this centered rect is used and not the original quad_rect. 1352 // it. This is why this centered rect is used and not the original quad_rect.
1372 gfx::RectF centered_rect(gfx::PointF(-0.5f * tile_rect.width(), 1353 gfx::RectF centered_rect(
1373 -0.5f * tile_rect.height()), 1354 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1374 tile_rect.size()); 1355 tile_rect.size());
1375 DrawQuadGeometry(frame, quad->quadTransform(), 1356 DrawQuadGeometry(
1376 centered_rect, uniforms.matrix_location); 1357 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
1377 } 1358 }
1378 1359
1379 struct TileProgramUniforms { 1360 struct TileProgramUniforms {
1380 unsigned program; 1361 unsigned program;
1381 unsigned matrix_location; 1362 unsigned matrix_location;
1382 unsigned viewport_location; 1363 unsigned viewport_location;
1383 unsigned quad_location; 1364 unsigned quad_location;
1384 unsigned edge_location; 1365 unsigned edge_location;
1385 unsigned vertex_tex_transform_location; 1366 unsigned vertex_tex_transform_location;
1386 unsigned sampler_location; 1367 unsigned sampler_location;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 quad->rect.height() / quad->tex_coord_rect.height(); 1402 quad->rect.height() / quad->tex_coord_rect.height();
1422 1403
1423 gfx::RectF clamp_geom_rect(tile_rect); 1404 gfx::RectF clamp_geom_rect(tile_rect);
1424 gfx::RectF clamp_tex_rect(tex_coord_rect); 1405 gfx::RectF clamp_tex_rect(tex_coord_rect);
1425 // Clamp texture coordinates to avoid sampling outside the layer 1406 // Clamp texture coordinates to avoid sampling outside the layer
1426 // by deflating the tile region half a texel or half a texel 1407 // by deflating the tile region half a texel or half a texel
1427 // minus epsilon for one pixel layers. The resulting clamp region 1408 // minus epsilon for one pixel layers. The resulting clamp region
1428 // is mapped to the unit square by the vertex shader and mapped 1409 // is mapped to the unit square by the vertex shader and mapped
1429 // back to normalized texture coordinates by the fragment shader 1410 // back to normalized texture coordinates by the fragment shader
1430 // after being clamped to 0-1 range. 1411 // after being clamped to 0-1 range.
1431 float tex_clamp_x = std::min( 1412 float tex_clamp_x =
1432 0.5f, 0.5f * clamp_tex_rect.width() - kAntiAliasingEpsilon); 1413 std::min(0.5f, 0.5f * clamp_tex_rect.width() - kAntiAliasingEpsilon);
1433 float tex_clamp_y = std::min( 1414 float tex_clamp_y =
1434 0.5f, 0.5f * clamp_tex_rect.height() - kAntiAliasingEpsilon); 1415 std::min(0.5f, 0.5f * clamp_tex_rect.height() - kAntiAliasingEpsilon);
1435 float geom_clamp_x = std::min( 1416 float geom_clamp_x =
1436 tex_clamp_x * tex_to_geom_scale_x, 1417 std::min(tex_clamp_x * tex_to_geom_scale_x,
1437 0.5f * clamp_geom_rect.width() - kAntiAliasingEpsilon); 1418 0.5f * clamp_geom_rect.width() - kAntiAliasingEpsilon);
1438 float geom_clamp_y = std::min( 1419 float geom_clamp_y =
1439 tex_clamp_y * tex_to_geom_scale_y, 1420 std::min(tex_clamp_y * tex_to_geom_scale_y,
1440 0.5f * clamp_geom_rect.height() - kAntiAliasingEpsilon); 1421 0.5f * clamp_geom_rect.height() - kAntiAliasingEpsilon);
1441 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y); 1422 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y);
1442 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); 1423 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y);
1443 1424
1444 // Map clamping rectangle to unit square. 1425 // Map clamping rectangle to unit square.
1445 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); 1426 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width();
1446 float vertex_tex_translate_y = 1427 float vertex_tex_translate_y =
1447 -clamp_geom_rect.y() / clamp_geom_rect.height(); 1428 -clamp_geom_rect.y() / clamp_geom_rect.height();
1448 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); 1429 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width();
1449 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); 1430 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
1450 1431
1451 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1432 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1452 gl_, &highp_threshold_cache_, highp_threshold_min_, 1433 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
1453 quad->texture_size);
1454 1434
1455 gfx::Transform device_transform = 1435 gfx::Transform device_transform =
1456 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1436 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1457 device_transform.FlattenTo2d(); 1437 device_transform.FlattenTo2d();
1458 if (!device_transform.IsInvertible()) 1438 if (!device_transform.IsInvertible())
1459 return; 1439 return;
1460 1440
1461 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1441 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1462 float edge[24]; 1442 float edge[24];
1463 bool use_aa = settings_->allow_antialiasing && SetupQuadForAntialiasing( 1443 bool use_aa =
1464 device_transform, quad, &local_quad, edge); 1444 settings_->allow_antialiasing &&
1445 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1465 1446
1466 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); 1447 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
1467 GLenum filter = (use_aa || scaled || 1448 GLenum filter = (use_aa || scaled ||
1468 !quad->quadTransform().IsIdentityOrIntegerTranslation()) 1449 !quad->quadTransform().IsIdentityOrIntegerTranslation())
1469 ? GL_LINEAR 1450 ? GL_LINEAR
1470 : GL_NEAREST; 1451 : GL_NEAREST;
1471 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1452 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1472 resource_provider_, resource_id, filter); 1453 resource_provider_, resource_id, filter);
1473 SamplerType sampler = SamplerTypeFromTextureTarget( 1454 SamplerType sampler =
1474 quad_resource_lock.target()); 1455 SamplerTypeFromTextureTarget(quad_resource_lock.target());
1475 1456
1476 float fragment_tex_translate_x = clamp_tex_rect.x(); 1457 float fragment_tex_translate_x = clamp_tex_rect.x();
1477 float fragment_tex_translate_y = clamp_tex_rect.y(); 1458 float fragment_tex_translate_y = clamp_tex_rect.y();
1478 float fragment_tex_scale_x = clamp_tex_rect.width(); 1459 float fragment_tex_scale_x = clamp_tex_rect.width();
1479 float fragment_tex_scale_y = clamp_tex_rect.height(); 1460 float fragment_tex_scale_y = clamp_tex_rect.height();
1480 1461
1481 // Map to normalized texture coordinates. 1462 // Map to normalized texture coordinates.
1482 if (sampler != SamplerType2DRect) { 1463 if (sampler != SamplerType2DRect) {
1483 gfx::Size texture_size = quad->texture_size; 1464 gfx::Size texture_size = quad->texture_size;
1484 DCHECK(!texture_size.IsEmpty()); 1465 DCHECK(!texture_size.IsEmpty());
1485 fragment_tex_translate_x /= texture_size.width(); 1466 fragment_tex_translate_x /= texture_size.width();
1486 fragment_tex_translate_y /= texture_size.height(); 1467 fragment_tex_translate_y /= texture_size.height();
1487 fragment_tex_scale_x /= texture_size.width(); 1468 fragment_tex_scale_x /= texture_size.width();
1488 fragment_tex_scale_y /= texture_size.height(); 1469 fragment_tex_scale_y /= texture_size.height();
1489 } 1470 }
1490 1471
1491 TileProgramUniforms uniforms; 1472 TileProgramUniforms uniforms;
1492 if (use_aa) { 1473 if (use_aa) {
1493 if (quad->swizzle_contents) { 1474 if (quad->swizzle_contents) {
1494 TileUniformLocation( 1475 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision, sampler),
1495 GetTileProgramSwizzleAA(tex_coord_precision, sampler), 1476 &uniforms);
1496 &uniforms);
1497 } else { 1477 } else {
1498 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler), 1478 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler),
1499 &uniforms); 1479 &uniforms);
1500 } 1480 }
1501 } else { 1481 } else {
1502 if (quad->ShouldDrawWithBlending()) { 1482 if (quad->ShouldDrawWithBlending()) {
1503 if (quad->swizzle_contents) { 1483 if (quad->swizzle_contents) {
1504 TileUniformLocation( 1484 TileUniformLocation(GetTileProgramSwizzle(tex_coord_precision, sampler),
1505 GetTileProgramSwizzle(tex_coord_precision, sampler), 1485 &uniforms);
1506 &uniforms);
1507 } else { 1486 } else {
1508 TileUniformLocation(GetTileProgram(tex_coord_precision, sampler), 1487 TileUniformLocation(GetTileProgram(tex_coord_precision, sampler),
1509 &uniforms); 1488 &uniforms);
1510 } 1489 }
1511 } else { 1490 } else {
1512 if (quad->swizzle_contents) { 1491 if (quad->swizzle_contents) {
1513 TileUniformLocation( 1492 TileUniformLocation(
1514 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler), 1493 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler),
1515 &uniforms); 1494 &uniforms);
1516 } else { 1495 } else {
1517 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler), 1496 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler),
1518 &uniforms); 1497 &uniforms);
1519 } 1498 }
1520 } 1499 }
1521 } 1500 }
1522 1501
1523 SetUseProgram(uniforms.program); 1502 SetUseProgram(uniforms.program);
1524 GLC(Context(), Context()->uniform1i(uniforms.sampler_location, 0)); 1503 GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0));
1525 1504
1526 if (use_aa) { 1505 if (use_aa) {
1527 float viewport[4] = { 1506 float viewport[4] = {static_cast<float>(viewport_.x()),
1528 static_cast<float>(viewport_.x()), 1507 static_cast<float>(viewport_.y()),
1529 static_cast<float>(viewport_.y()), 1508 static_cast<float>(viewport_.width()),
1530 static_cast<float>(viewport_.width()), 1509 static_cast<float>(viewport_.height()), };
1531 static_cast<float>(viewport_.height()), 1510 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
1532 }; 1511 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
1533 GLC(Context(),
1534 Context()->uniform4fv(uniforms.viewport_location, 1, viewport));
1535 GLC(Context(), Context()->uniform3fv(uniforms.edge_location, 8, edge));
1536 1512
1537 GLC(Context(), 1513 GLC(gl_,
1538 Context()->uniform4f(uniforms.vertex_tex_transform_location, 1514 gl_->Uniform4f(uniforms.vertex_tex_transform_location,
1539 vertex_tex_translate_x, 1515 vertex_tex_translate_x,
1540 vertex_tex_translate_y, 1516 vertex_tex_translate_y,
1541 vertex_tex_scale_x, 1517 vertex_tex_scale_x,
1542 vertex_tex_scale_y)); 1518 vertex_tex_scale_y));
1543 GLC(Context(), 1519 GLC(gl_,
1544 Context()->uniform4f(uniforms.fragment_tex_transform_location, 1520 gl_->Uniform4f(uniforms.fragment_tex_transform_location,
1545 fragment_tex_translate_x, 1521 fragment_tex_translate_x,
1546 fragment_tex_translate_y, 1522 fragment_tex_translate_y,
1547 fragment_tex_scale_x, 1523 fragment_tex_scale_x,
1548 fragment_tex_scale_y)); 1524 fragment_tex_scale_y));
1549 } else { 1525 } else {
1550 // Move fragment shader transform to vertex shader. We can do this while 1526 // Move fragment shader transform to vertex shader. We can do this while
1551 // still producing correct results as fragment_tex_transform_location 1527 // still producing correct results as fragment_tex_transform_location
1552 // should always be non-negative when tiles are transformed in a way 1528 // should always be non-negative when tiles are transformed in a way
1553 // that could result in sampling outside the layer. 1529 // that could result in sampling outside the layer.
1554 vertex_tex_scale_x *= fragment_tex_scale_x; 1530 vertex_tex_scale_x *= fragment_tex_scale_x;
1555 vertex_tex_scale_y *= fragment_tex_scale_y; 1531 vertex_tex_scale_y *= fragment_tex_scale_y;
1556 vertex_tex_translate_x *= fragment_tex_scale_x; 1532 vertex_tex_translate_x *= fragment_tex_scale_x;
1557 vertex_tex_translate_y *= fragment_tex_scale_y; 1533 vertex_tex_translate_y *= fragment_tex_scale_y;
1558 vertex_tex_translate_x += fragment_tex_translate_x; 1534 vertex_tex_translate_x += fragment_tex_translate_x;
1559 vertex_tex_translate_y += fragment_tex_translate_y; 1535 vertex_tex_translate_y += fragment_tex_translate_y;
1560 1536
1561 GLC(Context(), 1537 GLC(gl_,
1562 Context()->uniform4f(uniforms.vertex_tex_transform_location, 1538 gl_->Uniform4f(uniforms.vertex_tex_transform_location,
1563 vertex_tex_translate_x, 1539 vertex_tex_translate_x,
1564 vertex_tex_translate_y, 1540 vertex_tex_translate_y,
1565 vertex_tex_scale_x, 1541 vertex_tex_scale_x,
1566 vertex_tex_scale_y)); 1542 vertex_tex_scale_y));
1567 } 1543 }
1568 1544
1569 // Enable blending when the quad properties require it or if we decided 1545 // Enable blending when the quad properties require it or if we decided
1570 // to use antialiasing. 1546 // to use antialiasing.
1571 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1547 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1572 1548
1573 // Normalize to tile_rect. 1549 // Normalize to tile_rect.
1574 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1550 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1575 1551
1576 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1552 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1577 SetShaderQuadF(local_quad, uniforms.quad_location); 1553 SetShaderQuadF(local_quad, uniforms.quad_location);
1578 1554
1579 // The transform and vertex data are used to figure out the extents that the 1555 // The transform and vertex data are used to figure out the extents that the
1580 // un-antialiased quad should have and which vertex this is and the float 1556 // un-antialiased quad should have and which vertex this is and the float
1581 // quad passed in via uniform is the actual geometry that gets used to draw 1557 // quad passed in via uniform is the actual geometry that gets used to draw
1582 // it. This is why this centered rect is used and not the original quad_rect. 1558 // it. This is why this centered rect is used and not the original quad_rect.
1583 gfx::RectF centered_rect( 1559 gfx::RectF centered_rect(
1584 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1560 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1585 tile_rect.size()); 1561 tile_rect.size());
1586 DrawQuadGeometry( 1562 DrawQuadGeometry(
1587 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); 1563 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
1588 } 1564 }
1589 1565
1590 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, 1566 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
1591 const YUVVideoDrawQuad* quad) { 1567 const YUVVideoDrawQuad* quad) {
1592 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1568 SetBlendEnabled(quad->ShouldDrawWithBlending());
1593 1569
1594 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1570 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1595 gl_, &highp_threshold_cache_, highp_threshold_min_, 1571 gl_,
1572 &highp_threshold_cache_,
1573 highp_threshold_min_,
1596 quad->shared_quad_state->visible_content_rect.bottom_right()); 1574 quad->shared_quad_state->visible_content_rect.bottom_right());
1597 1575
1598 bool use_alpha_plane = quad->a_plane_resource_id != 0; 1576 bool use_alpha_plane = quad->a_plane_resource_id != 0;
1599 1577
1600 ResourceProvider::ScopedSamplerGL y_plane_lock( 1578 ResourceProvider::ScopedSamplerGL y_plane_lock(
1601 resource_provider_, 1579 resource_provider_, quad->y_plane_resource_id, GL_TEXTURE1, GL_LINEAR);
1602 quad->y_plane_resource_id,
1603 GL_TEXTURE1,
1604 GL_LINEAR);
1605 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), y_plane_lock.target()); 1580 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), y_plane_lock.target());
1606 ResourceProvider::ScopedSamplerGL u_plane_lock( 1581 ResourceProvider::ScopedSamplerGL u_plane_lock(
1607 resource_provider_, 1582 resource_provider_, quad->u_plane_resource_id, GL_TEXTURE2, GL_LINEAR);
1608 quad->u_plane_resource_id,
1609 GL_TEXTURE2,
1610 GL_LINEAR);
1611 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), u_plane_lock.target()); 1583 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), u_plane_lock.target());
1612 ResourceProvider::ScopedSamplerGL v_plane_lock( 1584 ResourceProvider::ScopedSamplerGL v_plane_lock(
1613 resource_provider_, 1585 resource_provider_, quad->v_plane_resource_id, GL_TEXTURE3, GL_LINEAR);
1614 quad->v_plane_resource_id,
1615 GL_TEXTURE3,
1616 GL_LINEAR);
1617 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target()); 1586 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target());
1618 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; 1587 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
1619 if (use_alpha_plane) { 1588 if (use_alpha_plane) {
1620 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( 1589 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
1621 resource_provider_, 1590 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR));
1622 quad->a_plane_resource_id,
1623 GL_TEXTURE4,
1624 GL_LINEAR));
1625 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); 1591 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target());
1626 } 1592 }
1627 1593
1628 int tex_scale_location = -1; 1594 int tex_scale_location = -1;
1629 int matrix_location = -1; 1595 int matrix_location = -1;
1630 int y_texture_location = -1; 1596 int y_texture_location = -1;
1631 int u_texture_location = -1; 1597 int u_texture_location = -1;
1632 int v_texture_location = -1; 1598 int v_texture_location = -1;
1633 int a_texture_location = -1; 1599 int a_texture_location = -1;
1634 int yuv_matrix_location = -1; 1600 int yuv_matrix_location = -1;
(...skipping 19 matching lines...) Expand all
1654 tex_scale_location = program->vertex_shader().tex_scale_location(); 1620 tex_scale_location = program->vertex_shader().tex_scale_location();
1655 matrix_location = program->vertex_shader().matrix_location(); 1621 matrix_location = program->vertex_shader().matrix_location();
1656 y_texture_location = program->fragment_shader().y_texture_location(); 1622 y_texture_location = program->fragment_shader().y_texture_location();
1657 u_texture_location = program->fragment_shader().u_texture_location(); 1623 u_texture_location = program->fragment_shader().u_texture_location();
1658 v_texture_location = program->fragment_shader().v_texture_location(); 1624 v_texture_location = program->fragment_shader().v_texture_location();
1659 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1625 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
1660 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 1626 yuv_adj_location = program->fragment_shader().yuv_adj_location();
1661 alpha_location = program->fragment_shader().alpha_location(); 1627 alpha_location = program->fragment_shader().alpha_location();
1662 } 1628 }
1663 1629
1664 GLC(Context(), 1630 GLC(gl_,
1665 Context()->uniform2f(tex_scale_location, 1631 gl_->Uniform2f(tex_scale_location,
1666 quad->tex_scale.width(), 1632 quad->tex_scale.width(),
1667 quad->tex_scale.height())); 1633 quad->tex_scale.height()));
1668 GLC(Context(), Context()->uniform1i(y_texture_location, 1)); 1634 GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
1669 GLC(Context(), Context()->uniform1i(u_texture_location, 2)); 1635 GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
1670 GLC(Context(), Context()->uniform1i(v_texture_location, 3)); 1636 GLC(gl_, gl_->Uniform1i(v_texture_location, 3));
1671 if (use_alpha_plane) 1637 if (use_alpha_plane)
1672 GLC(Context(), Context()->uniform1i(a_texture_location, 4)); 1638 GLC(gl_, gl_->Uniform1i(a_texture_location, 4));
1673 1639
1674 // These values are magic numbers that are used in the transformation from YUV 1640 // These values are magic numbers that are used in the transformation from YUV
1675 // to RGB color values. They are taken from the following webpage: 1641 // to RGB color values. They are taken from the following webpage:
1676 // http://www.fourcc.org/fccyvrgb.php 1642 // http://www.fourcc.org/fccyvrgb.php
1677 float yuv_to_rgb[9] = { 1643 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f,
1678 1.164f, 1.164f, 1.164f, 1644 2.018f, 1.596f, -.813f, 0.0f, };
1679 0.0f, -.391f, 2.018f, 1645 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1680 1.596f, -.813f, 0.0f,
1681 };
1682 GLC(Context(),
1683 Context()->uniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1684 1646
1685 // These values map to 16, 128, and 128 respectively, and are computed 1647 // These values map to 16, 128, and 128 respectively, and are computed
1686 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). 1648 // as a fraction over 256 (e.g. 16 / 256 = 0.0625).
1687 // They are used in the YUV to RGBA conversion formula: 1649 // They are used in the YUV to RGBA conversion formula:
1688 // Y - 16 : Gives 16 values of head and footroom for overshooting 1650 // Y - 16 : Gives 16 values of head and footroom for overshooting
1689 // U - 128 : Turns unsigned U into signed U [-128,127] 1651 // U - 128 : Turns unsigned U into signed U [-128,127]
1690 // V - 128 : Turns unsigned V into signed V [-128,127] 1652 // V - 128 : Turns unsigned V into signed V [-128,127]
1691 float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, }; 1653 float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, };
1692 GLC(Context(), Context()->uniform3fv(yuv_adj_location, 1, yuv_adjust)); 1654 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
1693
1694 1655
1695 SetShaderOpacity(quad->opacity(), alpha_location); 1656 SetShaderOpacity(quad->opacity(), alpha_location);
1696 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 1657 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location);
1697 } 1658 }
1698 1659
1699 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 1660 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1700 const StreamVideoDrawQuad* quad) { 1661 const StreamVideoDrawQuad* quad) {
1701 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1662 SetBlendEnabled(quad->ShouldDrawWithBlending());
1702 1663
1703 static float gl_matrix[16]; 1664 static float gl_matrix[16];
1704 1665
1705 DCHECK(capabilities_.using_egl_image); 1666 DCHECK(capabilities_.using_egl_image);
1706 1667
1707 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1668 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1708 gl_, &highp_threshold_cache_, highp_threshold_min_, 1669 gl_,
1670 &highp_threshold_cache_,
1671 highp_threshold_min_,
1709 quad->shared_quad_state->visible_content_rect.bottom_right()); 1672 quad->shared_quad_state->visible_content_rect.bottom_right());
1710 1673
1711 const VideoStreamTextureProgram* program = 1674 const VideoStreamTextureProgram* program =
1712 GetVideoStreamTextureProgram(tex_coord_precision); 1675 GetVideoStreamTextureProgram(tex_coord_precision);
1713 SetUseProgram(program->program()); 1676 SetUseProgram(program->program());
1714 1677
1715 ToGLMatrix(&gl_matrix[0], quad->matrix); 1678 ToGLMatrix(&gl_matrix[0], quad->matrix);
1716 GLC(Context(), 1679 GLC(gl_,
1717 Context()->uniformMatrix4fv( 1680 gl_->UniformMatrix4fv(
1718 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); 1681 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix));
1719 1682
1720 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1683 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1721 quad->resource_id); 1684 quad->resource_id);
1722 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1685 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
1723 GLC(Context(), 1686 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1724 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1725 1687
1726 GLC(Context(), 1688 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1727 Context()->uniform1i(program->fragment_shader().sampler_location(), 0));
1728 1689
1729 SetShaderOpacity(quad->opacity(), 1690 SetShaderOpacity(quad->opacity(),
1730 program->fragment_shader().alpha_location()); 1691 program->fragment_shader().alpha_location());
1731 DrawQuadGeometry(frame, 1692 DrawQuadGeometry(frame,
1732 quad->quadTransform(), 1693 quad->quadTransform(),
1733 quad->rect, 1694 quad->rect,
1734 program->vertex_shader().matrix_location()); 1695 program->vertex_shader().matrix_location());
1735 } 1696 }
1736 1697
1737 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, 1698 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
1738 const PictureDrawQuad* quad) { 1699 const PictureDrawQuad* quad) {
1739 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || 1700 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() ||
1740 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { 1701 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) {
1741 on_demand_tile_raster_bitmap_.setConfig( 1702 on_demand_tile_raster_bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
1742 SkBitmap::kARGB_8888_Config, 1703 quad->texture_size.width(),
1743 quad->texture_size.width(), 1704 quad->texture_size.height());
1744 quad->texture_size.height());
1745 on_demand_tile_raster_bitmap_.allocPixels(); 1705 on_demand_tile_raster_bitmap_.allocPixels();
1746 1706
1747 if (on_demand_tile_raster_resource_id_) 1707 if (on_demand_tile_raster_resource_id_)
1748 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 1708 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1749 1709
1750 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 1710 on_demand_tile_raster_resource_id_ =
1751 quad->texture_size, 1711 resource_provider_->CreateGLTexture(quad->texture_size,
1752 GL_TEXTURE_2D, 1712 GL_TEXTURE_2D,
1753 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 1713 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
1754 GL_CLAMP_TO_EDGE, 1714 GL_CLAMP_TO_EDGE,
1755 ResourceProvider::TextureUsageAny, 1715 ResourceProvider::TextureUsageAny,
1756 quad->texture_format); 1716 quad->texture_format);
1757 } 1717 }
1758 1718
1759 SkBitmapDevice device(on_demand_tile_raster_bitmap_); 1719 SkBitmapDevice device(on_demand_tile_raster_bitmap_);
1760 SkCanvas canvas(&device); 1720 SkCanvas canvas(&device);
1761 1721
1762 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, 1722 quad->picture_pile->RasterToBitmap(
1763 quad->contents_scale, NULL); 1723 &canvas, quad->content_rect, quad->contents_scale, NULL);
1764 1724
1765 uint8_t* bitmap_pixels = NULL; 1725 uint8_t* bitmap_pixels = NULL;
1766 SkBitmap on_demand_tile_raster_bitmap_dest; 1726 SkBitmap on_demand_tile_raster_bitmap_dest;
1767 SkBitmap::Config config = SkBitmapConfig(quad->texture_format); 1727 SkBitmap::Config config = SkBitmapConfig(quad->texture_format);
1768 if (on_demand_tile_raster_bitmap_.getConfig() != config) { 1728 if (on_demand_tile_raster_bitmap_.getConfig() != config) {
1769 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest, 1729 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest,
1770 config); 1730 config);
1771 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 1731 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
1772 // bitmap data. This check will be removed once crbug.com/293728 is fixed. 1732 // bitmap data. This check will be removed once crbug.com/293728 is fixed.
1773 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4); 1733 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4);
1774 bitmap_pixels = reinterpret_cast<uint8_t*>( 1734 bitmap_pixels = reinterpret_cast<uint8_t*>(
1775 on_demand_tile_raster_bitmap_dest.getPixels()); 1735 on_demand_tile_raster_bitmap_dest.getPixels());
1776 } else { 1736 } else {
1777 bitmap_pixels = reinterpret_cast<uint8_t*>( 1737 bitmap_pixels =
1778 on_demand_tile_raster_bitmap_.getPixels()); 1738 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels());
1779 } 1739 }
1780 1740
1781 resource_provider_->SetPixels( 1741 resource_provider_->SetPixels(on_demand_tile_raster_resource_id_,
1782 on_demand_tile_raster_resource_id_, 1742 bitmap_pixels,
1783 bitmap_pixels, 1743 gfx::Rect(quad->texture_size),
1784 gfx::Rect(quad->texture_size), 1744 gfx::Rect(quad->texture_size),
1785 gfx::Rect(quad->texture_size), 1745 gfx::Vector2d());
1786 gfx::Vector2d());
1787 1746
1788 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 1747 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_);
1789 } 1748 }
1790 1749
1791 struct TextureProgramBinding { 1750 struct TextureProgramBinding {
1792 template <class Program> 1751 template <class Program>
1793 void Set(Program* program) { 1752 void Set(Program* program) {
1794 DCHECK(program); 1753 DCHECK(program);
1795 program_id = program->program(); 1754 program_id = program->program();
1796 sampler_location = program->fragment_shader().sampler_location(); 1755 sampler_location = program->fragment_shader().sampler_location();
(...skipping 24 matching lines...) Expand all
1821 if (draw_cache_.program_id == 0) 1780 if (draw_cache_.program_id == 0)
1822 return; 1781 return;
1823 1782
1824 // Set the correct blending mode. 1783 // Set the correct blending mode.
1825 SetBlendEnabled(draw_cache_.needs_blending); 1784 SetBlendEnabled(draw_cache_.needs_blending);
1826 1785
1827 // Bind the program to the GL state. 1786 // Bind the program to the GL state.
1828 SetUseProgram(draw_cache_.program_id); 1787 SetUseProgram(draw_cache_.program_id);
1829 1788
1830 // Bind the correct texture sampler location. 1789 // Bind the correct texture sampler location.
1831 GLC(Context(), Context()->uniform1i(draw_cache_.sampler_location, 0)); 1790 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
1832 1791
1833 // Assume the current active textures is 0. 1792 // Assume the current active textures is 0.
1834 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_, 1793 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_,
1835 draw_cache_.resource_id); 1794 draw_cache_.resource_id);
1836 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1795 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
1837 GLC(Context(), 1796 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id()));
1838 Context()->bindTexture(GL_TEXTURE_2D, locked_quad.texture_id()));
1839 1797
1840 COMPILE_ASSERT( 1798 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof)
1841 sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof) 1799 struct_is_densely_packed);
1842 struct_is_densely_packed);
1843 COMPILE_ASSERT( 1800 COMPILE_ASSERT(
1844 sizeof(Float16) == 16 * sizeof(float), // NOLINT(runtime/sizeof) 1801 sizeof(Float16) == 16 * sizeof(float), // NOLINT(runtime/sizeof)
1845 struct_is_densely_packed); 1802 struct_is_densely_packed);
1846 1803
1847 // Upload the tranforms for both points and uvs. 1804 // Upload the tranforms for both points and uvs.
1848 GLC(context_, 1805 GLC(gl_,
1849 context_->uniformMatrix4fv( 1806 gl_->UniformMatrix4fv(
1850 static_cast<int>(draw_cache_.matrix_location), 1807 static_cast<int>(draw_cache_.matrix_location),
1851 static_cast<int>(draw_cache_.matrix_data.size()), 1808 static_cast<int>(draw_cache_.matrix_data.size()),
1852 false, 1809 false,
1853 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()))); 1810 reinterpret_cast<float*>(&draw_cache_.matrix_data.front())));
1854 GLC(context_, 1811 GLC(gl_,
1855 context_->uniform4fv( 1812 gl_->Uniform4fv(
1856 static_cast<int>(draw_cache_.uv_xform_location), 1813 static_cast<int>(draw_cache_.uv_xform_location),
1857 static_cast<int>(draw_cache_.uv_xform_data.size()), 1814 static_cast<int>(draw_cache_.uv_xform_data.size()),
1858 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front()))); 1815 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front())));
1859 1816
1860 if (draw_cache_.background_color != SK_ColorTRANSPARENT) { 1817 if (draw_cache_.background_color != SK_ColorTRANSPARENT) {
1861 Float4 background_color = PremultipliedColor(draw_cache_.background_color); 1818 Float4 background_color = PremultipliedColor(draw_cache_.background_color);
1862 GLC(context_, 1819 GLC(gl_,
1863 context_->uniform4fv( 1820 gl_->Uniform4fv(
1864 draw_cache_.background_color_location, 1, background_color.data)); 1821 draw_cache_.background_color_location, 1, background_color.data));
1865 } 1822 }
1866 1823
1867 GLC(context_, 1824 GLC(gl_,
1868 context_->uniform1fv( 1825 gl_->Uniform1fv(
1869 static_cast<int>(draw_cache_.vertex_opacity_location), 1826 static_cast<int>(draw_cache_.vertex_opacity_location),
1870 static_cast<int>(draw_cache_.vertex_opacity_data.size()), 1827 static_cast<int>(draw_cache_.vertex_opacity_data.size()),
1871 static_cast<float*>(&draw_cache_.vertex_opacity_data.front()))); 1828 static_cast<float*>(&draw_cache_.vertex_opacity_data.front())));
1872 1829
1873 // Draw the quads! 1830 // Draw the quads!
1874 GLC(context_, 1831 GLC(gl_,
1875 context_->drawElements(GL_TRIANGLES, 1832 gl_->DrawElements(GL_TRIANGLES,
1876 6 * draw_cache_.matrix_data.size(), 1833 6 * draw_cache_.matrix_data.size(),
1877 GL_UNSIGNED_SHORT, 1834 GL_UNSIGNED_SHORT,
1878 0)); 1835 0));
1879 1836
1880 // Clear the cache. 1837 // Clear the cache.
1881 draw_cache_.program_id = 0; 1838 draw_cache_.program_id = 0;
1882 draw_cache_.uv_xform_data.resize(0); 1839 draw_cache_.uv_xform_data.resize(0);
1883 draw_cache_.vertex_opacity_data.resize(0); 1840 draw_cache_.vertex_opacity_data.resize(0);
1884 draw_cache_.matrix_data.resize(0); 1841 draw_cache_.matrix_data.resize(0);
1885 } 1842 }
1886 1843
1887 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, 1844 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
1888 const TextureDrawQuad* quad) { 1845 const TextureDrawQuad* quad) {
1889 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1846 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1890 gl_, &highp_threshold_cache_, highp_threshold_min_, 1847 gl_,
1848 &highp_threshold_cache_,
1849 highp_threshold_min_,
1891 quad->shared_quad_state->visible_content_rect.bottom_right()); 1850 quad->shared_quad_state->visible_content_rect.bottom_right());
1892 1851
1893 // Choose the correct texture program binding 1852 // Choose the correct texture program binding
1894 TexTransformTextureProgramBinding binding; 1853 TexTransformTextureProgramBinding binding;
1895 if (quad->premultiplied_alpha) { 1854 if (quad->premultiplied_alpha) {
1896 if (quad->background_color == SK_ColorTRANSPARENT) { 1855 if (quad->background_color == SK_ColorTRANSPARENT) {
1897 binding.Set(GetTextureProgram(tex_coord_precision)); 1856 binding.Set(GetTextureProgram(tex_coord_precision));
1898 } else { 1857 } else {
1899 binding.Set(GetTextureBackgroundProgram(tex_coord_precision)); 1858 binding.Set(GetTextureBackgroundProgram(tex_coord_precision));
1900 } 1859 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 Float16 m; 1904 Float16 m;
1946 quad_rect_matrix.matrix().asColMajorf(m.data); 1905 quad_rect_matrix.matrix().asColMajorf(m.data);
1947 draw_cache_.matrix_data.push_back(m); 1906 draw_cache_.matrix_data.push_back(m);
1948 } 1907 }
1949 1908
1950 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, 1909 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
1951 const IOSurfaceDrawQuad* quad) { 1910 const IOSurfaceDrawQuad* quad) {
1952 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1911 SetBlendEnabled(quad->ShouldDrawWithBlending());
1953 1912
1954 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1913 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1955 gl_, &highp_threshold_cache_, highp_threshold_min_, 1914 gl_,
1915 &highp_threshold_cache_,
1916 highp_threshold_min_,
1956 quad->shared_quad_state->visible_content_rect.bottom_right()); 1917 quad->shared_quad_state->visible_content_rect.bottom_right());
1957 1918
1958 TexTransformTextureProgramBinding binding; 1919 TexTransformTextureProgramBinding binding;
1959 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); 1920 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
1960 1921
1961 SetUseProgram(binding.program_id); 1922 SetUseProgram(binding.program_id);
1962 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); 1923 GLC(gl_, gl_->Uniform1i(binding.sampler_location, 0));
1963 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { 1924 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) {
1964 GLC(Context(), 1925 GLC(gl_,
1965 Context()->uniform4f(binding.tex_transform_location, 1926 gl_->Uniform4f(binding.tex_transform_location,
1966 0, 1927 0,
1967 quad->io_surface_size.height(), 1928 quad->io_surface_size.height(),
1968 quad->io_surface_size.width(), 1929 quad->io_surface_size.width(),
1969 quad->io_surface_size.height() * -1.0f)); 1930 quad->io_surface_size.height() * -1.0f));
1970 } else { 1931 } else {
1971 GLC(Context(), 1932 GLC(gl_,
1972 Context()->uniform4f(binding.tex_transform_location, 1933 gl_->Uniform4f(binding.tex_transform_location,
1973 0, 1934 0,
1974 0, 1935 0,
1975 quad->io_surface_size.width(), 1936 quad->io_surface_size.width(),
1976 quad->io_surface_size.height())); 1937 quad->io_surface_size.height()));
1977 } 1938 }
1978 1939
1979 const float vertex_opacity[] = { quad->opacity(), quad->opacity(), 1940 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
1980 quad->opacity(), quad->opacity() }; 1941 quad->opacity(), quad->opacity()};
1981 GLC(Context(), 1942 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
1982 Context()->uniform1fv(
1983 binding.vertex_opacity_location, 4, vertex_opacity));
1984 1943
1985 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1944 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1986 quad->io_surface_resource_id); 1945 quad->io_surface_resource_id);
1987 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1946 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
1988 GLC(Context(), 1947 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
1989 Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB,
1990 lock.texture_id()));
1991 1948
1992 DrawQuadGeometry( 1949 DrawQuadGeometry(
1993 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 1950 frame, quad->quadTransform(), quad->rect, binding.matrix_location);
1994 1951
1995 GLC(Context(), Context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 1952 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
1996 } 1953 }
1997 1954
1998 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 1955 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
1999 current_framebuffer_lock_.reset(); 1956 current_framebuffer_lock_.reset();
2000 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 1957 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2001 1958
2002 GLC(context_, context_->disable(GL_BLEND)); 1959 GLC(gl_, gl_->Disable(GL_BLEND));
2003 blend_shadow_ = false; 1960 blend_shadow_ = false;
2004 } 1961 }
2005 1962
2006 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } 1963 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); }
2007 1964
2008 bool GLRenderer::FlippedFramebuffer() const { return true; } 1965 bool GLRenderer::FlippedFramebuffer() const { return true; }
2009 1966
2010 void GLRenderer::EnsureScissorTestEnabled() { 1967 void GLRenderer::EnsureScissorTestEnabled() {
2011 if (is_scissor_enabled_) 1968 if (is_scissor_enabled_)
2012 return; 1969 return;
2013 1970
2014 FlushTextureQuadCache(); 1971 FlushTextureQuadCache();
2015 GLC(context_, context_->enable(GL_SCISSOR_TEST)); 1972 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
2016 is_scissor_enabled_ = true; 1973 is_scissor_enabled_ = true;
2017 } 1974 }
2018 1975
2019 void GLRenderer::EnsureScissorTestDisabled() { 1976 void GLRenderer::EnsureScissorTestDisabled() {
2020 if (!is_scissor_enabled_) 1977 if (!is_scissor_enabled_)
2021 return; 1978 return;
2022 1979
2023 FlushTextureQuadCache(); 1980 FlushTextureQuadCache();
2024 GLC(context_, context_->disable(GL_SCISSOR_TEST)); 1981 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
2025 is_scissor_enabled_ = false; 1982 is_scissor_enabled_ = false;
2026 } 1983 }
2027 1984
2028 void GLRenderer::CopyCurrentRenderPassToBitmap( 1985 void GLRenderer::CopyCurrentRenderPassToBitmap(
2029 DrawingFrame* frame, 1986 DrawingFrame* frame,
2030 scoped_ptr<CopyOutputRequest> request) { 1987 scoped_ptr<CopyOutputRequest> request) {
2031 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 1988 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2032 if (request->has_area()) 1989 if (request->has_area())
2033 copy_rect.Intersect(request->area()); 1990 copy_rect.Intersect(request->area());
2034 GetFramebufferPixelsAsync(copy_rect, request.Pass()); 1991 GetFramebufferPixelsAsync(copy_rect, request.Pass());
2035 } 1992 }
2036 1993
2037 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { 1994 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) {
2038 transform.matrix().asColMajorf(gl_matrix); 1995 transform.matrix().asColMajorf(gl_matrix);
2039 } 1996 }
2040 1997
2041 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) { 1998 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) {
2042 if (quad_location == -1) 1999 if (quad_location == -1)
2043 return; 2000 return;
2044 2001
2045 float gl_quad[8]; 2002 float gl_quad[8];
2046 gl_quad[0] = quad.p1().x(); 2003 gl_quad[0] = quad.p1().x();
2047 gl_quad[1] = quad.p1().y(); 2004 gl_quad[1] = quad.p1().y();
2048 gl_quad[2] = quad.p2().x(); 2005 gl_quad[2] = quad.p2().x();
2049 gl_quad[3] = quad.p2().y(); 2006 gl_quad[3] = quad.p2().y();
2050 gl_quad[4] = quad.p3().x(); 2007 gl_quad[4] = quad.p3().x();
2051 gl_quad[5] = quad.p3().y(); 2008 gl_quad[5] = quad.p3().y();
2052 gl_quad[6] = quad.p4().x(); 2009 gl_quad[6] = quad.p4().x();
2053 gl_quad[7] = quad.p4().y(); 2010 gl_quad[7] = quad.p4().y();
2054 GLC(context_, context_->uniform2fv(quad_location, 4, gl_quad)); 2011 GLC(gl_, gl_->Uniform2fv(quad_location, 4, gl_quad));
2055 } 2012 }
2056 2013
2057 void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) { 2014 void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) {
2058 if (alpha_location != -1) 2015 if (alpha_location != -1)
2059 GLC(context_, context_->uniform1f(alpha_location, opacity)); 2016 GLC(gl_, gl_->Uniform1f(alpha_location, opacity));
2060 } 2017 }
2061 2018
2062 void GLRenderer::SetStencilEnabled(bool enabled) { 2019 void GLRenderer::SetStencilEnabled(bool enabled) {
2063 if (enabled == stencil_shadow_) 2020 if (enabled == stencil_shadow_)
2064 return; 2021 return;
2065 2022
2066 if (enabled) 2023 if (enabled)
2067 GLC(context_, context_->enable(GL_STENCIL_TEST)); 2024 GLC(gl_, gl_->Enable(GL_STENCIL_TEST));
2068 else 2025 else
2069 GLC(context_, context_->disable(GL_STENCIL_TEST)); 2026 GLC(gl_, gl_->Disable(GL_STENCIL_TEST));
2070 stencil_shadow_ = enabled; 2027 stencil_shadow_ = enabled;
2071 } 2028 }
2072 2029
2073 void GLRenderer::SetBlendEnabled(bool enabled) { 2030 void GLRenderer::SetBlendEnabled(bool enabled) {
2074 if (enabled == blend_shadow_) 2031 if (enabled == blend_shadow_)
2075 return; 2032 return;
2076 2033
2077 if (enabled) 2034 if (enabled)
2078 GLC(context_, context_->enable(GL_BLEND)); 2035 GLC(gl_, gl_->Enable(GL_BLEND));
2079 else 2036 else
2080 GLC(context_, context_->disable(GL_BLEND)); 2037 GLC(gl_, gl_->Disable(GL_BLEND));
2081 blend_shadow_ = enabled; 2038 blend_shadow_ = enabled;
2082 } 2039 }
2083 2040
2084 void GLRenderer::SetUseProgram(unsigned program) { 2041 void GLRenderer::SetUseProgram(unsigned program) {
2085 if (program == program_shadow_) 2042 if (program == program_shadow_)
2086 return; 2043 return;
2087 gl_->UseProgram(program); 2044 gl_->UseProgram(program);
2088 program_shadow_ = program; 2045 program_shadow_ = program;
2089 } 2046 }
2090 2047
2091 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2048 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
2092 const gfx::Transform& draw_transform, 2049 const gfx::Transform& draw_transform,
2093 const gfx::RectF& quad_rect, 2050 const gfx::RectF& quad_rect,
2094 int matrix_location) { 2051 int matrix_location) {
2095 gfx::Transform quad_rect_matrix; 2052 gfx::Transform quad_rect_matrix;
2096 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2053 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2097 static float gl_matrix[16]; 2054 static float gl_matrix[16];
2098 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2055 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2099 GLC(context_, 2056 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2100 context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2101 2057
2102 GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 2058 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
2103 } 2059 }
2104 2060
2105 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, 2061 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
2106 int texture_id, 2062 int texture_id,
2107 gfx::Rect rect, 2063 gfx::Rect rect,
2108 const gfx::Transform& draw_matrix, 2064 const gfx::Transform& draw_matrix,
2109 bool flip_vertically) { 2065 bool flip_vertically) {
2110 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2066 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2111 gl_, &highp_threshold_cache_, highp_threshold_min_, 2067 gl_, &highp_threshold_cache_, highp_threshold_min_, rect.bottom_right());
2112 rect.bottom_right());
2113 2068
2114 const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision); 2069 const RenderPassProgram* program = GetRenderPassProgram(tex_coord_precision);
2115 SetUseProgram(program->program()); 2070 SetUseProgram(program->program());
2116 2071
2117 GLC(Context(), Context()->uniform1i( 2072 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
2118 program->fragment_shader().sampler_location(), 0));
2119 2073
2120 if (flip_vertically) { 2074 if (flip_vertically) {
2121 GLC(Context(), Context()->uniform4f( 2075 GLC(gl_,
2122 program->vertex_shader().tex_transform_location(), 2076 gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
2123 0.f, 2077 0.f,
2124 1.f, 2078 1.f,
2125 1.f, 2079 1.f,
2126 -1.f)); 2080 -1.f));
2127 } else { 2081 } else {
2128 GLC(Context(), Context()->uniform4f( 2082 GLC(gl_,
2129 program->vertex_shader().tex_transform_location(), 2083 gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
2130 0.f, 2084 0.f,
2131 0.f, 2085 0.f,
2132 1.f, 2086 1.f,
2133 1.f)); 2087 1.f));
2134 } 2088 }
2135 2089
2136 SetShaderOpacity(1.f, program->fragment_shader().alpha_location()); 2090 SetShaderOpacity(1.f, program->fragment_shader().alpha_location());
2137 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 2091 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context()));
2138 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); 2092 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
2139 DrawQuadGeometry( 2093 DrawQuadGeometry(
2140 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); 2094 frame, draw_matrix, rect, program->vertex_shader().matrix_location());
2141 } 2095 }
2142 2096
2143 void GLRenderer::Finish() { 2097 void GLRenderer::Finish() {
2144 TRACE_EVENT0("cc", "GLRenderer::Finish"); 2098 TRACE_EVENT0("cc", "GLRenderer::Finish");
2145 GLC(context_, context_->finish()); 2099 GLC(gl_, gl_->Finish());
2146 } 2100 }
2147 2101
2148 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { 2102 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
2149 DCHECK(visible_); 2103 DCHECK(visible_);
2150 DCHECK(!is_backbuffer_discarded_); 2104 DCHECK(!is_backbuffer_discarded_);
2151 2105
2152 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); 2106 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers");
2153 // We're done! Time to swapbuffers! 2107 // We're done! Time to swapbuffers!
2154 2108
2155 CompositorFrame compositor_frame; 2109 CompositorFrame compositor_frame;
2156 compositor_frame.metadata = metadata; 2110 compositor_frame.metadata = metadata;
2157 compositor_frame.gl_frame_data = make_scoped_ptr(new GLFrameData); 2111 compositor_frame.gl_frame_data = make_scoped_ptr(new GLFrameData);
2158 compositor_frame.gl_frame_data->size = output_surface_->SurfaceSize(); 2112 compositor_frame.gl_frame_data->size = output_surface_->SurfaceSize();
2159 if (capabilities_.using_partial_swap) { 2113 if (capabilities_.using_partial_swap) {
2160 // If supported, we can save significant bandwidth by only swapping the 2114 // If supported, we can save significant bandwidth by only swapping the
2161 // damaged/scissored region (clamped to the viewport) 2115 // damaged/scissored region (clamped to the viewport)
2162 swap_buffer_rect_.Intersect(client_->DeviceViewport()); 2116 swap_buffer_rect_.Intersect(client_->DeviceViewport());
2163 int flipped_y_pos_of_rect_bottom = 2117 int flipped_y_pos_of_rect_bottom = client_->DeviceViewport().height() -
2164 client_->DeviceViewport().height() - swap_buffer_rect_.y() - 2118 swap_buffer_rect_.y() -
2165 swap_buffer_rect_.height(); 2119 swap_buffer_rect_.height();
2166 compositor_frame.gl_frame_data->sub_buffer_rect = 2120 compositor_frame.gl_frame_data->sub_buffer_rect =
2167 gfx::Rect(swap_buffer_rect_.x(), 2121 gfx::Rect(swap_buffer_rect_.x(),
2168 flipped_y_pos_of_rect_bottom, 2122 flipped_y_pos_of_rect_bottom,
2169 swap_buffer_rect_.width(), 2123 swap_buffer_rect_.width(),
2170 swap_buffer_rect_.height()); 2124 swap_buffer_rect_.height());
2171 } else { 2125 } else {
2172 compositor_frame.gl_frame_data->sub_buffer_rect = 2126 compositor_frame.gl_frame_data->sub_buffer_rect =
2173 gfx::Rect(output_surface_->SurfaceSize()); 2127 gfx::Rect(output_surface_->SurfaceSize());
2174 } 2128 }
2175 output_surface_->SwapBuffers(&compositor_frame); 2129 output_surface_->SwapBuffers(&compositor_frame);
2176 2130
2177 swap_buffer_rect_ = gfx::Rect(); 2131 swap_buffer_rect_ = gfx::Rect();
2178 2132
2179 // We don't have real fences, so we mark read fences as passed 2133 // We don't have real fences, so we mark read fences as passed
2180 // assuming a double-buffered GPU pipeline. A texture can be 2134 // assuming a double-buffered GPU pipeline. A texture can be
2181 // written to after one full frame has past since it was last read. 2135 // written to after one full frame has past since it was last read.
2182 if (last_swap_fence_.get()) 2136 if (last_swap_fence_.get())
2183 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed(); 2137 static_cast<SimpleSwapFence*>(last_swap_fence_.get())->SetHasPassed();
2184 last_swap_fence_ = resource_provider_->GetReadLockFence(); 2138 last_swap_fence_ = resource_provider_->GetReadLockFence();
2185 resource_provider_->SetReadLockFence(new SimpleSwapFence()); 2139 resource_provider_->SetReadLockFence(new SimpleSwapFence());
2186 } 2140 }
2187 2141
2188 void GLRenderer::EnforceMemoryPolicy() { 2142 void GLRenderer::EnforceMemoryPolicy() {
2189 if (!visible_) { 2143 if (!visible_) {
2190 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); 2144 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
2191 ReleaseRenderPassTextures(); 2145 ReleaseRenderPassTextures();
2192 DiscardBackbuffer(); 2146 DiscardBackbuffer();
2193 resource_provider_->ReleaseCachedData(); 2147 resource_provider_->ReleaseCachedData();
2194 GLC(context_, context_->flush()); 2148 GLC(gl_, gl_->Flush());
2195 } 2149 }
2196 } 2150 }
2197 2151
2198 void GLRenderer::DiscardBackbuffer() { 2152 void GLRenderer::DiscardBackbuffer() {
2199 if (is_backbuffer_discarded_) 2153 if (is_backbuffer_discarded_)
2200 return; 2154 return;
2201 2155
2202 output_surface_->DiscardBackbuffer(); 2156 output_surface_->DiscardBackbuffer();
2203 2157
2204 is_backbuffer_discarded_ = true; 2158 is_backbuffer_discarded_ = true;
(...skipping 22 matching lines...) Expand all
2227 pending_read.Pass()); 2181 pending_read.Pass());
2228 2182
2229 // This is a syncronous call since the callback is null. 2183 // This is a syncronous call since the callback is null.
2230 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); 2184 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect);
2231 DoGetFramebufferPixels(static_cast<uint8*>(pixels), 2185 DoGetFramebufferPixels(static_cast<uint8*>(pixels),
2232 window_rect, 2186 window_rect,
2233 AsyncGetFramebufferPixelsCleanupCallback()); 2187 AsyncGetFramebufferPixelsCleanupCallback());
2234 } 2188 }
2235 2189
2236 void GLRenderer::GetFramebufferPixelsAsync( 2190 void GLRenderer::GetFramebufferPixelsAsync(
2237 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) { 2191 gfx::Rect rect,
2192 scoped_ptr<CopyOutputRequest> request) {
2238 DCHECK(!request->IsEmpty()); 2193 DCHECK(!request->IsEmpty());
2239 if (request->IsEmpty()) 2194 if (request->IsEmpty())
2240 return; 2195 return;
2241 if (rect.IsEmpty()) 2196 if (rect.IsEmpty())
2242 return; 2197 return;
2243 2198
2244 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); 2199 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect);
2245 2200
2246 if (!request->force_bitmap_result()) { 2201 if (!request->force_bitmap_result()) {
2247 bool own_mailbox = !request->has_texture_mailbox(); 2202 bool own_mailbox = !request->has_texture_mailbox();
2248 2203
2249 unsigned int texture_id = context_->createTexture(); 2204 GLuint texture_id = 0;
2205 gl_->GenTextures(1, &texture_id);
2250 2206
2251 gpu::Mailbox mailbox; 2207 gpu::Mailbox mailbox;
2252 if (own_mailbox) { 2208 if (own_mailbox) {
2253 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name)); 2209 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name));
2254 if (mailbox.IsZero()) { 2210 if (mailbox.IsZero()) {
2255 context_->deleteTexture(texture_id); 2211 gl_->DeleteTextures(1, &texture_id);
2256 request->SendEmptyResult(); 2212 request->SendEmptyResult();
2257 return; 2213 return;
2258 } 2214 }
2259 } else { 2215 } else {
2260 mailbox = request->texture_mailbox().name(); 2216 mailbox = request->texture_mailbox().name();
2261 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), 2217 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D),
2262 request->texture_mailbox().target()); 2218 request->texture_mailbox().target());
2263 DCHECK(!mailbox.IsZero()); 2219 DCHECK(!mailbox.IsZero());
2264 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); 2220 unsigned incoming_sync_point = request->texture_mailbox().sync_point();
2265 if (incoming_sync_point) 2221 if (incoming_sync_point)
2266 GLC(context_, context_->waitSyncPoint(incoming_sync_point)); 2222 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point));
2267 } 2223 }
2268 2224
2269 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2225 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
2270 if (own_mailbox) { 2226 if (own_mailbox) {
2271 GLC(context_, 2227 GLC(gl_,
2272 context_->texParameteri( 2228 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2273 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2229 GLC(gl_,
2274 GLC(context_, 2230 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2275 context_->texParameteri( 2231 GLC(gl_,
2276 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2232 gl_->TexParameteri(
2277 GLC(context_,
2278 context_->texParameteri(
2279 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2233 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2280 GLC(context_, 2234 GLC(gl_,
2281 context_->texParameteri( 2235 gl_->TexParameteri(
2282 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2236 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2283 GLC(context_, 2237 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2284 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2285 } else { 2238 } else {
2286 GLC(context_, 2239 GLC(gl_, gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2287 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2288 } 2240 }
2289 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); 2241 GetFramebufferTexture(texture_id, RGBA_8888, window_rect);
2290 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2242 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2291 2243
2292 unsigned sync_point = context_->insertSyncPoint(); 2244 unsigned sync_point = gl_->InsertSyncPointCHROMIUM();
2293 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); 2245 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point);
2294 2246
2295 scoped_ptr<SingleReleaseCallback> release_callback; 2247 scoped_ptr<SingleReleaseCallback> release_callback;
2296 if (own_mailbox) { 2248 if (own_mailbox) {
2297 release_callback = texture_mailbox_deleter_->GetReleaseCallback( 2249 release_callback = texture_mailbox_deleter_->GetReleaseCallback(
2298 output_surface_->context_provider(), texture_id); 2250 output_surface_->context_provider(), texture_id);
2299 } else { 2251 } else {
2300 context_->deleteTexture(texture_id); 2252 gl_->DeleteTextures(1, &texture_id);
2301 } 2253 }
2302 2254
2303 request->SendTextureResult(window_rect.size(), 2255 request->SendTextureResult(
2304 texture_mailbox, 2256 window_rect.size(), texture_mailbox, release_callback.Pass());
2305 release_callback.Pass());
2306 return; 2257 return;
2307 } 2258 }
2308 2259
2309 DCHECK(request->force_bitmap_result()); 2260 DCHECK(request->force_bitmap_result());
2310 2261
2311 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 2262 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
2312 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 2263 bitmap->setConfig(
2313 window_rect.width(), 2264 SkBitmap::kARGB_8888_Config, window_rect.width(), window_rect.height());
2314 window_rect.height());
2315 bitmap->allocPixels(); 2265 bitmap->allocPixels();
2316 2266
2317 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); 2267 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap));
2318 2268
2319 // Save a pointer to the pixels, the bitmap is owned by the cleanup_callback. 2269 // Save a pointer to the pixels, the bitmap is owned by the cleanup_callback.
2320 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 2270 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
2321 2271
2322 AsyncGetFramebufferPixelsCleanupCallback cleanup_callback = base::Bind( 2272 AsyncGetFramebufferPixelsCleanupCallback cleanup_callback =
2323 &GLRenderer::PassOnSkBitmap, 2273 base::Bind(&GLRenderer::PassOnSkBitmap,
2324 base::Unretained(this), 2274 base::Unretained(this),
2325 base::Passed(&bitmap), 2275 base::Passed(&bitmap),
2326 base::Passed(&lock)); 2276 base::Passed(&lock));
2327 2277
2328 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); 2278 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels);
2329 pending_read->copy_request = request.Pass(); 2279 pending_read->copy_request = request.Pass();
2330 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), 2280 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(),
2331 pending_read.Pass()); 2281 pending_read.Pass());
2332 2282
2333 // This is an asyncronous call since the callback is not null. 2283 // This is an asyncronous call since the callback is not null.
2334 DoGetFramebufferPixels(pixels, window_rect, cleanup_callback); 2284 DoGetFramebufferPixels(pixels, window_rect, cleanup_callback);
2335 } 2285 }
2336 2286
(...skipping 13 matching lines...) Expand all
2350 unsigned temporary_texture = 0; 2300 unsigned temporary_texture = 0;
2351 unsigned temporary_fbo = 0; 2301 unsigned temporary_fbo = 0;
2352 2302
2353 if (do_workaround) { 2303 if (do_workaround) {
2354 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment 2304 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment
2355 // is an IOSurface-backed texture causes corruption of future glReadPixels() 2305 // is an IOSurface-backed texture causes corruption of future glReadPixels()
2356 // calls, even those on different OpenGL contexts. It is believed that this 2306 // calls, even those on different OpenGL contexts. It is believed that this
2357 // is the root cause of top crasher 2307 // is the root cause of top crasher
2358 // http://crbug.com/99393. <rdar://problem/10949687> 2308 // http://crbug.com/99393. <rdar://problem/10949687>
2359 2309
2360 temporary_texture = context_->createTexture(); 2310 gl_->GenTextures(1, &temporary_texture);
2361 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture)); 2311 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, temporary_texture));
2362 GLC(context_, context_->texParameteri( 2312 GLC(gl_,
2363 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2313 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2364 GLC(context_, context_->texParameteri( 2314 GLC(gl_,
2365 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2315 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2366 GLC(context_, context_->texParameteri( 2316 GLC(gl_,
2367 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2317 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2368 GLC(context_, context_->texParameteri( 2318 GLC(gl_,
2369 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2319 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2370 // Copy the contents of the current (IOSurface-backed) framebuffer into a 2320 // Copy the contents of the current (IOSurface-backed) framebuffer into a
2371 // temporary texture. 2321 // temporary texture.
2372 GetFramebufferTexture(temporary_texture, 2322 GetFramebufferTexture(
2373 RGBA_8888, 2323 temporary_texture, RGBA_8888, gfx::Rect(current_surface_size_));
2374 gfx::Rect(current_surface_size_)); 2324 gl_->GenFramebuffers(1, &temporary_fbo);
2375 temporary_fbo = context_->createFramebuffer();
2376 // Attach this texture to an FBO, and perform the readback from that FBO. 2325 // Attach this texture to an FBO, and perform the readback from that FBO.
2377 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); 2326 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, temporary_fbo));
2378 GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER, 2327 GLC(gl_,
2379 GL_COLOR_ATTACHMENT0, 2328 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
2380 GL_TEXTURE_2D, 2329 GL_COLOR_ATTACHMENT0,
2381 temporary_texture, 2330 GL_TEXTURE_2D,
2382 0)); 2331 temporary_texture,
2332 0));
2383 2333
2384 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), 2334 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
2385 context_->checkFramebufferStatus(GL_FRAMEBUFFER)); 2335 gl_->CheckFramebufferStatus(GL_FRAMEBUFFER));
2386 } 2336 }
2387 2337
2388 unsigned buffer = context_->createBuffer(); 2338 GLuint buffer = 0;
2389 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2339 gl_->GenBuffers(1, &buffer);
2390 buffer)); 2340 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer));
2391 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2341 GLC(gl_,
2392 4 * window_rect.size().GetArea(), 2342 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
2393 NULL, 2343 4 * window_rect.size().GetArea(),
2394 GL_STREAM_READ)); 2344 NULL,
2345 GL_STREAM_READ));
2395 2346
2396 blink::WebGLId query = 0; 2347 GLuint query = 0;
2397 if (is_async) { 2348 if (is_async) {
2398 query = context_->createQueryEXT(); 2349 gl_->GenQueriesEXT(1, &query);
2399 GLC(context_, context_->beginQueryEXT( 2350 GLC(gl_, gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query));
2400 GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM,
2401 query));
2402 } 2351 }
2403 2352
2404 GLC(context_, 2353 GLC(gl_,
2405 context_->readPixels(window_rect.x(), 2354 gl_->ReadPixels(window_rect.x(),
2406 window_rect.y(), 2355 window_rect.y(),
2407 window_rect.width(), 2356 window_rect.width(),
2408 window_rect.height(), 2357 window_rect.height(),
2409 GL_RGBA, 2358 GL_RGBA,
2410 GL_UNSIGNED_BYTE, 2359 GL_UNSIGNED_BYTE,
2411 NULL)); 2360 NULL));
2412 2361
2413 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2362 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0));
2414 0));
2415 2363
2416 if (do_workaround) { 2364 if (do_workaround) {
2417 // Clean up. 2365 // Clean up.
2418 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); 2366 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
2419 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2367 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2420 GLC(context_, context_->deleteFramebuffer(temporary_fbo)); 2368 GLC(gl_, gl_->DeleteFramebuffers(1, &temporary_fbo));
2421 GLC(context_, context_->deleteTexture(temporary_texture)); 2369 GLC(gl_, gl_->DeleteTextures(1, &temporary_texture));
2422 } 2370 }
2423 2371
2424 base::Closure finished_callback = 2372 base::Closure finished_callback = base::Bind(&GLRenderer::FinishedReadback,
2425 base::Bind(&GLRenderer::FinishedReadback, 2373 base::Unretained(this),
2426 base::Unretained(this), 2374 cleanup_callback,
2427 cleanup_callback, 2375 buffer,
2428 buffer, 2376 query,
2429 query, 2377 dest_pixels,
2430 dest_pixels, 2378 window_rect.size());
2431 window_rect.size());
2432 // Save the finished_callback so it can be cancelled. 2379 // Save the finished_callback so it can be cancelled.
2433 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset( 2380 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset(
2434 finished_callback); 2381 finished_callback);
2435 2382
2436 // Save the buffer to verify the callbacks happen in the expected order. 2383 // Save the buffer to verify the callbacks happen in the expected order.
2437 pending_async_read_pixels_.front()->buffer = buffer; 2384 pending_async_read_pixels_.front()->buffer = buffer;
2438 2385
2439 if (is_async) { 2386 if (is_async) {
2440 GLC(context_, context_->endQueryEXT( 2387 GLC(gl_, gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM));
2441 GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM));
2442 context_support_->SignalQuery(query, finished_callback); 2388 context_support_->SignalQuery(query, finished_callback);
2443 } else { 2389 } else {
2444 resource_provider_->Finish(); 2390 resource_provider_->Finish();
2445 finished_callback.Run(); 2391 finished_callback.Run();
2446 } 2392 }
2447 2393
2448 EnforceMemoryPolicy(); 2394 EnforceMemoryPolicy();
2449 } 2395 }
2450 2396
2451 void GLRenderer::FinishedReadback( 2397 void GLRenderer::FinishedReadback(
2452 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback, 2398 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback,
2453 unsigned source_buffer, 2399 unsigned source_buffer,
2454 unsigned query, 2400 unsigned query,
2455 uint8* dest_pixels, 2401 uint8* dest_pixels,
2456 gfx::Size size) { 2402 gfx::Size size) {
2457 DCHECK(!pending_async_read_pixels_.empty()); 2403 DCHECK(!pending_async_read_pixels_.empty());
2458 2404
2459 if (query != 0) { 2405 if (query != 0) {
2460 GLC(context_, context_->deleteQueryEXT(query)); 2406 GLC(gl_, gl_->DeleteQueriesEXT(1, &query));
2461 } 2407 }
2462 2408
2463 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back(); 2409 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back();
2464 // Make sure we service the readbacks in order. 2410 // Make sure we service the readbacks in order.
2465 DCHECK_EQ(source_buffer, current_read->buffer); 2411 DCHECK_EQ(source_buffer, current_read->buffer);
2466 2412
2467 uint8* src_pixels = NULL; 2413 uint8* src_pixels = NULL;
2468 2414
2469 if (source_buffer != 0) { 2415 if (source_buffer != 0) {
2470 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2416 GLC(gl_,
2471 source_buffer)); 2417 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer));
2472 src_pixels = static_cast<uint8*>( 2418 src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM(
2473 context_->mapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2419 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
2474 GL_READ_ONLY));
2475 2420
2476 if (src_pixels) { 2421 if (src_pixels) {
2477 size_t row_bytes = size.width() * 4; 2422 size_t row_bytes = size.width() * 4;
2478 int num_rows = size.height(); 2423 int num_rows = size.height();
2479 size_t total_bytes = num_rows * row_bytes; 2424 size_t total_bytes = num_rows * row_bytes;
2480 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { 2425 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) {
2481 // Flip Y axis. 2426 // Flip Y axis.
2482 size_t src_y = total_bytes - dest_y - row_bytes; 2427 size_t src_y = total_bytes - dest_y - row_bytes;
2483 // Swizzle OpenGL -> Skia byte order. 2428 // Swizzle OpenGL -> Skia byte order.
2484 for (size_t x = 0; x < row_bytes; x += 4) { 2429 for (size_t x = 0; x < row_bytes; x += 4) {
2485 dest_pixels[dest_y + x + SK_R32_SHIFT/8] = src_pixels[src_y + x + 0]; 2430 dest_pixels[dest_y + x + SK_R32_SHIFT / 8] =
2486 dest_pixels[dest_y + x + SK_G32_SHIFT/8] = src_pixels[src_y + x + 1]; 2431 src_pixels[src_y + x + 0];
2487 dest_pixels[dest_y + x + SK_B32_SHIFT/8] = src_pixels[src_y + x + 2]; 2432 dest_pixels[dest_y + x + SK_G32_SHIFT / 8] =
2488 dest_pixels[dest_y + x + SK_A32_SHIFT/8] = src_pixels[src_y + x + 3]; 2433 src_pixels[src_y + x + 1];
2434 dest_pixels[dest_y + x + SK_B32_SHIFT / 8] =
2435 src_pixels[src_y + x + 2];
2436 dest_pixels[dest_y + x + SK_A32_SHIFT / 8] =
2437 src_pixels[src_y + x + 3];
2489 } 2438 }
2490 } 2439 }
2491 2440
2492 GLC(context_, context_->unmapBufferCHROMIUM( 2441 GLC(gl_,
2493 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM)); 2442 gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM));
2494 } 2443 }
2495 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2444 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0));
2496 0)); 2445 GLC(gl_, gl_->DeleteBuffers(1, &source_buffer));
2497 GLC(context_, context_->deleteBuffer(source_buffer));
2498 } 2446 }
2499 2447
2500 // TODO(danakj): This can go away when synchronous readback is no more and its 2448 // TODO(danakj): This can go away when synchronous readback is no more and its
2501 // contents can just move here. 2449 // contents can just move here.
2502 if (!cleanup_callback.is_null()) 2450 if (!cleanup_callback.is_null())
2503 cleanup_callback.Run(current_read->copy_request.Pass(), src_pixels != NULL); 2451 cleanup_callback.Run(current_read->copy_request.Pass(), src_pixels != NULL);
2504 2452
2505 pending_async_read_pixels_.pop_back(); 2453 pending_async_read_pixels_.pop_back();
2506 } 2454 }
2507 2455
2508 void GLRenderer::PassOnSkBitmap( 2456 void GLRenderer::PassOnSkBitmap(scoped_ptr<SkBitmap> bitmap,
2509 scoped_ptr<SkBitmap> bitmap, 2457 scoped_ptr<SkAutoLockPixels> lock,
2510 scoped_ptr<SkAutoLockPixels> lock, 2458 scoped_ptr<CopyOutputRequest> request,
2511 scoped_ptr<CopyOutputRequest> request, 2459 bool success) {
2512 bool success) {
2513 DCHECK(request->force_bitmap_result()); 2460 DCHECK(request->force_bitmap_result());
2514 2461
2515 lock.reset(); 2462 lock.reset();
2516 if (success) 2463 if (success)
2517 request->SendBitmapResult(bitmap.Pass()); 2464 request->SendBitmapResult(bitmap.Pass());
2518 } 2465 }
2519 2466
2520 void GLRenderer::GetFramebufferTexture( 2467 void GLRenderer::GetFramebufferTexture(unsigned texture_id,
2521 unsigned texture_id, ResourceFormat texture_format, gfx::Rect window_rect) { 2468 ResourceFormat texture_format,
2469 gfx::Rect window_rect) {
2522 DCHECK(texture_id); 2470 DCHECK(texture_id);
2523 DCHECK_GE(window_rect.x(), 0); 2471 DCHECK_GE(window_rect.x(), 0);
2524 DCHECK_GE(window_rect.y(), 0); 2472 DCHECK_GE(window_rect.y(), 0);
2525 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2473 DCHECK_LE(window_rect.right(), current_surface_size_.width());
2526 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); 2474 DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
2527 2475
2528 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2476 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
2529 GLC(context_, 2477 GLC(gl_,
2530 context_->copyTexImage2D( 2478 gl_->CopyTexImage2D(GL_TEXTURE_2D,
2531 GL_TEXTURE_2D, 2479 0,
2532 0, 2480 GLDataFormat(texture_format),
2533 GLDataFormat(texture_format), 2481 window_rect.x(),
2534 window_rect.x(), 2482 window_rect.y(),
2535 window_rect.y(), 2483 window_rect.width(),
2536 window_rect.width(), 2484 window_rect.height(),
2537 window_rect.height(), 2485 0));
2538 0)); 2486 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2539 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
2540 } 2487 }
2541 2488
2542 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, 2489 bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
2543 const ScopedResource* texture, 2490 const ScopedResource* texture,
2544 gfx::Rect viewport_rect) { 2491 gfx::Rect viewport_rect) {
2545 DCHECK(texture->id()); 2492 DCHECK(texture->id());
2546 frame->current_render_pass = NULL; 2493 frame->current_render_pass = NULL;
2547 frame->current_texture = texture; 2494 frame->current_texture = texture;
2548 2495
2549 return BindFramebufferToTexture(frame, texture, viewport_rect); 2496 return BindFramebufferToTexture(frame, texture, viewport_rect);
2550 } 2497 }
2551 2498
2552 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 2499 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
2553 current_framebuffer_lock_.reset(); 2500 current_framebuffer_lock_.reset();
2554 output_surface_->BindFramebuffer(); 2501 output_surface_->BindFramebuffer();
2555 2502
2556 if (output_surface_->HasExternalStencilTest()) { 2503 if (output_surface_->HasExternalStencilTest()) {
2557 SetStencilEnabled(true); 2504 SetStencilEnabled(true);
2558 GLC(context_, context_->stencilFunc(GL_EQUAL, 1, 1)); 2505 GLC(gl_, gl_->StencilFunc(GL_EQUAL, 1, 1));
2559 } else { 2506 } else {
2560 SetStencilEnabled(false); 2507 SetStencilEnabled(false);
2561 } 2508 }
2562 } 2509 }
2563 2510
2564 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, 2511 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
2565 const ScopedResource* texture, 2512 const ScopedResource* texture,
2566 gfx::Rect target_rect) { 2513 gfx::Rect target_rect) {
2567 DCHECK(texture->id()); 2514 DCHECK(texture->id());
2568 2515
2569 current_framebuffer_lock_.reset(); 2516 current_framebuffer_lock_.reset();
2570 2517
2571 SetStencilEnabled(false); 2518 SetStencilEnabled(false);
2572 GLC(context_, 2519 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_));
2573 context_->bindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_));
2574 current_framebuffer_lock_ = 2520 current_framebuffer_lock_ =
2575 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( 2521 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL(
2576 resource_provider_, texture->id())); 2522 resource_provider_, texture->id()));
2577 unsigned texture_id = current_framebuffer_lock_->texture_id(); 2523 unsigned texture_id = current_framebuffer_lock_->texture_id();
2578 GLC(context_, 2524 GLC(gl_,
2579 context_->framebufferTexture2D( 2525 gl_->FramebufferTexture2D(
2580 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); 2526 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0));
2581 2527
2582 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == 2528 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) ==
2583 GL_FRAMEBUFFER_COMPLETE || IsContextLost()); 2529 GL_FRAMEBUFFER_COMPLETE ||
2530 IsContextLost());
2584 2531
2585 InitializeViewport(frame, 2532 InitializeViewport(
2586 target_rect, 2533 frame, target_rect, gfx::Rect(target_rect.size()), target_rect.size());
2587 gfx::Rect(target_rect.size()),
2588 target_rect.size());
2589 return true; 2534 return true;
2590 } 2535 }
2591 2536
2592 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { 2537 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) {
2593 EnsureScissorTestEnabled(); 2538 EnsureScissorTestEnabled();
2594 2539
2595 // Don't unnecessarily ask the context to change the scissor, because it 2540 // Don't unnecessarily ask the context to change the scissor, because it
2596 // may cause undesired GPU pipeline flushes. 2541 // may cause undesired GPU pipeline flushes.
2597 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) 2542 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_)
2598 return; 2543 return;
2599 2544
2600 scissor_rect_ = scissor_rect; 2545 scissor_rect_ = scissor_rect;
2601 FlushTextureQuadCache(); 2546 FlushTextureQuadCache();
2602 GLC(context_, 2547 GLC(gl_,
2603 context_->scissor(scissor_rect.x(), 2548 gl_->Scissor(scissor_rect.x(),
2604 scissor_rect.y(), 2549 scissor_rect.y(),
2605 scissor_rect.width(), 2550 scissor_rect.width(),
2606 scissor_rect.height())); 2551 scissor_rect.height()));
2607 2552
2608 scissor_rect_needs_reset_ = false; 2553 scissor_rect_needs_reset_ = false;
2609 } 2554 }
2610 2555
2611 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { 2556 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {
2612 viewport_ = window_space_viewport; 2557 viewport_ = window_space_viewport;
2613 GLC(context_, context_->viewport(window_space_viewport.x(), 2558 GLC(gl_,
2614 window_space_viewport.y(), 2559 gl_->Viewport(window_space_viewport.x(),
2615 window_space_viewport.width(), 2560 window_space_viewport.y(),
2616 window_space_viewport.height())); 2561 window_space_viewport.width(),
2562 window_space_viewport.height()));
2617 } 2563 }
2618 2564
2619 void GLRenderer::InitializeSharedObjects() { 2565 void GLRenderer::InitializeSharedObjects() {
2620 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 2566 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2621 2567
2622 // Create an FBO for doing offscreen rendering. 2568 // Create an FBO for doing offscreen rendering.
2623 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); 2569 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
2624 2570
2625 shared_geometry_ = make_scoped_ptr( 2571 shared_geometry_ = make_scoped_ptr(
2626 new GeometryBinding(context_, QuadVertexRect())); 2572 new GeometryBinding(context_, QuadVertexRect()));
2627 } 2573 }
2628 2574
2629 const GLRenderer::TileCheckerboardProgram* 2575 const GLRenderer::TileCheckerboardProgram*
2630 GLRenderer::GetTileCheckerboardProgram() { 2576 GLRenderer::GetTileCheckerboardProgram() {
2631 if (!tile_checkerboard_program_.initialized()) { 2577 if (!tile_checkerboard_program_.initialized()) {
2632 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); 2578 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
2633 tile_checkerboard_program_.Initialize( 2579 tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
2634 output_surface_->context_provider(), 2580 TexCoordPrecisionNA,
2635 TexCoordPrecisionNA, 2581 SamplerTypeNA);
2636 SamplerTypeNA);
2637 } 2582 }
2638 return &tile_checkerboard_program_; 2583 return &tile_checkerboard_program_;
2639 } 2584 }
2640 2585
2641 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { 2586 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() {
2642 if (!debug_border_program_.initialized()) { 2587 if (!debug_border_program_.initialized()) {
2643 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); 2588 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize");
2644 debug_border_program_.Initialize( 2589 debug_border_program_.Initialize(output_surface_->context_provider(),
2645 output_surface_->context_provider(), 2590 TexCoordPrecisionNA,
2646 TexCoordPrecisionNA, 2591 SamplerTypeNA);
2647 SamplerTypeNA);
2648 } 2592 }
2649 return &debug_border_program_; 2593 return &debug_border_program_;
2650 } 2594 }
2651 2595
2652 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { 2596 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() {
2653 if (!solid_color_program_.initialized()) { 2597 if (!solid_color_program_.initialized()) {
2654 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); 2598 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize");
2655 solid_color_program_.Initialize( 2599 solid_color_program_.Initialize(output_surface_->context_provider(),
2656 output_surface_->context_provider(), 2600 TexCoordPrecisionNA,
2657 TexCoordPrecisionNA, 2601 SamplerTypeNA);
2658 SamplerTypeNA);
2659 } 2602 }
2660 return &solid_color_program_; 2603 return &solid_color_program_;
2661 } 2604 }
2662 2605
2663 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { 2606 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() {
2664 if (!solid_color_program_aa_.initialized()) { 2607 if (!solid_color_program_aa_.initialized()) {
2665 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); 2608 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize");
2666 solid_color_program_aa_.Initialize( 2609 solid_color_program_aa_.Initialize(output_surface_->context_provider(),
2667 output_surface_->context_provider(), 2610 TexCoordPrecisionNA,
2668 TexCoordPrecisionNA, 2611 SamplerTypeNA);
2669 SamplerTypeNA);
2670 } 2612 }
2671 return &solid_color_program_aa_; 2613 return &solid_color_program_aa_;
2672 } 2614 }
2673 2615
2674 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( 2616 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram(
2675 TexCoordPrecision precision) { 2617 TexCoordPrecision precision) {
2676 DCHECK_GE(precision, 0); 2618 DCHECK_GE(precision, 0);
2677 DCHECK_LT(precision, NumTexCoordPrecisions); 2619 DCHECK_LT(precision, NumTexCoordPrecisions);
2678 RenderPassProgram* program = &render_pass_program_[precision]; 2620 RenderPassProgram* program = &render_pass_program_[precision];
2679 if (!program->initialized()) { 2621 if (!program->initialized()) {
2680 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); 2622 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize");
2681 program->Initialize( 2623 program->Initialize(
2682 output_surface_->context_provider(), precision, SamplerType2D); 2624 output_surface_->context_provider(), precision, SamplerType2D);
2683 } 2625 }
2684 return program; 2626 return program;
2685 } 2627 }
2686 2628
2687 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( 2629 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
2688 TexCoordPrecision precision) { 2630 TexCoordPrecision precision) {
2689 DCHECK_GE(precision, 0); 2631 DCHECK_GE(precision, 0);
2690 DCHECK_LT(precision, NumTexCoordPrecisions); 2632 DCHECK_LT(precision, NumTexCoordPrecisions);
2691 RenderPassProgramAA* program = &render_pass_program_aa_[precision]; 2633 RenderPassProgramAA* program = &render_pass_program_aa_[precision];
2692 if (!program->initialized()) { 2634 if (!program->initialized()) {
2693 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); 2635 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize");
2694 program->Initialize( 2636 program->Initialize(
2695 output_surface_->context_provider(), precision, SamplerType2D); 2637 output_surface_->context_provider(), precision, SamplerType2D);
2696 } 2638 }
2697 return program; 2639 return program;
2698 } 2640 }
2699 2641
2700 const GLRenderer::RenderPassMaskProgram* 2642 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
2701 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { 2643 TexCoordPrecision precision) {
2702 DCHECK_GE(precision, 0); 2644 DCHECK_GE(precision, 0);
2703 DCHECK_LT(precision, NumTexCoordPrecisions); 2645 DCHECK_LT(precision, NumTexCoordPrecisions);
2704 RenderPassMaskProgram* program = &render_pass_mask_program_[precision]; 2646 RenderPassMaskProgram* program = &render_pass_mask_program_[precision];
2705 if (!program->initialized()) { 2647 if (!program->initialized()) {
2706 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); 2648 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize");
2707 program->Initialize( 2649 program->Initialize(
2708 output_surface_->context_provider(), precision, SamplerType2D); 2650 output_surface_->context_provider(), precision, SamplerType2D);
2709 } 2651 }
2710 return program; 2652 return program;
2711 } 2653 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 if (!program->initialized()) { 2718 if (!program->initialized()) {
2777 TRACE_EVENT0("cc", 2719 TRACE_EVENT0("cc",
2778 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); 2720 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize");
2779 program->Initialize( 2721 program->Initialize(
2780 output_surface_->context_provider(), precision, SamplerType2D); 2722 output_surface_->context_provider(), precision, SamplerType2D);
2781 } 2723 }
2782 return program; 2724 return program;
2783 } 2725 }
2784 2726
2785 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( 2727 const GLRenderer::TileProgram* GLRenderer::GetTileProgram(
2786 TexCoordPrecision precision, SamplerType sampler) { 2728 TexCoordPrecision precision,
2729 SamplerType sampler) {
2787 DCHECK_GE(precision, 0); 2730 DCHECK_GE(precision, 0);
2788 DCHECK_LT(precision, NumTexCoordPrecisions); 2731 DCHECK_LT(precision, NumTexCoordPrecisions);
2789 DCHECK_GE(sampler, 0); 2732 DCHECK_GE(sampler, 0);
2790 DCHECK_LT(sampler, NumSamplerTypes); 2733 DCHECK_LT(sampler, NumSamplerTypes);
2791 TileProgram* program = &tile_program_[precision][sampler]; 2734 TileProgram* program = &tile_program_[precision][sampler];
2792 if (!program->initialized()) { 2735 if (!program->initialized()) {
2793 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); 2736 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize");
2794 program->Initialize( 2737 program->Initialize(
2795 output_surface_->context_provider(), precision, sampler); 2738 output_surface_->context_provider(), precision, sampler);
2796 } 2739 }
2797 return program; 2740 return program;
2798 } 2741 }
2799 2742
2800 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( 2743 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque(
2801 TexCoordPrecision precision, SamplerType sampler) { 2744 TexCoordPrecision precision,
2745 SamplerType sampler) {
2802 DCHECK_GE(precision, 0); 2746 DCHECK_GE(precision, 0);
2803 DCHECK_LT(precision, NumTexCoordPrecisions); 2747 DCHECK_LT(precision, NumTexCoordPrecisions);
2804 DCHECK_GE(sampler, 0); 2748 DCHECK_GE(sampler, 0);
2805 DCHECK_LT(sampler, NumSamplerTypes); 2749 DCHECK_LT(sampler, NumSamplerTypes);
2806 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; 2750 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler];
2807 if (!program->initialized()) { 2751 if (!program->initialized()) {
2808 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); 2752 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize");
2809 program->Initialize( 2753 program->Initialize(
2810 output_surface_->context_provider(), precision, sampler); 2754 output_surface_->context_provider(), precision, sampler);
2811 } 2755 }
2812 return program; 2756 return program;
2813 } 2757 }
2814 2758
2815 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( 2759 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA(
2816 TexCoordPrecision precision, SamplerType sampler) { 2760 TexCoordPrecision precision,
2761 SamplerType sampler) {
2817 DCHECK_GE(precision, 0); 2762 DCHECK_GE(precision, 0);
2818 DCHECK_LT(precision, NumTexCoordPrecisions); 2763 DCHECK_LT(precision, NumTexCoordPrecisions);
2819 DCHECK_GE(sampler, 0); 2764 DCHECK_GE(sampler, 0);
2820 DCHECK_LT(sampler, NumSamplerTypes); 2765 DCHECK_LT(sampler, NumSamplerTypes);
2821 TileProgramAA* program = &tile_program_aa_[precision][sampler]; 2766 TileProgramAA* program = &tile_program_aa_[precision][sampler];
2822 if (!program->initialized()) { 2767 if (!program->initialized()) {
2823 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); 2768 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize");
2824 program->Initialize( 2769 program->Initialize(
2825 output_surface_->context_provider(), precision, sampler); 2770 output_surface_->context_provider(), precision, sampler);
2826 } 2771 }
2827 return program; 2772 return program;
2828 } 2773 }
2829 2774
2830 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( 2775 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle(
2831 TexCoordPrecision precision, SamplerType sampler) { 2776 TexCoordPrecision precision,
2777 SamplerType sampler) {
2832 DCHECK_GE(precision, 0); 2778 DCHECK_GE(precision, 0);
2833 DCHECK_LT(precision, NumTexCoordPrecisions); 2779 DCHECK_LT(precision, NumTexCoordPrecisions);
2834 DCHECK_GE(sampler, 0); 2780 DCHECK_GE(sampler, 0);
2835 DCHECK_LT(sampler, NumSamplerTypes); 2781 DCHECK_LT(sampler, NumSamplerTypes);
2836 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; 2782 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler];
2837 if (!program->initialized()) { 2783 if (!program->initialized()) {
2838 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); 2784 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize");
2839 program->Initialize( 2785 program->Initialize(
2840 output_surface_->context_provider(), precision, sampler); 2786 output_surface_->context_provider(), precision, sampler);
2841 } 2787 }
2842 return program; 2788 return program;
2843 } 2789 }
2844 2790
2845 const GLRenderer::TileProgramSwizzleOpaque* 2791 const GLRenderer::TileProgramSwizzleOpaque*
2846 GLRenderer::GetTileProgramSwizzleOpaque( 2792 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision,
2847 TexCoordPrecision precision, SamplerType sampler) { 2793 SamplerType sampler) {
2848 DCHECK_GE(precision, 0); 2794 DCHECK_GE(precision, 0);
2849 DCHECK_LT(precision, NumTexCoordPrecisions); 2795 DCHECK_LT(precision, NumTexCoordPrecisions);
2850 DCHECK_GE(sampler, 0); 2796 DCHECK_GE(sampler, 0);
2851 DCHECK_LT(sampler, NumSamplerTypes); 2797 DCHECK_LT(sampler, NumSamplerTypes);
2852 TileProgramSwizzleOpaque* program = 2798 TileProgramSwizzleOpaque* program =
2853 &tile_program_swizzle_opaque_[precision][sampler]; 2799 &tile_program_swizzle_opaque_[precision][sampler];
2854 if (!program->initialized()) { 2800 if (!program->initialized()) {
2855 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); 2801 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize");
2856 program->Initialize( 2802 program->Initialize(
2857 output_surface_->context_provider(), precision, sampler); 2803 output_surface_->context_provider(), precision, sampler);
2858 } 2804 }
2859 return program; 2805 return program;
2860 } 2806 }
2861 2807
2862 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( 2808 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA(
2863 TexCoordPrecision precision, SamplerType sampler) { 2809 TexCoordPrecision precision,
2810 SamplerType sampler) {
2864 DCHECK_GE(precision, 0); 2811 DCHECK_GE(precision, 0);
2865 DCHECK_LT(precision, NumTexCoordPrecisions); 2812 DCHECK_LT(precision, NumTexCoordPrecisions);
2866 DCHECK_GE(sampler, 0); 2813 DCHECK_GE(sampler, 0);
2867 DCHECK_LT(sampler, NumSamplerTypes); 2814 DCHECK_LT(sampler, NumSamplerTypes);
2868 TileProgramSwizzleAA* program = 2815 TileProgramSwizzleAA* program = &tile_program_swizzle_aa_[precision][sampler];
2869 &tile_program_swizzle_aa_[precision][sampler];
2870 if (!program->initialized()) { 2816 if (!program->initialized()) {
2871 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); 2817 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize");
2872 program->Initialize( 2818 program->Initialize(
2873 output_surface_->context_provider(), precision, sampler); 2819 output_surface_->context_provider(), precision, sampler);
2874 } 2820 }
2875 return program; 2821 return program;
2876 } 2822 }
2877 2823
2878 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( 2824 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram(
2879 TexCoordPrecision precision) { 2825 TexCoordPrecision precision) {
2880 DCHECK_GE(precision, 0); 2826 DCHECK_GE(precision, 0);
2881 DCHECK_LT(precision, NumTexCoordPrecisions); 2827 DCHECK_LT(precision, NumTexCoordPrecisions);
2882 TextureProgram* program = &texture_program_[precision]; 2828 TextureProgram* program = &texture_program_[precision];
2883 if (!program->initialized()) { 2829 if (!program->initialized()) {
2884 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); 2830 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize");
2885 program->Initialize( 2831 program->Initialize(
2886 output_surface_->context_provider(), precision, SamplerType2D); 2832 output_surface_->context_provider(), precision, SamplerType2D);
2887 } 2833 }
2888 return program; 2834 return program;
2889 } 2835 }
2890 2836
2891 const GLRenderer::NonPremultipliedTextureProgram* 2837 const GLRenderer::NonPremultipliedTextureProgram*
2892 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { 2838 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) {
2893 DCHECK_GE(precision, 0); 2839 DCHECK_GE(precision, 0);
2894 DCHECK_LT(precision, NumTexCoordPrecisions); 2840 DCHECK_LT(precision, NumTexCoordPrecisions);
2895 NonPremultipliedTextureProgram* program = 2841 NonPremultipliedTextureProgram* program =
2896 &nonpremultiplied_texture_program_[precision]; 2842 &nonpremultiplied_texture_program_[precision];
2897 if (!program->initialized()) { 2843 if (!program->initialized()) {
2898 TRACE_EVENT0("cc", 2844 TRACE_EVENT0("cc",
2899 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); 2845 "GLRenderer::NonPremultipliedTextureProgram::Initialize");
2900 program->Initialize( 2846 program->Initialize(
2901 output_surface_->context_provider(), precision, SamplerType2D); 2847 output_surface_->context_provider(), precision, SamplerType2D);
2902 } 2848 }
(...skipping 22 matching lines...) Expand all
2925 &nonpremultiplied_texture_background_program_[precision]; 2871 &nonpremultiplied_texture_background_program_[precision];
2926 if (!program->initialized()) { 2872 if (!program->initialized()) {
2927 TRACE_EVENT0("cc", 2873 TRACE_EVENT0("cc",
2928 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); 2874 "GLRenderer::NonPremultipliedTextureProgram::Initialize");
2929 program->Initialize( 2875 program->Initialize(
2930 output_surface_->context_provider(), precision, SamplerType2D); 2876 output_surface_->context_provider(), precision, SamplerType2D);
2931 } 2877 }
2932 return program; 2878 return program;
2933 } 2879 }
2934 2880
2935 const GLRenderer::TextureProgram* 2881 const GLRenderer::TextureProgram* GLRenderer::GetTextureIOSurfaceProgram(
2936 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { 2882 TexCoordPrecision precision) {
2937 DCHECK_GE(precision, 0); 2883 DCHECK_GE(precision, 0);
2938 DCHECK_LT(precision, NumTexCoordPrecisions); 2884 DCHECK_LT(precision, NumTexCoordPrecisions);
2939 TextureProgram* program = &texture_io_surface_program_[precision]; 2885 TextureProgram* program = &texture_io_surface_program_[precision];
2940 if (!program->initialized()) { 2886 if (!program->initialized()) {
2941 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); 2887 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize");
2942 program->Initialize( 2888 program->Initialize(
2943 output_surface_->context_provider(), precision, SamplerType2DRect); 2889 output_surface_->context_provider(), precision, SamplerType2DRect);
2944 } 2890 }
2945 return program; 2891 return program;
2946 } 2892 }
(...skipping 28 matching lines...) Expand all
2975 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { 2921 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) {
2976 if (!Capabilities().using_egl_image) 2922 if (!Capabilities().using_egl_image)
2977 return NULL; 2923 return NULL;
2978 DCHECK_GE(precision, 0); 2924 DCHECK_GE(precision, 0);
2979 DCHECK_LT(precision, NumTexCoordPrecisions); 2925 DCHECK_LT(precision, NumTexCoordPrecisions);
2980 VideoStreamTextureProgram* program = 2926 VideoStreamTextureProgram* program =
2981 &video_stream_texture_program_[precision]; 2927 &video_stream_texture_program_[precision];
2982 if (!program->initialized()) { 2928 if (!program->initialized()) {
2983 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); 2929 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize");
2984 program->Initialize( 2930 program->Initialize(
2985 output_surface_->context_provider(), 2931 output_surface_->context_provider(), precision, SamplerTypeExternalOES);
2986 precision,
2987 SamplerTypeExternalOES);
2988 } 2932 }
2989 return program; 2933 return program;
2990 } 2934 }
2991 2935
2992 void GLRenderer::CleanupSharedObjects() { 2936 void GLRenderer::CleanupSharedObjects() {
2993 shared_geometry_.reset(); 2937 shared_geometry_.reset();
2994 2938
2995 for (int i = 0; i < NumTexCoordPrecisions; ++i) { 2939 for (int i = 0; i < NumTexCoordPrecisions; ++i) {
2996 for (int j = 0; j < NumSamplerTypes; ++j) { 2940 for (int j = 0; j < NumSamplerTypes; ++j) {
2997 tile_program_[i][j].Cleanup(gl_); 2941 tile_program_[i][j].Cleanup(gl_);
(...skipping 24 matching lines...) Expand all
3022 video_stream_texture_program_[i].Cleanup(gl_); 2966 video_stream_texture_program_[i].Cleanup(gl_);
3023 } 2967 }
3024 2968
3025 tile_checkerboard_program_.Cleanup(gl_); 2969 tile_checkerboard_program_.Cleanup(gl_);
3026 2970
3027 debug_border_program_.Cleanup(gl_); 2971 debug_border_program_.Cleanup(gl_);
3028 solid_color_program_.Cleanup(gl_); 2972 solid_color_program_.Cleanup(gl_);
3029 solid_color_program_aa_.Cleanup(gl_); 2973 solid_color_program_aa_.Cleanup(gl_);
3030 2974
3031 if (offscreen_framebuffer_id_) 2975 if (offscreen_framebuffer_id_)
3032 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); 2976 GLC(gl_, gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_));
3033 2977
3034 if (on_demand_tile_raster_resource_id_) 2978 if (on_demand_tile_raster_resource_id_)
3035 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 2979 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
3036 2980
3037 ReleaseRenderPassTextures(); 2981 ReleaseRenderPassTextures();
3038 } 2982 }
3039 2983
3040 void GLRenderer::ReinitializeGLState() { 2984 void GLRenderer::ReinitializeGLState() {
3041 // Bind the common vertex attributes used for drawing all the layers. 2985 // Bind the common vertex attributes used for drawing all the layers.
3042 shared_geometry_->PrepareForDraw(); 2986 shared_geometry_->PrepareForDraw();
3043 2987
3044 GLC(context_, context_->disable(GL_DEPTH_TEST)); 2988 GLC(gl_, gl_->Disable(GL_DEPTH_TEST));
3045 GLC(context_, context_->disable(GL_CULL_FACE)); 2989 GLC(gl_, gl_->Disable(GL_CULL_FACE));
3046 GLC(context_, context_->colorMask(true, true, true, true)); 2990 GLC(gl_, gl_->ColorMask(true, true, true, true));
3047 GLC(context_, context_->disable(GL_STENCIL_TEST)); 2991 GLC(gl_, gl_->Disable(GL_STENCIL_TEST));
3048 stencil_shadow_ = false; 2992 stencil_shadow_ = false;
3049 GLC(context_, context_->enable(GL_BLEND)); 2993 GLC(gl_, gl_->Enable(GL_BLEND));
3050 blend_shadow_ = true; 2994 blend_shadow_ = true;
3051 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 2995 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
3052 GLC(context_, context_->activeTexture(GL_TEXTURE0)); 2996 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
3053 program_shadow_ = 0; 2997 program_shadow_ = 0;
3054 2998
3055 // Make sure scissoring starts as disabled. 2999 // Make sure scissoring starts as disabled.
3056 is_scissor_enabled_ = false; 3000 is_scissor_enabled_ = false;
3057 GLC(context_, context_->disable(GL_SCISSOR_TEST)); 3001 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
3058 scissor_rect_needs_reset_ = true; 3002 scissor_rect_needs_reset_ = true;
3059 } 3003 }
3060 3004
3061 bool GLRenderer::IsContextLost() { 3005 bool GLRenderer::IsContextLost() {
3062 return output_surface_->context_provider()->IsContextLost(); 3006 return output_surface_->context_provider()->IsContextLost();
3063 } 3007 }
3064 3008
3065 } // namespace cc 3009 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698