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

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

Issue 595593002: Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/debug/stack_trace.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h"
20 #include "build/build_config.h"
15 #include "cc/base/math_util.h" 21 #include "cc/base/math_util.h"
16 #include "cc/layers/video_layer_impl.h" 22 #include "cc/layers/video_layer_impl.h"
17 #include "cc/output/compositor_frame.h" 23 #include "cc/output/compositor_frame.h"
18 #include "cc/output/compositor_frame_metadata.h" 24 #include "cc/output/compositor_frame_metadata.h"
19 #include "cc/output/context_provider.h" 25 #include "cc/output/context_provider.h"
20 #include "cc/output/copy_output_request.h" 26 #include "cc/output/copy_output_request.h"
21 #include "cc/output/geometry_binding.h" 27 #include "cc/output/geometry_binding.h"
22 #include "cc/output/gl_frame_data.h" 28 #include "cc/output/gl_frame_data.h"
23 #include "cc/output/output_surface.h" 29 #include "cc/output/output_surface.h"
24 #include "cc/output/render_surface_filters.h" 30 #include "cc/output/render_surface_filters.h"
25 #include "cc/quads/picture_draw_quad.h" 31 #include "cc/quads/picture_draw_quad.h"
26 #include "cc/quads/render_pass.h" 32 #include "cc/quads/render_pass.h"
27 #include "cc/quads/stream_video_draw_quad.h" 33 #include "cc/quads/stream_video_draw_quad.h"
34 #include "cc/quads/draw_polygon.h"
28 #include "cc/quads/texture_draw_quad.h" 35 #include "cc/quads/texture_draw_quad.h"
29 #include "cc/resources/layer_quad.h" 36 #include "cc/resources/layer_quad.h"
30 #include "cc/resources/scoped_resource.h" 37 #include "cc/resources/scoped_resource.h"
31 #include "cc/resources/texture_mailbox_deleter.h" 38 #include "cc/resources/texture_mailbox_deleter.h"
32 #include "gpu/GLES2/gl2extchromium.h" 39 #include "gpu/GLES2/gl2extchromium.h"
33 #include "gpu/command_buffer/client/context_support.h" 40 #include "gpu/command_buffer/client/context_support.h"
34 #include "gpu/command_buffer/client/gles2_interface.h" 41 #include "gpu/command_buffer/client/gles2_interface.h"
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 42 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 43 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "third_party/skia/include/core/SkColor.h" 44 #include "third_party/skia/include/core/SkColor.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 482
476 // TODO(enne): Do we need to reinitialize all of this state per frame? 483 // TODO(enne): Do we need to reinitialize all of this state per frame?
477 ReinitializeGLState(); 484 ReinitializeGLState();
478 } 485 }
479 486
480 void GLRenderer::DoNoOp() { 487 void GLRenderer::DoNoOp() {
481 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 488 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
482 GLC(gl_, gl_->Flush()); 489 GLC(gl_, gl_->Flush());
483 } 490 }
484 491
485 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { 492 void GLRenderer::DoDrawQuad(DrawingFrame* frame,
493 const DrawQuad* quad,
494 const gfx::QuadF* draw_region) {
486 DCHECK(quad->rect.Contains(quad->visible_rect)); 495 DCHECK(quad->rect.Contains(quad->visible_rect));
487 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 496 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
488 FlushTextureQuadCache(); 497 FlushTextureQuadCache(false);
489 } 498 }
490 499
491 switch (quad->material) { 500 switch (quad->material) {
492 case DrawQuad::INVALID: 501 case DrawQuad::INVALID:
493 NOTREACHED(); 502 NOTREACHED();
494 break; 503 break;
495 case DrawQuad::CHECKERBOARD: 504 case DrawQuad::CHECKERBOARD:
496 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); 505 DrawCheckerboardQuad(
506 frame, CheckerboardDrawQuad::MaterialCast(quad), draw_region);
497 break; 507 break;
498 case DrawQuad::DEBUG_BORDER: 508 case DrawQuad::DEBUG_BORDER:
499 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); 509 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad));
500 break; 510 break;
501 case DrawQuad::IO_SURFACE_CONTENT: 511 case DrawQuad::IO_SURFACE_CONTENT:
502 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); 512 DrawIOSurfaceQuad(
513 frame, IOSurfaceDrawQuad::MaterialCast(quad), draw_region);
503 break; 514 break;
504 case DrawQuad::PICTURE_CONTENT: 515 case DrawQuad::PICTURE_CONTENT:
505 DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad)); 516 DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad), draw_region);
506 break; 517 break;
507 case DrawQuad::RENDER_PASS: 518 case DrawQuad::RENDER_PASS:
508 DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); 519 DrawRenderPassQuad(
520 frame, RenderPassDrawQuad::MaterialCast(quad), draw_region);
509 break; 521 break;
510 case DrawQuad::SOLID_COLOR: 522 case DrawQuad::SOLID_COLOR:
511 DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad)); 523 DrawSolidColorQuad(
524 frame, SolidColorDrawQuad::MaterialCast(quad), draw_region);
512 break; 525 break;
513 case DrawQuad::STREAM_VIDEO_CONTENT: 526 case DrawQuad::STREAM_VIDEO_CONTENT:
514 DrawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad)); 527 DrawStreamVideoQuad(
528 frame, StreamVideoDrawQuad::MaterialCast(quad), draw_region);
515 break; 529 break;
516 case DrawQuad::SURFACE_CONTENT: 530 case DrawQuad::SURFACE_CONTENT:
517 // Surface content should be fully resolved to other quad types before 531 // Surface content should be fully resolved to other quad types before
518 // reaching a direct renderer. 532 // reaching a direct renderer.
519 NOTREACHED(); 533 NOTREACHED();
520 break; 534 break;
521 case DrawQuad::TEXTURE_CONTENT: 535 case DrawQuad::TEXTURE_CONTENT:
522 EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); 536 EnqueueTextureQuad(
537 frame, TextureDrawQuad::MaterialCast(quad), draw_region);
523 break; 538 break;
524 case DrawQuad::TILED_CONTENT: 539 case DrawQuad::TILED_CONTENT:
525 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); 540 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad), draw_region);
526 break; 541 break;
527 case DrawQuad::YUV_VIDEO_CONTENT: 542 case DrawQuad::YUV_VIDEO_CONTENT:
528 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); 543 DrawYUVVideoQuad(
544 frame, YUVVideoDrawQuad::MaterialCast(quad), draw_region);
529 break; 545 break;
530 } 546 }
531 } 547 }
532 548
533 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame, 549 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
534 const CheckerboardDrawQuad* quad) { 550 const CheckerboardDrawQuad* quad,
551 const gfx::QuadF* clip_region) {
552 // TODO(thildebr) For now since checkerboards shouldn't be part of a 3D
553 // context, clipping regions aren't supported so we skip drawing them
554 // if this becomes the case.
555 if (clip_region) {
556 return;
557 }
535 SetBlendEnabled(quad->ShouldDrawWithBlending()); 558 SetBlendEnabled(quad->ShouldDrawWithBlending());
536 559
537 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); 560 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
538 DCHECK(program && (program->initialized() || IsContextLost())); 561 DCHECK(program && (program->initialized() || IsContextLost()));
539 SetUseProgram(program->program()); 562 SetUseProgram(program->program());
540 563
541 SkColor color = quad->color; 564 SkColor color = quad->color;
542 GLC(gl_, 565 GLC(gl_,
543 gl_->Uniform4f(program->fragment_shader().color_location(), 566 gl_->Uniform4f(program->fragment_shader().color_location(),
544 SkColorGetR(color) * (1.0f / 255.0f), 567 SkColorGetR(color) * (1.0f / 255.0f),
(...skipping 21 matching lines...) Expand all
566 frequency)); 589 frequency));
567 590
568 SetShaderOpacity(quad->opacity(), 591 SetShaderOpacity(quad->opacity(),
569 program->fragment_shader().alpha_location()); 592 program->fragment_shader().alpha_location());
570 DrawQuadGeometry(frame, 593 DrawQuadGeometry(frame,
571 quad->quadTransform(), 594 quad->quadTransform(),
572 quad->rect, 595 quad->rect,
573 program->vertex_shader().matrix_location()); 596 program->vertex_shader().matrix_location());
574 } 597 }
575 598
599 // This function does not handle 3D sorting right now, since the debug border
600 // quads are just drawn as their original quads and not in split pieces. This
601 // results in some debug border quads drawing over foreground quads.
576 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 602 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
577 const DebugBorderDrawQuad* quad) { 603 const DebugBorderDrawQuad* quad) {
578 SetBlendEnabled(quad->ShouldDrawWithBlending()); 604 SetBlendEnabled(quad->ShouldDrawWithBlending());
579 605
580 static float gl_matrix[16]; 606 static float gl_matrix[16];
581 const DebugBorderProgram* program = GetDebugBorderProgram(); 607 const DebugBorderProgram* program = GetDebugBorderProgram();
582 DCHECK(program && (program->initialized() || IsContextLost())); 608 DCHECK(program && (program->initialized() || IsContextLost()));
583 SetUseProgram(program->program()); 609 SetUseProgram(program->program());
584 610
585 // Use the full quad_rect for debug quads to not move the edges based on 611 // Use the full quad_rect for debug quads to not move the edges based on
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 } 971 }
946 972
947 UseRenderPass(frame, target_render_pass); 973 UseRenderPass(frame, target_render_pass);
948 974
949 if (!using_background_texture) 975 if (!using_background_texture)
950 return scoped_ptr<ScopedResource>(); 976 return scoped_ptr<ScopedResource>();
951 return background_texture.Pass(); 977 return background_texture.Pass();
952 } 978 }
953 979
954 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 980 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
955 const RenderPassDrawQuad* quad) { 981 const RenderPassDrawQuad* quad,
982 const gfx::QuadF* clip_region) {
956 SetBlendEnabled(quad->ShouldDrawWithBlending()); 983 SetBlendEnabled(quad->ShouldDrawWithBlending());
957 984
958 ScopedResource* contents_texture = 985 ScopedResource* contents_texture =
959 render_pass_textures_.get(quad->render_pass_id); 986 render_pass_textures_.get(quad->render_pass_id);
960 if (!contents_texture || !contents_texture->id()) 987 if (!contents_texture || !contents_texture->id())
961 return; 988 return;
962 989
963 gfx::Transform quad_rect_matrix; 990 gfx::Transform quad_rect_matrix;
964 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 991 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
965 gfx::Transform contents_device_transform = 992 gfx::Transform contents_device_transform =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 bool flip_vertically = true; 1078 bool flip_vertically = true;
1052 1079
1053 CopyTextureToFramebuffer(frame, 1080 CopyTextureToFramebuffer(frame,
1054 lock.texture_id(), 1081 lock.texture_id(),
1055 quad->rect, 1082 quad->rect,
1056 quad->quadTransform(), 1083 quad->quadTransform(),
1057 flip_vertically); 1084 flip_vertically);
1058 } 1085 }
1059 1086
1060 bool clipped = false; 1087 bool clipped = false;
1061 gfx::QuadF device_quad = MathUtil::MapQuad( 1088 // The idea here is to scale the clip_region down to the 1.0x1.0 quad with
1062 contents_device_transform, SharedGeometryQuad(), &clipped); 1089 // a top corner of -0.5,-0.5 to match the ShaderGeometryQuad(). Unfortunately
1090 // doesn't work properly yet.
1091 gfx::QuadF local_clip_region = SharedGeometryQuad();
1092 if (clip_region) {
1093 gfx::RectF content_rect(quad->shared_quad_state->content_bounds);
enne (OOO) 2014/09/24 17:35:30 I'm not sure I understand why this is needed. Als
1094 // Scale this quad down to within the bounds of the SharedGeometryQuad
1095 gfx::PointF p1((clip_region->p1().x() / content_rect.width()) - 0.5f,
1096 (clip_region->p1().y() / content_rect.height()) - 0.5f);
1097 gfx::PointF p2((clip_region->p2().x() / content_rect.width()) - 0.5f,
1098 (clip_region->p2().y() / content_rect.height()) - 0.5f);
1099 gfx::PointF p3((clip_region->p3().x() / content_rect.width()) - 0.5f,
1100 (clip_region->p3().y() / content_rect.height()) - 0.5f);
1101 gfx::PointF p4((clip_region->p4().x() / content_rect.width()) - 0.5f,
1102 (clip_region->p4().y() / content_rect.height()) - 0.5f);
1103 local_clip_region = gfx::QuadF(p1, p2, p3, p4);
1104 }
1105 gfx::QuadF device_quad =
1106 MathUtil::MapQuad(contents_device_transform, local_clip_region, &clipped);
1063 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox())); 1107 LayerQuad device_layer_bounds(gfx::QuadF(device_quad.BoundingBox()));
1064 LayerQuad device_layer_edges(device_quad); 1108 LayerQuad device_layer_edges(device_quad);
1065 1109
1066 // Use anti-aliasing programs only when necessary. 1110 // Use anti-aliasing programs only when necessary.
1067 bool use_aa = 1111 bool use_aa =
1068 !clipped && (!device_quad.IsRectilinear() || 1112 !clipped && (!device_quad.IsRectilinear() ||
1069 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(), 1113 !gfx::IsNearestRectWithinDistance(device_quad.BoundingBox(),
1070 kAntiAliasingEpsilon)); 1114 kAntiAliasingEpsilon));
1071 if (use_aa) { 1115 if (use_aa) {
1072 device_layer_bounds.InflateAntiAliasingDistance(); 1116 device_layer_bounds.InflateAntiAliasingDistance();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 static void SolidColorUniformLocation(T program, 1402 static void SolidColorUniformLocation(T program,
1359 SolidColorProgramUniforms* uniforms) { 1403 SolidColorProgramUniforms* uniforms) {
1360 uniforms->program = program->program(); 1404 uniforms->program = program->program();
1361 uniforms->matrix_location = program->vertex_shader().matrix_location(); 1405 uniforms->matrix_location = program->vertex_shader().matrix_location();
1362 uniforms->viewport_location = program->vertex_shader().viewport_location(); 1406 uniforms->viewport_location = program->vertex_shader().viewport_location();
1363 uniforms->quad_location = program->vertex_shader().quad_location(); 1407 uniforms->quad_location = program->vertex_shader().quad_location();
1364 uniforms->edge_location = program->vertex_shader().edge_location(); 1408 uniforms->edge_location = program->vertex_shader().edge_location();
1365 uniforms->color_location = program->fragment_shader().color_location(); 1409 uniforms->color_location = program->fragment_shader().color_location();
1366 } 1410 }
1367 1411
1412 // This function works in layer space to expand the split resulting quads needed
1413 // for sorting so that they "fill out" towards the edges for the AA that's
1414 // performed within the shaders. It makes sure to grow each sub-quad that
1415 // makes up the original quad by linearly interpolating points out torwards the
1416 // edges.
1417 static void ExpandDrawRegionToAAQuad(const gfx::QuadF& original_quad,
1418 const gfx::QuadF& aa_quad,
1419 gfx::QuadF* draw_region) {
1420 gfx::PointF region_points[] = {draw_region->p1(), draw_region->p2(),
1421 draw_region->p3(), draw_region->p4()};
1422
1423 // We find the bounding box of the original quad and the inflated AA quad
1424 // that was developed by SetupQuadForAntiAliasing.
1425 gfx::RectF original_rect = original_quad.BoundingBox();
1426 gfx::RectF aa_rect = aa_quad.BoundingBox();
1427
1428 // For all 4 of the draw region points, we find the factor from 0.0 to 1.0
1429 // of the X, Y values of the region points within the original quad. Since
1430 // the region quad lives within the boundaries of the original quad instead
1431 // of the AA quad, we need to inflate the values to match those of the AA
1432 // quad, so we apply the same factor, instead to the AA quad, to achieve the
1433 // new draw region points.
1434 // The |delta| values are just the width and height of the quads, and we
1435 // divide the x, y values we get by these to get them normalized from 0.0
1436 // to 1.0.
1437 float min_x = original_rect.x();
1438 float min_y = original_rect.y();
1439 float delta_x = original_rect.width();
1440 float delta_y = original_rect.height();
1441 float min_aa_x = aa_rect.x();
1442 float min_aa_y = aa_rect.y();
1443 float delta_aa_x = aa_rect.width();
1444 float delta_aa_y = aa_rect.height();
1445
1446 // Here we loop through the 4 vertices of the draw region and apply the
1447 // scaling that we get from x / delta_x, y / delta_y on the original quad
1448 // and apply those factors to delta_aa_x and delta_aa_y to get our final
1449 // points.
1450 for (int i = 0; i < 4; i++) {
1451 float x_factor = 0.0f;
1452 float y_factor = 0.0f;
1453 if (delta_x != 0.0f)
1454 x_factor = (region_points[i].x() - min_x) / delta_x;
1455 if (delta_y != 0.0f)
1456 y_factor = (region_points[i].y() - min_y) / delta_y;
1457 region_points[i].set_x(min_aa_x + (delta_aa_x * x_factor));
1458 region_points[i].set_y(min_aa_y + (delta_aa_y * y_factor));
1459 }
1460
1461 *draw_region = gfx::QuadF(
1462 region_points[0], region_points[1], region_points[2], region_points[3]);
1463 }
1464
1368 // static 1465 // static
1369 bool GLRenderer::SetupQuadForAntialiasing( 1466 bool GLRenderer::SetupQuadForAntialiasing(
1370 const gfx::Transform& device_transform, 1467 const gfx::Transform& device_transform,
1371 const DrawQuad* quad, 1468 const DrawQuad* quad,
1372 gfx::QuadF* local_quad, 1469 gfx::QuadF* local_quad,
1373 float edge[24]) { 1470 float edge[24]) {
1374 gfx::Rect tile_rect = quad->visible_rect; 1471 gfx::Rect tile_rect = quad->visible_rect;
1375 1472
1376 bool clipped = false; 1473 bool clipped = false;
1377 gfx::QuadF device_layer_quad = MathUtil::MapQuad( 1474 gfx::QuadF device_layer_quad = MathUtil::MapQuad(
1378 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped); 1475 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped);
1379 1476
1477 // The 2d BoundingBox of the quad may still be empty even if the quad
1478 // was not clipped (if the plane is edge-on for example).
1479 if (device_layer_quad.BoundingBox().IsEmpty()) {
1480 return false;
1481 }
1482
1380 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear(); 1483 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear();
1381 bool is_nearest_rect_within_epsilon = 1484 bool is_nearest_rect_within_epsilon =
1382 is_axis_aligned_in_target && 1485 is_axis_aligned_in_target &&
1383 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), 1486 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(),
1384 kAntiAliasingEpsilon); 1487 kAntiAliasingEpsilon);
1385 // AAing clipped quads is not supported by the code yet. 1488 // AAing clipped quads is not supported by the code yet.
1386 bool use_aa = !clipped && !is_nearest_rect_within_epsilon && quad->IsEdge(); 1489 bool use_aa = !clipped && !is_nearest_rect_within_epsilon && quad->IsEdge();
1387 if (!use_aa) 1490 if (!use_aa)
1388 return false; 1491 return false;
1389 1492
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 *local_quad = MathUtil::MapQuad( 1547 *local_quad = MathUtil::MapQuad(
1445 inverse_device_transform, device_quad.ToQuadF(), &clipped); 1548 inverse_device_transform, device_quad.ToQuadF(), &clipped);
1446 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may 1549 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may
1447 // cause device_quad to become clipped. To our knowledge this scenario does 1550 // cause device_quad to become clipped. To our knowledge this scenario does
1448 // not need to be handled differently than the unclipped case. 1551 // not need to be handled differently than the unclipped case.
1449 1552
1450 return true; 1553 return true;
1451 } 1554 }
1452 1555
1453 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 1556 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
1454 const SolidColorDrawQuad* quad) { 1557 const SolidColorDrawQuad* quad,
1558 const gfx::QuadF* clip_region) {
1455 gfx::Rect tile_rect = quad->visible_rect; 1559 gfx::Rect tile_rect = quad->visible_rect;
1456 1560
1457 SkColor color = quad->color; 1561 SkColor color = quad->color;
1458 float opacity = quad->opacity(); 1562 float opacity = quad->opacity();
1459 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; 1563 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
1460 1564
1461 // Early out if alpha is small enough that quad doesn't contribute to output. 1565 // Early out if alpha is small enough that quad doesn't contribute to output.
1462 if (alpha < std::numeric_limits<float>::epsilon() && 1566 if (alpha < std::numeric_limits<float>::epsilon() &&
1463 quad->ShouldDrawWithBlending()) 1567 quad->ShouldDrawWithBlending())
1464 return; 1568 return;
1465 1569
1466 gfx::Transform device_transform = 1570 gfx::Transform device_transform =
1467 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1571 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1468 device_transform.FlattenTo2d(); 1572 device_transform.FlattenTo2d();
1469 if (!device_transform.IsInvertible()) 1573 if (!device_transform.IsInvertible())
1470 return; 1574 return;
1471 1575
1472 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1576 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1577 gfx::QuadF original_quad = local_quad;
1473 float edge[24]; 1578 float edge[24];
1474 bool use_aa = 1579 bool use_aa =
1475 settings_->allow_antialiasing && !quad->force_anti_aliasing_off && 1580 settings_->allow_antialiasing &&
1476 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); 1581 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1477 1582
1583 gfx::QuadF local_draw_region;
1584 if (!clip_region) {
1585 local_draw_region = local_quad;
1586 } else {
1587 local_draw_region = *clip_region;
1588 }
1589
1590 if (use_aa) {
1591 ExpandDrawRegionToAAQuad(original_quad, local_quad, &local_draw_region);
1592 }
1593
1478 SolidColorProgramUniforms uniforms; 1594 SolidColorProgramUniforms uniforms;
1479 if (use_aa) 1595 if (use_aa)
1480 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); 1596 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms);
1481 else 1597 else
1482 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); 1598 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
1483 SetUseProgram(uniforms.program); 1599 SetUseProgram(uniforms.program);
1484 1600
1485 GLC(gl_, 1601 GLC(gl_,
1486 gl_->Uniform4f(uniforms.color_location, 1602 gl_->Uniform4f(uniforms.color_location,
1487 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1603 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1488 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1604 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
1489 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, 1605 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
1490 alpha)); 1606 alpha));
1491 if (use_aa) { 1607 if (use_aa) {
1492 float viewport[4] = {static_cast<float>(viewport_.x()), 1608 float viewport[4] = {static_cast<float>(viewport_.x()),
1493 static_cast<float>(viewport_.y()), 1609 static_cast<float>(viewport_.y()),
1494 static_cast<float>(viewport_.width()), 1610 static_cast<float>(viewport_.width()),
1495 static_cast<float>(viewport_.height()), }; 1611 static_cast<float>(viewport_.height()), };
1496 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport)); 1612 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport));
1497 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge)); 1613 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge));
1498 } 1614 }
1499 1615
1500 // Enable blending when the quad properties require it or if we decided 1616 // Enable blending when the quad properties require it or if we decided
1501 // to use antialiasing. 1617 // to use antialiasing.
1502 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1618 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1503 1619
1504 // Normalize to tile_rect. 1620 //Normalize to tile_rect.
1505 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1621 local_draw_region.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1506 1622
1507 SetShaderQuadF(local_quad, uniforms.quad_location); 1623 SetShaderQuadF(local_draw_region, uniforms.quad_location);
1508 1624
1509 // The transform and vertex data are used to figure out the extents that the 1625 // The transform and vertex data are used to figure out the extents that the
1510 // un-antialiased quad should have and which vertex this is and the float 1626 // un-antialiased quad should have and which vertex this is and the float
1511 // quad passed in via uniform is the actual geometry that gets used to draw 1627 // quad passed in via uniform is the actual geometry that gets used to draw
1512 // it. This is why this centered rect is used and not the original quad_rect. 1628 // it. This is why this centered rect is used and not the original quad_rect.
1513 gfx::RectF centered_rect( 1629 gfx::RectF centered_rect(
1514 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1630 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1515 tile_rect.size()); 1631 tile_rect.size());
1516 DrawQuadGeometry( 1632 DrawQuadGeometry(
1517 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); 1633 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
(...skipping 21 matching lines...) Expand all
1539 uniforms->vertex_tex_transform_location = 1655 uniforms->vertex_tex_transform_location =
1540 program->vertex_shader().vertex_tex_transform_location(); 1656 program->vertex_shader().vertex_tex_transform_location();
1541 1657
1542 uniforms->sampler_location = program->fragment_shader().sampler_location(); 1658 uniforms->sampler_location = program->fragment_shader().sampler_location();
1543 uniforms->alpha_location = program->fragment_shader().alpha_location(); 1659 uniforms->alpha_location = program->fragment_shader().alpha_location();
1544 uniforms->fragment_tex_transform_location = 1660 uniforms->fragment_tex_transform_location =
1545 program->fragment_shader().fragment_tex_transform_location(); 1661 program->fragment_shader().fragment_tex_transform_location();
1546 } 1662 }
1547 1663
1548 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, 1664 void GLRenderer::DrawTileQuad(const DrawingFrame* frame,
1549 const TileDrawQuad* quad) { 1665 const TileDrawQuad* quad,
1550 DrawContentQuad(frame, quad, quad->resource_id); 1666 const gfx::QuadF* clip_region) {
1667 DrawContentQuad(frame, quad, quad->resource_id, clip_region);
1551 } 1668 }
1552 1669
1553 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, 1670 void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
1554 const ContentDrawQuadBase* quad, 1671 const ContentDrawQuadBase* quad,
1555 ResourceProvider::ResourceId resource_id) { 1672 ResourceProvider::ResourceId resource_id,
1673 const gfx::QuadF* clip_region) {
1556 gfx::Rect tile_rect = quad->visible_rect; 1674 gfx::Rect tile_rect = quad->visible_rect;
1557 1675
1558 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1676 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1559 quad->tex_coord_rect, quad->rect, tile_rect); 1677 quad->tex_coord_rect, quad->rect, tile_rect);
1560 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1678 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1561 float tex_to_geom_scale_y = 1679 float tex_to_geom_scale_y =
1562 quad->rect.height() / quad->tex_coord_rect.height(); 1680 quad->rect.height() / quad->tex_coord_rect.height();
1563 1681
1564 gfx::RectF clamp_geom_rect(tile_rect); 1682 gfx::RectF clamp_geom_rect(tile_rect);
1565 gfx::RectF clamp_tex_rect(tex_coord_rect); 1683 gfx::RectF clamp_tex_rect(tex_coord_rect);
(...skipping 26 matching lines...) Expand all
1592 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1710 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1593 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1711 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
1594 1712
1595 gfx::Transform device_transform = 1713 gfx::Transform device_transform =
1596 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1714 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1597 device_transform.FlattenTo2d(); 1715 device_transform.FlattenTo2d();
1598 if (!device_transform.IsInvertible()) 1716 if (!device_transform.IsInvertible())
1599 return; 1717 return;
1600 1718
1601 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1719 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1720 gfx::QuadF original_quad = local_quad;
1602 float edge[24]; 1721 float edge[24];
1603 bool use_aa = 1722 bool use_aa =
1604 settings_->allow_antialiasing && 1723 settings_->allow_antialiasing &&
1605 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); 1724 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1606 1725
1726 gfx::QuadF local_draw_region;
1727 if (!clip_region) {
1728 local_draw_region = local_quad;
1729 } else {
1730 local_draw_region = *clip_region;
1731 }
1732
1733 if (use_aa) {
1734 ExpandDrawRegionToAAQuad(original_quad, local_quad, &local_draw_region);
1735 }
1736
1607 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); 1737 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
1608 GLenum filter = (use_aa || scaled || 1738 GLenum filter = (use_aa || scaled ||
1609 !quad->quadTransform().IsIdentityOrIntegerTranslation()) 1739 !quad->quadTransform().IsIdentityOrIntegerTranslation())
1610 ? GL_LINEAR 1740 ? GL_LINEAR
1611 : GL_NEAREST; 1741 : GL_NEAREST;
1612 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1742 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1613 resource_provider_, resource_id, filter); 1743 resource_provider_, resource_id, filter);
1614 SamplerType sampler = 1744 SamplerType sampler =
1615 SamplerTypeFromTextureTarget(quad_resource_lock.target()); 1745 SamplerTypeFromTextureTarget(quad_resource_lock.target());
1616 1746
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 vertex_tex_translate_y, 1830 vertex_tex_translate_y,
1701 vertex_tex_scale_x, 1831 vertex_tex_scale_x,
1702 vertex_tex_scale_y)); 1832 vertex_tex_scale_y));
1703 } 1833 }
1704 1834
1705 // Enable blending when the quad properties require it or if we decided 1835 // Enable blending when the quad properties require it or if we decided
1706 // to use antialiasing. 1836 // to use antialiasing.
1707 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1837 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1708 1838
1709 // Normalize to tile_rect. 1839 // Normalize to tile_rect.
1710 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1840 local_draw_region.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1711
1712 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1841 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1713 SetShaderQuadF(local_quad, uniforms.quad_location); 1842 SetShaderQuadF(local_draw_region, uniforms.quad_location);
1714 1843
1715 // The transform and vertex data are used to figure out the extents that the 1844 // The transform and vertex data are used to figure out the extents that the
1716 // un-antialiased quad should have and which vertex this is and the float 1845 // un-antialiased quad should have and which vertex this is and the float
1717 // quad passed in via uniform is the actual geometry that gets used to draw 1846 // quad passed in via uniform is the actual geometry that gets used to draw
1718 // it. This is why this centered rect is used and not the original quad_rect. 1847 // it. This is why this centered rect is used and not the original quad_rect.
1719 gfx::RectF centered_rect( 1848 gfx::RectF centered_rect(
1720 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1849 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1721 tile_rect.size()); 1850 tile_rect.size());
1722 DrawQuadGeometry( 1851 DrawQuadGeometry(
1723 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); 1852 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
1724 } 1853 }
1725 1854
1726 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, 1855 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
1727 const YUVVideoDrawQuad* quad) { 1856 const YUVVideoDrawQuad* quad,
1857 const gfx::QuadF* clip_region) {
1728 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1858 SetBlendEnabled(quad->ShouldDrawWithBlending());
1729 1859
1730 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1860 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1731 gl_, 1861 gl_,
1732 &highp_threshold_cache_, 1862 &highp_threshold_cache_,
1733 highp_threshold_min_, 1863 highp_threshold_min_,
1734 quad->shared_quad_state->visible_content_rect.bottom_right()); 1864 quad->shared_quad_state->visible_content_rect.bottom_right());
1735 1865
1736 bool use_alpha_plane = quad->a_plane_resource_id != 0; 1866 bool use_alpha_plane = quad->a_plane_resource_id != 0;
1737 1867
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 case YUVVideoDrawQuad::REC_601: 1966 case YUVVideoDrawQuad::REC_601:
1837 yuv_to_rgb = yuv_to_rgb_rec601; 1967 yuv_to_rgb = yuv_to_rgb_rec601;
1838 yuv_adjust = yuv_adjust_rec601; 1968 yuv_adjust = yuv_adjust_rec601;
1839 break; 1969 break;
1840 case YUVVideoDrawQuad::REC_601_JPEG: 1970 case YUVVideoDrawQuad::REC_601_JPEG:
1841 yuv_to_rgb = yuv_to_rgb_rec601_jpeg; 1971 yuv_to_rgb = yuv_to_rgb_rec601_jpeg;
1842 yuv_adjust = yuv_adjust_rec601_jpeg; 1972 yuv_adjust = yuv_adjust_rec601_jpeg;
1843 break; 1973 break;
1844 } 1974 }
1845 1975
1976 // The transform and vertex data are used to figure out the extents that the
1977 // un-antialiased quad should have and which vertex this is and the float
1978 // quad passed in via uniform is the actual geometry that gets used to draw
1979 // it. This is why this centered rect is used and not the original quad_rect.
1980 gfx::RectF tile_rect = quad->visible_rect;
1846 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 1981 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1847 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 1982 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
1848 1983
1849 SetShaderOpacity(quad->opacity(), alpha_location); 1984 SetShaderOpacity(quad->opacity(), alpha_location);
1850 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 1985 if (!clip_region) {
1986 DrawQuadGeometry(frame, quad->quadTransform(), tile_rect, matrix_location);
1987 } else {
1988 gfx::QuadF region_quad = *clip_region;
1989 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1990 DrawQuadGeometryClippedByQuadF(
1991 frame, quad->quadTransform(), tile_rect, region_quad, matrix_location);
1992 }
1851 } 1993 }
1852 1994
1853 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 1995 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1854 const StreamVideoDrawQuad* quad) { 1996 const StreamVideoDrawQuad* quad,
1997 const gfx::QuadF* clip_region) {
1855 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1998 SetBlendEnabled(quad->ShouldDrawWithBlending());
1856 1999
1857 static float gl_matrix[16]; 2000 static float gl_matrix[16];
1858 2001
1859 DCHECK(capabilities_.using_egl_image); 2002 DCHECK(capabilities_.using_egl_image);
1860 2003
1861 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2004 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1862 gl_, 2005 gl_,
1863 &highp_threshold_cache_, 2006 &highp_threshold_cache_,
1864 highp_threshold_min_, 2007 highp_threshold_min_,
(...skipping 10 matching lines...) Expand all
1875 2018
1876 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2019 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1877 quad->resource_id); 2020 quad->resource_id);
1878 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2021 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
1879 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); 2022 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1880 2023
1881 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2024 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1882 2025
1883 SetShaderOpacity(quad->opacity(), 2026 SetShaderOpacity(quad->opacity(),
1884 program->fragment_shader().alpha_location()); 2027 program->fragment_shader().alpha_location());
1885 DrawQuadGeometry(frame, 2028 if (!clip_region) {
1886 quad->quadTransform(), 2029 DrawQuadGeometry(frame,
1887 quad->rect, 2030 quad->quadTransform(),
1888 program->vertex_shader().matrix_location()); 2031 quad->rect,
2032 program->vertex_shader().matrix_location());
2033 } else {
2034 DrawQuadGeometryClippedByQuadF(frame,
2035 quad->quadTransform(),
2036 quad->rect,
2037 *clip_region,
2038 program->vertex_shader().matrix_location());
2039 }
1889 } 2040 }
1890 2041
1891 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, 2042 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
1892 const PictureDrawQuad* quad) { 2043 const PictureDrawQuad* quad,
2044 const gfx::QuadF* clip_region) {
1893 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || 2045 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() ||
1894 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { 2046 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) {
1895 on_demand_tile_raster_bitmap_.allocN32Pixels(quad->texture_size.width(), 2047 on_demand_tile_raster_bitmap_.allocN32Pixels(quad->texture_size.width(),
1896 quad->texture_size.height()); 2048 quad->texture_size.height());
1897 2049
1898 if (on_demand_tile_raster_resource_id_) 2050 if (on_demand_tile_raster_resource_id_)
1899 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 2051 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1900 2052
1901 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 2053 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
1902 quad->texture_size, 2054 quad->texture_size,
(...skipping 23 matching lines...) Expand all
1926 bitmap_pixels = 2078 bitmap_pixels =
1927 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()); 2079 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels());
1928 } 2080 }
1929 2081
1930 resource_provider_->SetPixels(on_demand_tile_raster_resource_id_, 2082 resource_provider_->SetPixels(on_demand_tile_raster_resource_id_,
1931 bitmap_pixels, 2083 bitmap_pixels,
1932 gfx::Rect(quad->texture_size), 2084 gfx::Rect(quad->texture_size),
1933 gfx::Rect(quad->texture_size), 2085 gfx::Rect(quad->texture_size),
1934 gfx::Vector2d()); 2086 gfx::Vector2d());
1935 2087
1936 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 2088 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_, clip_region);
1937 } 2089 }
1938 2090
1939 struct TextureProgramBinding { 2091 struct TextureProgramBinding {
1940 template <class Program> 2092 template <class Program>
1941 void Set(Program* program) { 2093 void Set(Program* program) {
1942 DCHECK(program); 2094 DCHECK(program);
1943 program_id = program->program(); 2095 program_id = program->program();
1944 sampler_location = program->fragment_shader().sampler_location(); 2096 sampler_location = program->fragment_shader().sampler_location();
1945 matrix_location = program->vertex_shader().matrix_location(); 2097 matrix_location = program->vertex_shader().matrix_location();
1946 background_color_location = 2098 background_color_location =
1947 program->fragment_shader().background_color_location(); 2099 program->fragment_shader().background_color_location();
1948 } 2100 }
1949 int program_id; 2101 int program_id;
1950 int sampler_location; 2102 int sampler_location;
1951 int matrix_location; 2103 int matrix_location;
2104 int transform_location;
1952 int background_color_location; 2105 int background_color_location;
1953 }; 2106 };
1954 2107
1955 struct TexTransformTextureProgramBinding : TextureProgramBinding { 2108 struct TexTransformTextureProgramBinding : TextureProgramBinding {
1956 template <class Program> 2109 template <class Program>
1957 void Set(Program* program) { 2110 void Set(Program* program) {
1958 TextureProgramBinding::Set(program); 2111 TextureProgramBinding::Set(program);
1959 tex_transform_location = program->vertex_shader().tex_transform_location(); 2112 tex_transform_location = program->vertex_shader().tex_transform_location();
1960 vertex_opacity_location = 2113 vertex_opacity_location =
1961 program->vertex_shader().vertex_opacity_location(); 2114 program->vertex_shader().vertex_opacity_location();
1962 } 2115 }
1963 int tex_transform_location; 2116 int tex_transform_location;
1964 int vertex_opacity_location; 2117 int vertex_opacity_location;
1965 }; 2118 };
1966 2119
1967 void GLRenderer::FlushTextureQuadCache() { 2120 void GLRenderer::FlushTextureQuadCache(bool using_clip_region) {
1968 // Check to see if we have anything to draw. 2121 // Check to see if we have anything to draw.
1969 if (draw_cache_.program_id == 0) 2122 if (draw_cache_.program_id == 0)
1970 return; 2123 return;
2124 /*
2125 if (!using_clip_region) {
2126 shared_geometry_->PrepareForDraw();
2127 } else {
2128 clipped_geometry_->PrepareForDraw();
2129 }
2130 */
1971 2131
1972 // Set the correct blending mode. 2132 // Set the correct blending mode.
1973 SetBlendEnabled(draw_cache_.needs_blending); 2133 SetBlendEnabled(draw_cache_.needs_blending);
1974 2134
1975 // Bind the program to the GL state. 2135 // Bind the program to the GL state.
1976 SetUseProgram(draw_cache_.program_id); 2136 SetUseProgram(draw_cache_.program_id);
1977 2137
1978 // Bind the correct texture sampler location. 2138 // Bind the correct texture sampler location.
1979 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); 2139 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
1980 2140
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 gl_->DrawElements(GL_TRIANGLES, 2179 gl_->DrawElements(GL_TRIANGLES,
2020 6 * draw_cache_.matrix_data.size(), 2180 6 * draw_cache_.matrix_data.size(),
2021 GL_UNSIGNED_SHORT, 2181 GL_UNSIGNED_SHORT,
2022 0)); 2182 0));
2023 2183
2024 // Clear the cache. 2184 // Clear the cache.
2025 draw_cache_.program_id = 0; 2185 draw_cache_.program_id = 0;
2026 draw_cache_.uv_xform_data.resize(0); 2186 draw_cache_.uv_xform_data.resize(0);
2027 draw_cache_.vertex_opacity_data.resize(0); 2187 draw_cache_.vertex_opacity_data.resize(0);
2028 draw_cache_.matrix_data.resize(0); 2188 draw_cache_.matrix_data.resize(0);
2189 /*
2190 if (using_clip_region) {
2191 shared_geometry_->PrepareForDraw();
2192 }*/
2193 }
2194
2195 void PrintQuad(const gfx::QuadF& quad) {
2196 LOG(ERROR) << "quad";
2197 LOG(ERROR) << quad.p1().x() << ", " << quad.p1().y();
2198 LOG(ERROR) << quad.p2().x() << ", " << quad.p2().y();
2199 LOG(ERROR) << quad.p3().x() << ", " << quad.p3().y();
2200 LOG(ERROR) << quad.p4().x() << ", " << quad.p4().y();
2029 } 2201 }
2030 2202
2031 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, 2203 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
2032 const TextureDrawQuad* quad) { 2204 const TextureDrawQuad* quad,
2205 const gfx::QuadF* clip_region) {
2206 //TODO(awoloszyn):: THIS IS VERY SUSPICIOUS, this is going to invole
2207 // a huge amount of state swapping where it may not be necessary
2208 // Here we need to flush out everything that's already in the cache because
2209 // we need to enqueue a single quad, switch geometry bindings, and then
2210 // flush that single quad.
2211 if (clip_region) {
2212 // We send in false here because we want to flush what's currently in the
2213 // queue using the shared_geometry and not clipped_geometry
2214 // FlushTextureQuadCache(false);
2215 }
2216
2033 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2217 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2034 gl_, 2218 gl_,
2035 &highp_threshold_cache_, 2219 &highp_threshold_cache_,
2036 highp_threshold_min_, 2220 highp_threshold_min_,
2037 quad->shared_quad_state->visible_content_rect.bottom_right()); 2221 quad->shared_quad_state->visible_content_rect.bottom_right());
2038 2222
2039 // Choose the correct texture program binding 2223 // Choose the correct texture program binding
2040 TexTransformTextureProgramBinding binding; 2224 TexTransformTextureProgramBinding binding;
2041 if (quad->premultiplied_alpha) { 2225 if (quad->premultiplied_alpha) {
2042 if (quad->background_color == SK_ColorTRANSPARENT) { 2226 if (quad->background_color == SK_ColorTRANSPARENT) {
(...skipping 10 matching lines...) Expand all
2053 } 2237 }
2054 } 2238 }
2055 2239
2056 int resource_id = quad->resource_id; 2240 int resource_id = quad->resource_id;
2057 2241
2058 if (draw_cache_.program_id != binding.program_id || 2242 if (draw_cache_.program_id != binding.program_id ||
2059 draw_cache_.resource_id != resource_id || 2243 draw_cache_.resource_id != resource_id ||
2060 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || 2244 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() ||
2061 draw_cache_.background_color != quad->background_color || 2245 draw_cache_.background_color != quad->background_color ||
2062 draw_cache_.matrix_data.size() >= 8) { 2246 draw_cache_.matrix_data.size() >= 8) {
2063 FlushTextureQuadCache(); 2247 FlushTextureQuadCache(false);
2064 draw_cache_.program_id = binding.program_id; 2248 draw_cache_.program_id = binding.program_id;
2065 draw_cache_.resource_id = resource_id; 2249 draw_cache_.resource_id = resource_id;
2066 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); 2250 draw_cache_.needs_blending = quad->ShouldDrawWithBlending();
2067 draw_cache_.background_color = quad->background_color; 2251 draw_cache_.background_color = quad->background_color;
2068 2252
2069 draw_cache_.uv_xform_location = binding.tex_transform_location; 2253 draw_cache_.uv_xform_location = binding.tex_transform_location;
2070 draw_cache_.background_color_location = binding.background_color_location; 2254 draw_cache_.background_color_location = binding.background_color_location;
2071 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; 2255 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location;
2072 draw_cache_.matrix_location = binding.matrix_location; 2256 draw_cache_.matrix_location = binding.matrix_location;
2073 draw_cache_.sampler_location = binding.sampler_location; 2257 draw_cache_.sampler_location = binding.sampler_location;
2074 } 2258 }
2075 2259
2076 // Generate the uv-transform 2260 // Generate the uv-transform
2077 draw_cache_.uv_xform_data.push_back(UVTransform(quad)); 2261 if (!clip_region) {
2262 draw_cache_.uv_xform_data.push_back(UVTransform(quad));
2263 } else {
2264 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2265 draw_cache_.uv_xform_data.push_back(uv_transform);
2266 }
2078 2267
2079 // Generate the vertex opacity 2268 // Generate the vertex opacity
2080 const float opacity = quad->opacity(); 2269 const float opacity = quad->opacity();
2081 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2270 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
2082 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); 2271 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity);
2083 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); 2272 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity);
2084 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); 2273 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity);
2085 2274
2086 // Generate the transform matrix 2275 // Generate the transform matrix
2087 gfx::Transform quad_rect_matrix; 2276 gfx::Transform quad_rect_matrix;
2088 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 2277 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
2089 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; 2278 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix;
2090 2279
2091 Float16 m; 2280 Float16 m;
2092 quad_rect_matrix.matrix().asColMajorf(m.data); 2281 quad_rect_matrix.matrix().asColMajorf(m.data);
2093 draw_cache_.matrix_data.push_back(m); 2282 draw_cache_.matrix_data.push_back(m);
2283
2284 if (clip_region) {
2285 // Now we make the clip_region fit inside the regular SharedGeometryQuad
2286 // and send that in to be rendered.
2287 gfx::PointF p1(clip_region->p1().x() * (1.0f / quad->rect.width()) - 0.5f,
2288 clip_region->p1().y() * (1.0f / quad->rect.height()) - 0.5f);
2289 gfx::PointF p2(clip_region->p2().x() * (1.0f / quad->rect.width()) - 0.5f,
2290 clip_region->p2().y() * (1.0f / quad->rect.height()) - 0.5f);
2291 gfx::PointF p3(clip_region->p3().x() * (1.0f / quad->rect.width()) - 0.5f,
2292 clip_region->p3().y() * (1.0f / quad->rect.height()) - 0.5f);
2293 gfx::PointF p4(clip_region->p4().x() * (1.0f / quad->rect.width()) - 0.5f,
2294 clip_region->p4().y() * (1.0f / quad->rect.height()) - 0.5f);
2295 gfx::QuadF scaled_region(p1, p2, p3, p4);
2296
2297 float uv[8];
2298 uv[0] = p1.x() + 0.5f;
2299 uv[1] = p1.y() + 0.5f;
2300 uv[2] = p2.x() + 0.5f;
2301 uv[3] = p2.y() + 0.5f;
2302 uv[4] = p3.x() + 0.5f;
2303 uv[5] = p3.y() + 0.5f;
2304 uv[6] = p4.x() + 0.5f;
2305 uv[7] = p4.y() + 0.5f;
2306
2307 clipped_geometry_->InitializeCustomQuadWithUVs(scaled_region, uv);
2308 //TODO(awoloszyn) Again, if we flush with EVERY call, we are doing something
2309 //wrong
2310 //FlushTextureQuadCache(true);
2311 }
2094 } 2312 }
2095 2313
2096 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, 2314 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
2097 const IOSurfaceDrawQuad* quad) { 2315 const IOSurfaceDrawQuad* quad,
2316 const gfx::QuadF* clip_region) {
2098 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2317 SetBlendEnabled(quad->ShouldDrawWithBlending());
2099 2318
2100 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2319 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2101 gl_, 2320 gl_,
2102 &highp_threshold_cache_, 2321 &highp_threshold_cache_,
2103 highp_threshold_min_, 2322 highp_threshold_min_,
2104 quad->shared_quad_state->visible_content_rect.bottom_right()); 2323 quad->shared_quad_state->visible_content_rect.bottom_right());
2105 2324
2106 TexTransformTextureProgramBinding binding; 2325 TexTransformTextureProgramBinding binding;
2107 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); 2326 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
(...skipping 18 matching lines...) Expand all
2126 2345
2127 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), 2346 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
2128 quad->opacity(), quad->opacity()}; 2347 quad->opacity(), quad->opacity()};
2129 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); 2348 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
2130 2349
2131 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2350 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2132 quad->io_surface_resource_id); 2351 quad->io_surface_resource_id);
2133 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2352 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2134 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); 2353 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
2135 2354
2136 DrawQuadGeometry( 2355 if (!clip_region) {
2137 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 2356 DrawQuadGeometry(
2357 frame, quad->quadTransform(), quad->rect, binding.matrix_location);
2358 } else {
2359 DrawQuadGeometryClippedByQuadF(frame,
2360 quad->quadTransform(),
2361 quad->rect,
2362 *clip_region,
2363 binding.matrix_location);
2364 }
2138 2365
2139 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 2366 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
2140 } 2367 }
2141 2368
2142 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2369 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2143 if (use_sync_query_) { 2370 if (use_sync_query_) {
2144 DCHECK(current_sync_query_); 2371 DCHECK(current_sync_query_);
2145 current_sync_query_->End(); 2372 current_sync_query_->End();
2146 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2373 pending_sync_queries_.push_back(current_sync_query_.Pass());
2147 } 2374 }
2148 2375
2149 current_framebuffer_lock_.reset(); 2376 current_framebuffer_lock_.reset();
2150 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2377 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2151 2378
2152 GLC(gl_, gl_->Disable(GL_BLEND)); 2379 GLC(gl_, gl_->Disable(GL_BLEND));
2153 blend_shadow_ = false; 2380 blend_shadow_ = false;
2154 2381
2155 ScheduleOverlays(frame); 2382 ScheduleOverlays(frame);
2156 } 2383 }
2157 2384
2158 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } 2385 void GLRenderer::FinishDrawingQuadList() {
2386 FlushTextureQuadCache(false);
2387 }
2159 2388
2160 bool GLRenderer::FlippedFramebuffer() const { return true; } 2389 bool GLRenderer::FlippedFramebuffer() const { return true; }
2161 2390
2162 void GLRenderer::EnsureScissorTestEnabled() { 2391 void GLRenderer::EnsureScissorTestEnabled() {
2163 if (is_scissor_enabled_) 2392 if (is_scissor_enabled_)
2164 return; 2393 return;
2165 2394
2166 FlushTextureQuadCache(); 2395 FlushTextureQuadCache(false);
2167 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST)); 2396 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
2168 is_scissor_enabled_ = true; 2397 is_scissor_enabled_ = true;
2169 } 2398 }
2170 2399
2171 void GLRenderer::EnsureScissorTestDisabled() { 2400 void GLRenderer::EnsureScissorTestDisabled() {
2172 if (!is_scissor_enabled_) 2401 if (!is_scissor_enabled_)
2173 return; 2402 return;
2174 2403
2175 FlushTextureQuadCache(); 2404 FlushTextureQuadCache(false);
2176 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 2405 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
2177 is_scissor_enabled_ = false; 2406 is_scissor_enabled_ = false;
2178 } 2407 }
2179 2408
2180 void GLRenderer::CopyCurrentRenderPassToBitmap( 2409 void GLRenderer::CopyCurrentRenderPassToBitmap(
2181 DrawingFrame* frame, 2410 DrawingFrame* frame,
2182 scoped_ptr<CopyOutputRequest> request) { 2411 scoped_ptr<CopyOutputRequest> request) {
2183 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); 2412 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap");
2184 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 2413 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2185 if (request->has_area()) 2414 if (request->has_area())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 blend_shadow_ = enabled; 2463 blend_shadow_ = enabled;
2235 } 2464 }
2236 2465
2237 void GLRenderer::SetUseProgram(unsigned program) { 2466 void GLRenderer::SetUseProgram(unsigned program) {
2238 if (program == program_shadow_) 2467 if (program == program_shadow_)
2239 return; 2468 return;
2240 gl_->UseProgram(program); 2469 gl_->UseProgram(program);
2241 program_shadow_ = program; 2470 program_shadow_ = program;
2242 } 2471 }
2243 2472
2473 void GLRenderer::DrawQuadGeometryClippedByQuadF(
2474 const DrawingFrame* frame,
2475 const gfx::Transform& draw_transform,
2476 const gfx::RectF& quad_rect,
2477 const gfx::QuadF& clipping_region_quad,
2478 int matrix_location) {
2479 // clipped_geometry_->PrepareForDraw();
2480 clipped_geometry_->InitializeCustomQuad(clipping_region_quad);
2481 static float gl_matrix[16];
2482 ToGLMatrix(&gl_matrix[0], frame->projection_matrix);
2483 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2484
2485 GLC(gl_,
2486 gl_->DrawElements(GL_TRIANGLES,
2487 6,
2488 GL_UNSIGNED_SHORT,
2489 reinterpret_cast<const void*>(0)));
2490 }
2491
2244 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2492 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
2245 const gfx::Transform& draw_transform, 2493 const gfx::Transform& draw_transform,
2246 const gfx::RectF& quad_rect, 2494 const gfx::RectF& quad_rect,
2247 int matrix_location) { 2495 int matrix_location) {
2496 // shared_geometry_->PrepareForDraw();
2248 gfx::Transform quad_rect_matrix; 2497 gfx::Transform quad_rect_matrix;
2249 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2498 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2250 static float gl_matrix[16]; 2499 static float gl_matrix[16];
2251 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2500 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2252 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); 2501 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2253 2502
2254 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 2503 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
2255 } 2504 }
2256 2505
2257 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, 2506 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 return true; 2910 return true;
2662 } 2911 }
2663 2912
2664 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { 2913 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
2665 EnsureScissorTestEnabled(); 2914 EnsureScissorTestEnabled();
2666 2915
2667 // Don't unnecessarily ask the context to change the scissor, because it 2916 // Don't unnecessarily ask the context to change the scissor, because it
2668 // may cause undesired GPU pipeline flushes. 2917 // may cause undesired GPU pipeline flushes.
2669 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) 2918 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_)
2670 return; 2919 return;
2671
2672 scissor_rect_ = scissor_rect; 2920 scissor_rect_ = scissor_rect;
2673 FlushTextureQuadCache(); 2921 FlushTextureQuadCache(false);
2674 GLC(gl_, 2922 GLC(gl_,
2675 gl_->Scissor(scissor_rect.x(), 2923 gl_->Scissor(scissor_rect.x(),
2676 scissor_rect.y(), 2924 scissor_rect.y(),
2677 scissor_rect.width(), 2925 scissor_rect.width(),
2678 scissor_rect.height())); 2926 scissor_rect.height()));
2679 2927
2680 scissor_rect_needs_reset_ = false; 2928 scissor_rect_needs_reset_ = false;
2681 } 2929 }
2682 2930
2683 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) { 2931 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
2684 viewport_ = window_space_viewport; 2932 viewport_ = window_space_viewport;
2685 GLC(gl_, 2933 GLC(gl_,
2686 gl_->Viewport(window_space_viewport.x(), 2934 gl_->Viewport(window_space_viewport.x(),
2687 window_space_viewport.y(), 2935 window_space_viewport.y(),
2688 window_space_viewport.width(), 2936 window_space_viewport.width(),
2689 window_space_viewport.height())); 2937 window_space_viewport.height()));
2690 } 2938 }
2691 2939
2692 void GLRenderer::InitializeSharedObjects() { 2940 void GLRenderer::InitializeSharedObjects() {
2693 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 2941 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2694 2942
2695 // Create an FBO for doing offscreen rendering. 2943 // Create an FBO for doing offscreen rendering.
2696 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_)); 2944 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
2697 2945
2698 shared_geometry_ = make_scoped_ptr( 2946 shared_geometry_ =
2699 new GeometryBinding(gl_, QuadVertexRect())); 2947 make_scoped_ptr(new GeometryBinding(gl_, QuadVertexRect(), 8));
2948 clipped_geometry_ =
2949 make_scoped_ptr(new GeometryBindingQuad(gl_, QuadVertexRect()));
2700 } 2950 }
2701 2951
2702 const GLRenderer::TileCheckerboardProgram* 2952 const GLRenderer::TileCheckerboardProgram*
2703 GLRenderer::GetTileCheckerboardProgram() { 2953 GLRenderer::GetTileCheckerboardProgram() {
2704 if (!tile_checkerboard_program_.initialized()) { 2954 if (!tile_checkerboard_program_.initialized()) {
2705 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); 2955 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
2706 tile_checkerboard_program_.Initialize(output_surface_->context_provider(), 2956 tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
2707 TexCoordPrecisionNA, 2957 TexCoordPrecisionNA,
2708 SamplerTypeNA); 2958 SamplerTypeNA);
2709 } 2959 }
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 context_support_->ScheduleOverlayPlane( 3432 context_support_->ScheduleOverlayPlane(
3183 overlay.plane_z_order, 3433 overlay.plane_z_order,
3184 overlay.transform, 3434 overlay.transform,
3185 pending_overlay_resources_.back()->texture_id(), 3435 pending_overlay_resources_.back()->texture_id(),
3186 overlay.display_rect, 3436 overlay.display_rect,
3187 overlay.uv_rect); 3437 overlay.uv_rect);
3188 } 3438 }
3189 } 3439 }
3190 3440
3191 } // namespace cc 3441 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698