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

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: Removed the static that was only used in ony place anyway Created 5 years, 9 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/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h"
18 #include "build/build_config.h"
14 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
15 #include "cc/base/math_util.h" 20 #include "cc/base/math_util.h"
16 #include "cc/layers/video_layer_impl.h" 21 #include "cc/layers/video_layer_impl.h"
17 #include "cc/output/compositor_frame.h" 22 #include "cc/output/compositor_frame.h"
18 #include "cc/output/compositor_frame_metadata.h" 23 #include "cc/output/compositor_frame_metadata.h"
19 #include "cc/output/context_provider.h" 24 #include "cc/output/context_provider.h"
20 #include "cc/output/copy_output_request.h" 25 #include "cc/output/copy_output_request.h"
21 #include "cc/output/geometry_binding.h" 26 #include "cc/output/dynamic_geometry_binding.h"
22 #include "cc/output/gl_frame_data.h" 27 #include "cc/output/gl_frame_data.h"
23 #include "cc/output/output_surface.h" 28 #include "cc/output/output_surface.h"
24 #include "cc/output/render_surface_filters.h" 29 #include "cc/output/render_surface_filters.h"
30 #include "cc/output/static_geometry_binding.h"
31 #include "cc/quads/draw_polygon.h"
25 #include "cc/quads/picture_draw_quad.h" 32 #include "cc/quads/picture_draw_quad.h"
26 #include "cc/quads/render_pass.h" 33 #include "cc/quads/render_pass.h"
27 #include "cc/quads/stream_video_draw_quad.h" 34 #include "cc/quads/stream_video_draw_quad.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_gpu_raster.h" 37 #include "cc/resources/scoped_gpu_raster.h"
31 #include "cc/resources/scoped_resource.h" 38 #include "cc/resources/scoped_resource.h"
32 #include "cc/resources/texture_mailbox_deleter.h" 39 #include "cc/resources/texture_mailbox_deleter.h"
33 #include "gpu/GLES2/gl2extchromium.h" 40 #include "gpu/GLES2/gl2extchromium.h"
34 #include "gpu/command_buffer/client/context_support.h" 41 #include "gpu/command_buffer/client/context_support.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 context_support_(output_surface->context_provider()->ContextSupport()), 324 context_support_(output_surface->context_provider()->ContextSupport()),
318 texture_mailbox_deleter_(texture_mailbox_deleter), 325 texture_mailbox_deleter_(texture_mailbox_deleter),
319 is_backbuffer_discarded_(false), 326 is_backbuffer_discarded_(false),
320 is_scissor_enabled_(false), 327 is_scissor_enabled_(false),
321 scissor_rect_needs_reset_(true), 328 scissor_rect_needs_reset_(true),
322 stencil_shadow_(false), 329 stencil_shadow_(false),
323 blend_shadow_(false), 330 blend_shadow_(false),
324 highp_threshold_min_(highp_threshold_min), 331 highp_threshold_min_(highp_threshold_min),
325 highp_threshold_cache_(0), 332 highp_threshold_cache_(0),
326 use_sync_query_(false), 333 use_sync_query_(false),
327 on_demand_tile_raster_resource_id_(0) { 334 on_demand_tile_raster_resource_id_(0),
335 bound_geometry_(NO_BINDING) {
328 DCHECK(gl_); 336 DCHECK(gl_);
329 DCHECK(context_support_); 337 DCHECK(context_support_);
330 338
331 ContextProvider::Capabilities context_caps = 339 ContextProvider::Capabilities context_caps =
332 output_surface_->context_provider()->ContextCapabilities(); 340 output_surface_->context_provider()->ContextCapabilities();
333 341
334 capabilities_.using_partial_swap = 342 capabilities_.using_partial_swap =
335 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer; 343 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer;
336 344
337 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle); 345 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 495
488 // TODO(enne): Do we need to reinitialize all of this state per frame? 496 // TODO(enne): Do we need to reinitialize all of this state per frame?
489 ReinitializeGLState(); 497 ReinitializeGLState();
490 } 498 }
491 499
492 void GLRenderer::DoNoOp() { 500 void GLRenderer::DoNoOp() {
493 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 501 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
494 GLC(gl_, gl_->Flush()); 502 GLC(gl_, gl_->Flush());
495 } 503 }
496 504
497 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { 505 void GLRenderer::DoDrawQuad(DrawingFrame* frame,
506 const DrawQuad* quad,
507 const gfx::QuadF* clip_region) {
498 DCHECK(quad->rect.Contains(quad->visible_rect)); 508 DCHECK(quad->rect.Contains(quad->visible_rect));
499 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 509 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
500 FlushTextureQuadCache(); 510 FlushTextureQuadCache(SHARED_BINDING);
501 } 511 }
502 512
503 switch (quad->material) { 513 switch (quad->material) {
504 case DrawQuad::INVALID: 514 case DrawQuad::INVALID:
505 NOTREACHED(); 515 NOTREACHED();
506 break; 516 break;
507 case DrawQuad::CHECKERBOARD: 517 case DrawQuad::CHECKERBOARD:
508 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); 518 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad),
519 clip_region);
509 break; 520 break;
510 case DrawQuad::DEBUG_BORDER: 521 case DrawQuad::DEBUG_BORDER:
511 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); 522 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad));
512 break; 523 break;
513 case DrawQuad::IO_SURFACE_CONTENT: 524 case DrawQuad::IO_SURFACE_CONTENT:
514 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); 525 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad),
526 clip_region);
515 break; 527 break;
516 case DrawQuad::PICTURE_CONTENT: 528 case DrawQuad::PICTURE_CONTENT:
517 // PictureDrawQuad should only be used for resourceless software draws. 529 // PictureDrawQuad should only be used for resourceless software draws.
518 NOTREACHED(); 530 NOTREACHED();
519 break; 531 break;
520 case DrawQuad::RENDER_PASS: 532 case DrawQuad::RENDER_PASS:
521 DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); 533 DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad),
534 clip_region);
522 break; 535 break;
523 case DrawQuad::SOLID_COLOR: 536 case DrawQuad::SOLID_COLOR:
524 DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad)); 537 DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad),
538 clip_region);
525 break; 539 break;
526 case DrawQuad::STREAM_VIDEO_CONTENT: 540 case DrawQuad::STREAM_VIDEO_CONTENT:
527 DrawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad)); 541 DrawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad),
542 clip_region);
528 break; 543 break;
529 case DrawQuad::SURFACE_CONTENT: 544 case DrawQuad::SURFACE_CONTENT:
530 // Surface content should be fully resolved to other quad types before 545 // Surface content should be fully resolved to other quad types before
531 // reaching a direct renderer. 546 // reaching a direct renderer.
532 NOTREACHED(); 547 NOTREACHED();
533 break; 548 break;
534 case DrawQuad::TEXTURE_CONTENT: 549 case DrawQuad::TEXTURE_CONTENT:
535 EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); 550 EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad),
551 clip_region);
536 break; 552 break;
537 case DrawQuad::TILED_CONTENT: 553 case DrawQuad::TILED_CONTENT:
538 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); 554 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad), clip_region);
539 break; 555 break;
540 case DrawQuad::YUV_VIDEO_CONTENT: 556 case DrawQuad::YUV_VIDEO_CONTENT:
541 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); 557 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad),
558 clip_region);
542 break; 559 break;
543 } 560 }
544 } 561 }
545 562
546 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame, 563 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
547 const CheckerboardDrawQuad* quad) { 564 const CheckerboardDrawQuad* quad,
565 const gfx::QuadF* clip_region) {
566 // TODO(enne) For now since checkerboards shouldn't be part of a 3D
567 // context, clipping regions aren't supported so we skip drawing them
568 // if this becomes the case.
569 if (clip_region) {
570 return;
571 }
548 SetBlendEnabled(quad->ShouldDrawWithBlending()); 572 SetBlendEnabled(quad->ShouldDrawWithBlending());
549 573
550 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); 574 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
551 DCHECK(program && (program->initialized() || IsContextLost())); 575 DCHECK(program && (program->initialized() || IsContextLost()));
552 SetUseProgram(program->program()); 576 SetUseProgram(program->program());
553 577
554 SkColor color = quad->color; 578 SkColor color = quad->color;
555 GLC(gl_, 579 GLC(gl_,
556 gl_->Uniform4f(program->fragment_shader().color_location(), 580 gl_->Uniform4f(program->fragment_shader().color_location(),
557 SkColorGetR(color) * (1.0f / 255.0f), 581 SkColorGetR(color) * (1.0f / 255.0f),
(...skipping 23 matching lines...) Expand all
581 frequency)); 605 frequency));
582 606
583 SetShaderOpacity(quad->opacity(), 607 SetShaderOpacity(quad->opacity(),
584 program->fragment_shader().alpha_location()); 608 program->fragment_shader().alpha_location());
585 DrawQuadGeometry(frame, 609 DrawQuadGeometry(frame,
586 quad->quadTransform(), 610 quad->quadTransform(),
587 quad->rect, 611 quad->rect,
588 program->vertex_shader().matrix_location()); 612 program->vertex_shader().matrix_location());
589 } 613 }
590 614
615 // This function does not handle 3D sorting right now, since the debug border
616 // quads are just drawn as their original quads and not in split pieces. This
617 // results in some debug border quads drawing over foreground quads.
591 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 618 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
592 const DebugBorderDrawQuad* quad) { 619 const DebugBorderDrawQuad* quad) {
593 SetBlendEnabled(quad->ShouldDrawWithBlending()); 620 SetBlendEnabled(quad->ShouldDrawWithBlending());
594 621
595 static float gl_matrix[16]; 622 static float gl_matrix[16];
596 const DebugBorderProgram* program = GetDebugBorderProgram(); 623 const DebugBorderProgram* program = GetDebugBorderProgram();
597 DCHECK(program && (program->initialized() || IsContextLost())); 624 DCHECK(program && (program->initialized() || IsContextLost()));
598 SetUseProgram(program->program()); 625 SetUseProgram(program->program());
599 626
600 // Use the full quad_rect for debug quads to not move the edges based on 627 // Use the full quad_rect for debug quads to not move the edges based on
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 if (frame->current_render_pass->has_transparent_background) 839 if (frame->current_render_pass->has_transparent_background)
813 return false; 840 return false;
814 841
815 // TODO(ajuma): Add support for reference filters once 842 // TODO(ajuma): Add support for reference filters once
816 // FilterOperations::GetOutsets supports reference filters. 843 // FilterOperations::GetOutsets supports reference filters.
817 if (quad->background_filters.HasReferenceFilter()) 844 if (quad->background_filters.HasReferenceFilter())
818 return false; 845 return false;
819 return true; 846 return true;
820 } 847 }
821 848
849 // This takes a gfx::Rect and a clip region quad in the same space,
850 // and returns a quad with the same proportions in the space -0.5->0.5.
851 bool GetScaledRegion(const gfx::Rect& rect,
852 const gfx::QuadF* clip,
853 gfx::QuadF* scaled_region) {
854 if (!clip)
855 return false;
856
857 gfx::PointF p1(((clip->p1().x() - rect.x()) / rect.width()) - 0.5f,
858 ((clip->p1().y() - rect.y()) / rect.height()) - 0.5f);
859 gfx::PointF p2(((clip->p2().x() - rect.x()) / rect.width()) - 0.5f,
860 ((clip->p2().y() - rect.y()) / rect.height()) - 0.5f);
861 gfx::PointF p3(((clip->p3().x() - rect.x()) / rect.width()) - 0.5f,
862 ((clip->p3().y() - rect.y()) / rect.height()) - 0.5f);
863 gfx::PointF p4(((clip->p4().x() - rect.x()) / rect.width()) - 0.5f,
864 ((clip->p4().y() - rect.y()) / rect.height()) - 0.5f);
865 *scaled_region = gfx::QuadF(p1, p2, p3, p4);
866 return true;
867 }
868
869 // This takes a gfx::Rect and a clip region quad in the same space,
870 // and returns the proportional uv's in the space 0->1.
871 bool GetScaledUVs(const gfx::Rect& rect, const gfx::QuadF* clip, float uvs[8]) {
872 if (!clip)
873 return false;
874
875 uvs[0] = ((clip->p1().x() - rect.x()) / rect.width());
876 uvs[1] = ((clip->p1().y() - rect.y()) / rect.height());
877 uvs[2] = ((clip->p2().x() - rect.x()) / rect.width());
878 uvs[3] = ((clip->p2().y() - rect.y()) / rect.height());
879 uvs[4] = ((clip->p3().x() - rect.x()) / rect.width());
880 uvs[5] = ((clip->p3().y() - rect.y()) / rect.height());
881 uvs[6] = ((clip->p4().x() - rect.x()) / rect.width());
882 uvs[7] = ((clip->p4().y() - rect.y()) / rect.height());
883 return true;
884 }
885
822 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad( 886 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(
823 DrawingFrame* frame, 887 DrawingFrame* frame,
824 const RenderPassDrawQuad* quad, 888 const RenderPassDrawQuad* quad,
825 const gfx::Transform& contents_device_transform, 889 const gfx::Transform& contents_device_transform,
890 const gfx::QuadF* clip_region,
826 bool use_aa) { 891 bool use_aa) {
892 gfx::QuadF scaled_region;
893 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) {
894 scaled_region = SharedGeometryQuad().BoundingBox();
895 }
896
827 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( 897 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect(
828 contents_device_transform, SharedGeometryQuad().BoundingBox())); 898 contents_device_transform, scaled_region.BoundingBox()));
829 899
830 if (ShouldApplyBackgroundFilters(frame, quad)) { 900 if (ShouldApplyBackgroundFilters(frame, quad)) {
831 int top, right, bottom, left; 901 int top, right, bottom, left;
832 quad->background_filters.GetOutsets(&top, &right, &bottom, &left); 902 quad->background_filters.GetOutsets(&top, &right, &bottom, &left);
833 backdrop_rect.Inset(-left, -top, -right, -bottom); 903 backdrop_rect.Inset(-left, -top, -right, -bottom);
834 } 904 }
835 905
836 if (!backdrop_rect.IsEmpty() && use_aa) { 906 if (!backdrop_rect.IsEmpty() && use_aa) {
837 const int kOutsetForAntialiasing = 1; 907 const int kOutsetForAntialiasing = 1;
838 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing); 908 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing);
(...skipping 28 matching lines...) Expand all
867 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 937 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
868 quad->background_filters, background_texture->size()); 938 quad->background_filters, background_texture->size());
869 939
870 skia::RefPtr<SkImage> background_with_filters = ApplyImageFilter( 940 skia::RefPtr<SkImage> background_with_filters = ApplyImageFilter(
871 ScopedUseGrContext::Create(this, frame), resource_provider_, quad->rect, 941 ScopedUseGrContext::Create(this, frame), resource_provider_, quad->rect,
872 quad->filters_scale, filter.get(), background_texture); 942 quad->filters_scale, filter.get(), background_texture);
873 return background_with_filters; 943 return background_with_filters;
874 } 944 }
875 945
876 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 946 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
877 const RenderPassDrawQuad* quad) { 947 const RenderPassDrawQuad* quad,
948 const gfx::QuadF* clip_region) {
878 ScopedResource* contents_texture = 949 ScopedResource* contents_texture =
879 render_pass_textures_.get(quad->render_pass_id); 950 render_pass_textures_.get(quad->render_pass_id);
880 if (!contents_texture || !contents_texture->id()) 951 if (!contents_texture || !contents_texture->id())
881 return; 952 return;
882 953
883 gfx::Transform quad_rect_matrix; 954 gfx::Transform quad_rect_matrix;
884 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 955 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
885 gfx::Transform contents_device_transform = 956 gfx::Transform contents_device_transform =
886 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 957 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
887 contents_device_transform.FlattenTo2d(); 958 contents_device_transform.FlattenTo2d();
888 959
889 // Can only draw surface if device matrix is invertible. 960 // Can only draw surface if device matrix is invertible.
890 if (!contents_device_transform.IsInvertible()) 961 if (!contents_device_transform.IsInvertible())
891 return; 962 return;
892 963
893 gfx::QuadF surface_quad = SharedGeometryQuad(); 964 gfx::QuadF surface_quad = SharedGeometryQuad();
894 float edge[24]; 965 float edge[24];
895 bool use_aa = settings_->allow_antialiasing && 966 bool use_aa = settings_->allow_antialiasing &&
896 ShouldAntialiasQuad(contents_device_transform, quad, 967 ShouldAntialiasQuad(contents_device_transform, quad,
897 settings_->force_antialiasing); 968 settings_->force_antialiasing);
898 969
899 if (use_aa) 970 SetupQuadForClippingAndAntialiasing(contents_device_transform, quad, use_aa,
900 SetupQuadForAntialiasing(contents_device_transform, quad, 971 clip_region, &surface_quad, edge);
901 &surface_quad, edge);
902
903 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; 972 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
904 bool use_shaders_for_blending = 973 bool use_shaders_for_blending =
905 !CanApplyBlendModeUsingBlendFunc(blend_mode) || 974 !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
906 ShouldApplyBackgroundFilters(frame, quad) || 975 ShouldApplyBackgroundFilters(frame, quad) ||
907 settings_->force_blending_with_shaders; 976 settings_->force_blending_with_shaders;
908 977
909 scoped_ptr<ScopedResource> background_texture; 978 scoped_ptr<ScopedResource> background_texture;
910 skia::RefPtr<SkImage> background_image; 979 skia::RefPtr<SkImage> background_image;
911 gfx::Rect background_rect; 980 gfx::Rect background_rect;
912 if (use_shaders_for_blending) { 981 if (use_shaders_for_blending) {
913 // Compute a bounding box around the pixels that will be visible through 982 // Compute a bounding box around the pixels that will be visible through
914 // the quad. 983 // the quad.
915 background_rect = GetBackdropBoundingBoxForRenderPassQuad( 984 background_rect = GetBackdropBoundingBoxForRenderPassQuad(
916 frame, quad, contents_device_transform, use_aa); 985 frame, quad, contents_device_transform, clip_region, use_aa);
917 986
918 if (!background_rect.IsEmpty()) { 987 if (!background_rect.IsEmpty()) {
919 // The pixels from the filtered background should completely replace the 988 // The pixels from the filtered background should completely replace the
920 // current pixel values. 989 // current pixel values.
921 if (blend_enabled()) 990 if (blend_enabled())
922 SetBlendEnabled(false); 991 SetBlendEnabled(false);
923 992
924 // Read the pixels in the bounding box into a buffer R. 993 // Read the pixels in the bounding box into a buffer R.
925 // This function allocates a texture, which should contribute to the 994 // This function allocates a texture, which should contribute to the
926 // amount of memory used by render surfaces: 995 // amount of memory used by render surfaces:
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 static void SolidColorUniformLocation(T program, 1300 static void SolidColorUniformLocation(T program,
1232 SolidColorProgramUniforms* uniforms) { 1301 SolidColorProgramUniforms* uniforms) {
1233 uniforms->program = program->program(); 1302 uniforms->program = program->program();
1234 uniforms->matrix_location = program->vertex_shader().matrix_location(); 1303 uniforms->matrix_location = program->vertex_shader().matrix_location();
1235 uniforms->viewport_location = program->vertex_shader().viewport_location(); 1304 uniforms->viewport_location = program->vertex_shader().viewport_location();
1236 uniforms->quad_location = program->vertex_shader().quad_location(); 1305 uniforms->quad_location = program->vertex_shader().quad_location();
1237 uniforms->edge_location = program->vertex_shader().edge_location(); 1306 uniforms->edge_location = program->vertex_shader().edge_location();
1238 uniforms->color_location = program->fragment_shader().color_location(); 1307 uniforms->color_location = program->fragment_shader().color_location();
1239 } 1308 }
1240 1309
1310 namespace {
1311 // These functions determine if a quad, clipped by a clip_region contains
1312 // the entire {top|bottom|left|right} edge.
1313 bool is_top(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1314 if (!quad->IsTopEdge())
1315 return false;
1316 if (!clip_region)
1317 return true;
1318
1319 return std::abs(clip_region->p1().y()) < kAntiAliasingEpsilon &&
1320 std::abs(clip_region->p2().y()) < kAntiAliasingEpsilon;
1321 }
1322
1323 bool is_bottom(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1324 if (!quad->IsBottomEdge())
1325 return false;
1326 if (!clip_region)
1327 return true;
1328
1329 return std::abs(clip_region->p3().y() -
1330 quad->shared_quad_state->content_bounds.height()) <
1331 kAntiAliasingEpsilon &&
1332 std::abs(clip_region->p4().y() -
1333 quad->shared_quad_state->content_bounds.height()) <
1334 kAntiAliasingEpsilon;
1335 }
1336
1337 bool is_left(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1338 if (!quad->IsLeftEdge())
1339 return false;
1340 if (!clip_region)
1341 return true;
1342
1343 return std::abs(clip_region->p1().x()) < kAntiAliasingEpsilon &&
1344 std::abs(clip_region->p4().x()) < kAntiAliasingEpsilon;
1345 }
1346
1347 bool is_right(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1348 if (!quad->IsRightEdge())
1349 return false;
1350 if (!clip_region)
1351 return true;
1352
1353 return std::abs(clip_region->p2().x() -
1354 quad->shared_quad_state->content_bounds.width()) <
1355 kAntiAliasingEpsilon &&
1356 std::abs(clip_region->p3().x() -
1357 quad->shared_quad_state->content_bounds.width()) <
1358 kAntiAliasingEpsilon;
1359 }
1360 } // anonymous namespace
1361
1241 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( 1362 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges(
1242 const LayerQuad& device_layer_edges, 1363 const LayerQuad& device_layer_edges,
1243 const gfx::Transform& device_transform, 1364 const gfx::Transform& device_transform,
1365 const gfx::QuadF* clip_region,
1244 const DrawQuad* quad) { 1366 const DrawQuad* quad) {
1245 gfx::Rect tile_rect = quad->visible_rect; 1367 gfx::RectF tile_rect = quad->visible_rect;
1246 gfx::PointF bottom_right = tile_rect.bottom_right(); 1368 gfx::QuadF tile_quad(tile_rect);
1247 gfx::PointF bottom_left = tile_rect.bottom_left(); 1369
1248 gfx::PointF top_left = tile_rect.origin(); 1370 if (clip_region) {
1249 gfx::PointF top_right = tile_rect.top_right(); 1371 if (quad->material != DrawQuad::RENDER_PASS) {
1372 tile_quad = *clip_region;
1373 } else {
1374 GetScaledRegion(quad->rect, clip_region, &tile_quad);
1375 }
1376 }
1377
1378 gfx::PointF bottom_right = tile_quad.p3();
1379 gfx::PointF bottom_left = tile_quad.p4();
1380 gfx::PointF top_left = tile_quad.p1();
1381 gfx::PointF top_right = tile_quad.p2();
1250 bool clipped = false; 1382 bool clipped = false;
1251 1383
1252 // Map points to device space. We ignore |clipped|, since the result of 1384 // Map points to device space. We ignore |clipped|, since the result of
1253 // |MapPoint()| still produces a valid point to draw the quad with. When 1385 // |MapPoint()| still produces a valid point to draw the quad with. When
1254 // clipped, the point will be outside of the viewport. See crbug.com/416367. 1386 // clipped, the point will be outside of the viewport. See crbug.com/416367.
1255 bottom_right = MathUtil::MapPoint(device_transform, bottom_right, &clipped); 1387 bottom_right = MathUtil::MapPoint(device_transform, bottom_right, &clipped);
1256 bottom_left = MathUtil::MapPoint(device_transform, bottom_left, &clipped); 1388 bottom_left = MathUtil::MapPoint(device_transform, bottom_left, &clipped);
1257 top_left = MathUtil::MapPoint(device_transform, top_left, &clipped); 1389 top_left = MathUtil::MapPoint(device_transform, top_left, &clipped);
1258 top_right = MathUtil::MapPoint(device_transform, top_right, &clipped); 1390 top_right = MathUtil::MapPoint(device_transform, top_right, &clipped);
1259 1391
1260 LayerQuad::Edge bottom_edge(bottom_right, bottom_left); 1392 LayerQuad::Edge bottom_edge(bottom_right, bottom_left);
1261 LayerQuad::Edge left_edge(bottom_left, top_left); 1393 LayerQuad::Edge left_edge(bottom_left, top_left);
1262 LayerQuad::Edge top_edge(top_left, top_right); 1394 LayerQuad::Edge top_edge(top_left, top_right);
1263 LayerQuad::Edge right_edge(top_right, bottom_right); 1395 LayerQuad::Edge right_edge(top_right, bottom_right);
1264 1396
1265 // Only apply anti-aliasing to edges not clipped by culling or scissoring. 1397 // Only apply anti-aliasing to edges not clipped by culling or scissoring.
1266 if (quad->IsTopEdge() && tile_rect.y() == quad->rect.y()) 1398 // If an edge is degenerate we do not want to replace it with a "proper" edge
1399 // as that will cause the quad to possibly expand is strange ways.
1400 if (!top_edge.degenerate() && is_top(clip_region, quad) &&
1401 tile_rect.y() == quad->rect.y()) {
1267 top_edge = device_layer_edges.top(); 1402 top_edge = device_layer_edges.top();
1268 if (quad->IsLeftEdge() && tile_rect.x() == quad->rect.x()) 1403 }
1404 if (!left_edge.degenerate() && is_left(clip_region, quad) &&
1405 tile_rect.x() == quad->rect.x()) {
1269 left_edge = device_layer_edges.left(); 1406 left_edge = device_layer_edges.left();
1270 if (quad->IsRightEdge() && tile_rect.right() == quad->rect.right()) 1407 }
1408 if (!right_edge.degenerate() && is_right(clip_region, quad) &&
1409 tile_rect.right() == quad->rect.right()) {
1271 right_edge = device_layer_edges.right(); 1410 right_edge = device_layer_edges.right();
1272 if (quad->IsBottomEdge() && tile_rect.bottom() == quad->rect.bottom()) 1411 }
1412 if (!bottom_edge.degenerate() && is_bottom(clip_region, quad) &&
1413 tile_rect.bottom() == quad->rect.bottom()) {
1273 bottom_edge = device_layer_edges.bottom(); 1414 bottom_edge = device_layer_edges.bottom();
1415 }
1274 1416
1275 float sign = gfx::QuadF(tile_rect).IsCounterClockwise() ? -1 : 1; 1417 float sign = tile_quad.IsCounterClockwise() ? -1 : 1;
1276 bottom_edge.scale(sign); 1418 bottom_edge.scale(sign);
1277 left_edge.scale(sign); 1419 left_edge.scale(sign);
1278 top_edge.scale(sign); 1420 top_edge.scale(sign);
1279 right_edge.scale(sign); 1421 right_edge.scale(sign);
1280 1422
1281 // Create device space quad. 1423 // Create device space quad.
1282 return LayerQuad(left_edge, top_edge, right_edge, bottom_edge).ToQuadF(); 1424 return LayerQuad(left_edge, top_edge, right_edge, bottom_edge).ToQuadF();
1283 } 1425 }
1284 1426
1427 float GetTotalQuadError(const gfx::QuadF* clipped_quad,
1428 const gfx::QuadF* ideal_rect) {
1429 return (clipped_quad->p1() - ideal_rect->p1()).LengthSquared() +
1430 (clipped_quad->p2() - ideal_rect->p2()).LengthSquared() +
1431 (clipped_quad->p3() - ideal_rect->p3()).LengthSquared() +
1432 (clipped_quad->p4() - ideal_rect->p4()).LengthSquared();
1433 }
1434
1435 // Attempt to rotate the clipped quad until it lines up the most
1436 // correctly. This is necessary because we check the edges of this
1437 // quad against the expected left/right/top/bottom for anti-aliasing.
1438 void AlignQuadToBoundingBox(gfx::QuadF* clipped_quad) {
1439 gfx::QuadF bounding_quad = gfx::QuadF(clipped_quad->BoundingBox());
1440 gfx::QuadF best_rotation = *clipped_quad;
1441 float least_error_amount = GetTotalQuadError(clipped_quad, &bounding_quad);
1442 for (size_t i = 1; i < 4; ++i) {
1443 clipped_quad->Realign(1);
1444 float new_error = GetTotalQuadError(clipped_quad, &bounding_quad);
1445 if (new_error < least_error_amount) {
1446 least_error_amount = new_error;
1447 best_rotation = *clipped_quad;
1448 }
1449 }
1450 *clipped_quad = best_rotation;
1451 }
1452
1285 // static 1453 // static
1286 bool GLRenderer::ShouldAntialiasQuad(const gfx::Transform& device_transform, 1454 bool GLRenderer::ShouldAntialiasQuad(const gfx::Transform& device_transform,
1287 const DrawQuad* quad, 1455 const DrawQuad* quad,
1288 bool force_antialiasing) { 1456 bool force_antialiasing) {
1289 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS); 1457 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS);
1290 // For render pass quads, |device_transform| already contains quad's rect. 1458 // For render pass quads, |device_transform| already contains quad's rect.
1291 // TODO(rosca@adobe.com): remove branching on is_render_pass_quad 1459 // TODO(rosca@adobe.com): remove branching on is_render_pass_quad
1292 // crbug.com/429702 1460 // crbug.com/429702
1293 if (!is_render_pass_quad && !quad->IsEdge()) 1461 if (!is_render_pass_quad && !quad->IsEdge())
1294 return false; 1462 return false;
(...skipping 11 matching lines...) Expand all
1306 bool is_nearest_rect_within_epsilon = 1474 bool is_nearest_rect_within_epsilon =
1307 is_axis_aligned_in_target && 1475 is_axis_aligned_in_target &&
1308 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), 1476 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(),
1309 kAntiAliasingEpsilon); 1477 kAntiAliasingEpsilon);
1310 // AAing clipped quads is not supported by the code yet. 1478 // AAing clipped quads is not supported by the code yet.
1311 bool use_aa = !clipped && !is_nearest_rect_within_epsilon; 1479 bool use_aa = !clipped && !is_nearest_rect_within_epsilon;
1312 return use_aa || force_antialiasing; 1480 return use_aa || force_antialiasing;
1313 } 1481 }
1314 1482
1315 // static 1483 // static
1316 void GLRenderer::SetupQuadForAntialiasing( 1484 void GLRenderer::SetupQuadForClippingAndAntialiasing(
1317 const gfx::Transform& device_transform, 1485 const gfx::Transform& device_transform,
1318 const DrawQuad* quad, 1486 const DrawQuad* quad,
1487 bool use_aa,
1488 const gfx::QuadF* clip_region,
1319 gfx::QuadF* local_quad, 1489 gfx::QuadF* local_quad,
1320 float edge[24]) { 1490 float edge[24]) {
1321 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS); 1491 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS);
1322 gfx::RectF content_rect = 1492 gfx::QuadF rotated_clip;
1323 is_render_pass_quad ? QuadVertexRect() : quad->visibleContentRect(); 1493 const gfx::QuadF* local_clip_region = clip_region;
1494 if (local_clip_region) {
1495 rotated_clip = *clip_region;
1496 AlignQuadToBoundingBox(&rotated_clip);
1497 local_clip_region = &rotated_clip;
1498 }
1324 1499
1500 gfx::QuadF content_rect = is_render_pass_quad
1501 ? gfx::QuadF(QuadVertexRect())
1502 : gfx::QuadF(quad->visibleContentRect());
1503 if (!use_aa) {
1504 if (local_clip_region) {
1505 if (!is_render_pass_quad) {
1506 content_rect = *local_clip_region;
1507 } else {
1508 GetScaledRegion(quad->rect, local_clip_region, &content_rect);
1509 }
1510 *local_quad = content_rect;
1511 }
1512 return;
1513 }
1325 bool clipped = false; 1514 bool clipped = false;
1326 gfx::QuadF device_layer_quad = 1515 gfx::QuadF device_layer_quad =
1327 MathUtil::MapQuad(device_transform, gfx::QuadF(content_rect), &clipped); 1516 MathUtil::MapQuad(device_transform, content_rect, &clipped);
1328 1517
1329 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox())); 1518 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox()));
1330 device_layer_bounds.InflateAntiAliasingDistance(); 1519 device_layer_bounds.InflateAntiAliasingDistance();
1331 1520
1332 LayerQuad device_layer_edges(device_layer_quad); 1521 LayerQuad device_layer_edges(device_layer_quad);
1333 device_layer_edges.InflateAntiAliasingDistance(); 1522 device_layer_edges.InflateAntiAliasingDistance();
1334 1523
1335 device_layer_edges.ToFloatArray(edge); 1524 device_layer_edges.ToFloatArray(edge);
1336 device_layer_bounds.ToFloatArray(&edge[12]); 1525 device_layer_bounds.ToFloatArray(&edge[12]);
1337 1526
1527 // If we have a clip region then we are split, and therefore
1528 // by necessity, at least one of our edges is not an external
1529 // one.
1530 bool is_full_rect = quad->visible_rect == quad->rect;
1531
1532 bool region_contains_all_outside_edges =
1533 is_full_rect &&
1534 (is_top(local_clip_region, quad) && is_left(local_clip_region, quad) &&
1535 is_bottom(local_clip_region, quad) && is_right(local_clip_region, quad));
1536
1338 bool use_aa_on_all_four_edges = 1537 bool use_aa_on_all_four_edges =
1339 is_render_pass_quad || 1538 !local_clip_region &&
1340 (quad->IsTopEdge() && quad->IsLeftEdge() && quad->IsBottomEdge() && 1539 (is_render_pass_quad || region_contains_all_outside_edges);
1341 quad->IsRightEdge() && quad->visible_rect == quad->rect);
1342 1540
1343 gfx::QuadF device_quad = 1541 gfx::QuadF device_quad =
1344 use_aa_on_all_four_edges 1542 use_aa_on_all_four_edges
1345 ? device_layer_edges.ToQuadF() 1543 ? device_layer_edges.ToQuadF()
1346 : GetDeviceQuadWithAntialiasingOnExteriorEdges( 1544 : GetDeviceQuadWithAntialiasingOnExteriorEdges(
1347 device_layer_edges, device_transform, quad); 1545 device_layer_edges, device_transform, local_clip_region, quad);
1348 1546
1349 // Map device space quad to local space. device_transform has no 3d 1547 // Map device space quad to local space. device_transform has no 3d
1350 // component since it was flattened, so we don't need to project. We should 1548 // component since it was flattened, so we don't need to project. We should
1351 // have already checked that the transform was uninvertible above. 1549 // have already checked that the transform was uninvertible above.
1352 gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization); 1550 gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization);
1353 bool did_invert = device_transform.GetInverse(&inverse_device_transform); 1551 bool did_invert = device_transform.GetInverse(&inverse_device_transform);
1354 DCHECK(did_invert); 1552 DCHECK(did_invert);
1355 *local_quad = 1553 *local_quad =
1356 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped); 1554 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped);
1357 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may 1555 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may
1358 // cause device_quad to become clipped. To our knowledge this scenario does 1556 // cause device_quad to become clipped. To our knowledge this scenario does
1359 // not need to be handled differently than the unclipped case. 1557 // not need to be handled differently than the unclipped case.
1360 } 1558 }
1361 1559
1362 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 1560 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
1363 const SolidColorDrawQuad* quad) { 1561 const SolidColorDrawQuad* quad,
1562 const gfx::QuadF* clip_region) {
1364 gfx::Rect tile_rect = quad->visible_rect; 1563 gfx::Rect tile_rect = quad->visible_rect;
1365 1564
1366 SkColor color = quad->color; 1565 SkColor color = quad->color;
1367 float opacity = quad->opacity(); 1566 float opacity = quad->opacity();
1368 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; 1567 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
1369 1568
1370 // Early out if alpha is small enough that quad doesn't contribute to output. 1569 // Early out if alpha is small enough that quad doesn't contribute to output.
1371 if (alpha < std::numeric_limits<float>::epsilon() && 1570 if (alpha < std::numeric_limits<float>::epsilon() &&
1372 quad->ShouldDrawWithBlending()) 1571 quad->ShouldDrawWithBlending())
1373 return; 1572 return;
1374 1573
1375 gfx::Transform device_transform = 1574 gfx::Transform device_transform =
1376 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1575 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1377 device_transform.FlattenTo2d(); 1576 device_transform.FlattenTo2d();
1378 if (!device_transform.IsInvertible()) 1577 if (!device_transform.IsInvertible())
1379 return; 1578 return;
1380 1579
1381 bool force_aa = false; 1580 bool force_aa = false;
1382 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1581 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1383 float edge[24]; 1582 float edge[24];
1384 bool use_aa = settings_->allow_antialiasing && 1583 bool use_aa = settings_->allow_antialiasing &&
1385 !quad->force_anti_aliasing_off && 1584 !quad->force_anti_aliasing_off &&
1386 ShouldAntialiasQuad(device_transform, quad, force_aa); 1585 ShouldAntialiasQuad(device_transform, quad, force_aa);
1586 SetupQuadForClippingAndAntialiasing(device_transform, quad, use_aa,
1587 clip_region, &local_quad, edge);
1387 1588
1388 SolidColorProgramUniforms uniforms; 1589 SolidColorProgramUniforms uniforms;
1389 if (use_aa) { 1590 if (use_aa) {
1390 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1391 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); 1591 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms);
1392 } else { 1592 } else {
1393 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); 1593 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
1394 } 1594 }
1395 SetUseProgram(uniforms.program); 1595 SetUseProgram(uniforms.program);
1396 1596
1397 GLC(gl_, 1597 GLC(gl_,
1398 gl_->Uniform4f(uniforms.color_location, 1598 gl_->Uniform4f(uniforms.color_location,
1399 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1599 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1400 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1600 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 uniforms->vertex_tex_transform_location = 1651 uniforms->vertex_tex_transform_location =
1452 program->vertex_shader().vertex_tex_transform_location(); 1652 program->vertex_shader().vertex_tex_transform_location();
1453 1653
1454 uniforms->sampler_location = program->fragment_shader().sampler_location(); 1654 uniforms->sampler_location = program->fragment_shader().sampler_location();
1455 uniforms->alpha_location = program->fragment_shader().alpha_location(); 1655 uniforms->alpha_location = program->fragment_shader().alpha_location();
1456 uniforms->fragment_tex_transform_location = 1656 uniforms->fragment_tex_transform_location =
1457 program->fragment_shader().fragment_tex_transform_location(); 1657 program->fragment_shader().fragment_tex_transform_location();
1458 } 1658 }
1459 1659
1460 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, 1660 void GLRenderer::DrawTileQuad(const DrawingFrame* frame,
1461 const TileDrawQuad* quad) { 1661 const TileDrawQuad* quad,
1462 DrawContentQuad(frame, quad, quad->resource_id); 1662 const gfx::QuadF* clip_region) {
1663 DrawContentQuad(frame, quad, quad->resource_id, clip_region);
1463 } 1664 }
1464 1665
1465 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, 1666 void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
1466 const ContentDrawQuadBase* quad, 1667 const ContentDrawQuadBase* quad,
1467 ResourceProvider::ResourceId resource_id) { 1668 ResourceProvider::ResourceId resource_id,
1669 const gfx::QuadF* clip_region) {
1468 gfx::Transform device_transform = 1670 gfx::Transform device_transform =
1469 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1671 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1470 device_transform.FlattenTo2d(); 1672 device_transform.FlattenTo2d();
1471 1673
1472 bool use_aa = settings_->allow_antialiasing && 1674 bool use_aa = settings_->allow_antialiasing &&
1473 ShouldAntialiasQuad(device_transform, quad, false); 1675 ShouldAntialiasQuad(device_transform, quad, false);
1474 1676
1475 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA 1677 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA
1476 // similar to the way DrawContentQuadNoAA works and then consider 1678 // similar to the way DrawContentQuadNoAA works and then consider
1477 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. 1679 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method.
1478 if (use_aa) 1680 if (use_aa)
1479 DrawContentQuadAA(frame, quad, resource_id, device_transform); 1681 DrawContentQuadAA(frame, quad, resource_id, device_transform, clip_region);
1480 else 1682 else
1481 DrawContentQuadNoAA(frame, quad, resource_id); 1683 DrawContentQuadNoAA(frame, quad, resource_id, clip_region);
1482 } 1684 }
1483 1685
1484 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame, 1686 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame,
1485 const ContentDrawQuadBase* quad, 1687 const ContentDrawQuadBase* quad,
1486 ResourceProvider::ResourceId resource_id, 1688 ResourceProvider::ResourceId resource_id,
1487 const gfx::Transform& device_transform) { 1689 const gfx::Transform& device_transform,
1690 const gfx::QuadF* clip_region) {
1488 if (!device_transform.IsInvertible()) 1691 if (!device_transform.IsInvertible())
1489 return; 1692 return;
1490 1693
1491 gfx::Rect tile_rect = quad->visible_rect; 1694 gfx::Rect tile_rect = quad->visible_rect;
1492 1695
1493 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1696 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1494 quad->tex_coord_rect, quad->rect, tile_rect); 1697 quad->tex_coord_rect, quad->rect, tile_rect);
1495 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1698 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1496 float tex_to_geom_scale_y = 1699 float tex_to_geom_scale_y =
1497 quad->rect.height() / quad->tex_coord_rect.height(); 1700 quad->rect.height() / quad->tex_coord_rect.height();
(...skipping 24 matching lines...) Expand all
1522 float vertex_tex_translate_y = 1725 float vertex_tex_translate_y =
1523 -clamp_geom_rect.y() / clamp_geom_rect.height(); 1726 -clamp_geom_rect.y() / clamp_geom_rect.height();
1524 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); 1727 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width();
1525 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); 1728 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
1526 1729
1527 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1730 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1528 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1731 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
1529 1732
1530 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1733 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1531 float edge[24]; 1734 float edge[24];
1532 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); 1735 SetupQuadForClippingAndAntialiasing(device_transform, quad, true, clip_region,
1533 1736 &local_quad, edge);
1534 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1737 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1535 resource_provider_, resource_id, 1738 resource_provider_, resource_id,
1536 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR); 1739 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR);
1537 SamplerType sampler = 1740 SamplerType sampler =
1538 SamplerTypeFromTextureTarget(quad_resource_lock.target()); 1741 SamplerTypeFromTextureTarget(quad_resource_lock.target());
1539 1742
1540 float fragment_tex_translate_x = clamp_tex_rect.x(); 1743 float fragment_tex_translate_x = clamp_tex_rect.x();
1541 float fragment_tex_translate_y = clamp_tex_rect.y(); 1744 float fragment_tex_translate_y = clamp_tex_rect.y();
1542 float fragment_tex_scale_x = clamp_tex_rect.width(); 1745 float fragment_tex_scale_x = clamp_tex_rect.width();
1543 float fragment_tex_scale_y = clamp_tex_rect.height(); 1746 float fragment_tex_scale_y = clamp_tex_rect.height();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 // it. This is why this centered rect is used and not the original quad_rect. 1804 // it. This is why this centered rect is used and not the original quad_rect.
1602 gfx::RectF centered_rect( 1805 gfx::RectF centered_rect(
1603 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1806 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1604 tile_rect.size()); 1807 tile_rect.size());
1605 DrawQuadGeometry( 1808 DrawQuadGeometry(
1606 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); 1809 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
1607 } 1810 }
1608 1811
1609 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 1812 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
1610 const ContentDrawQuadBase* quad, 1813 const ContentDrawQuadBase* quad,
1611 ResourceProvider::ResourceId resource_id) { 1814 ResourceProvider::ResourceId resource_id,
1815 const gfx::QuadF* clip_region) {
1612 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1816 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1613 quad->tex_coord_rect, quad->rect, quad->visible_rect); 1817 quad->tex_coord_rect, quad->rect, quad->visible_rect);
1614 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1818 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1615 float tex_to_geom_scale_y = 1819 float tex_to_geom_scale_y =
1616 quad->rect.height() / quad->tex_coord_rect.height(); 1820 quad->rect.height() / quad->tex_coord_rect.height();
1617 1821
1618 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); 1822 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
1619 GLenum filter = 1823 GLenum filter =
1620 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) && 1824 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) &&
1621 !quad->nearest_neighbor 1825 !quad->nearest_neighbor
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 vertex_tex_scale_y)); 1879 vertex_tex_scale_y));
1676 1880
1677 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1881 SetBlendEnabled(quad->ShouldDrawWithBlending());
1678 1882
1679 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1883 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1680 1884
1681 // Pass quad coordinates to the uniform in the same order as GeometryBinding 1885 // Pass quad coordinates to the uniform in the same order as GeometryBinding
1682 // does, then vertices will match the texture mapping in the vertex buffer. 1886 // does, then vertices will match the texture mapping in the vertex buffer.
1683 // The method SetShaderQuadF() changes the order of vertices and so it's 1887 // The method SetShaderQuadF() changes the order of vertices and so it's
1684 // not used here. 1888 // not used here.
1685 1889 gfx::QuadF tile_rect(quad->visible_rect);
1686 gfx::RectF tile_rect = quad->visible_rect; 1890 float width = quad->visible_rect.width();
1891 float height = quad->visible_rect.height();
1892 gfx::PointF top_left = quad->visible_rect.origin();
1893 if (clip_region) {
1894 tile_rect = *clip_region;
1895 float gl_uv[8] = {
1896 (tile_rect.p4().x() - top_left.x()) / width,
1897 (tile_rect.p4().y() - top_left.y()) / height,
1898 (tile_rect.p1().x() - top_left.x()) / width,
1899 (tile_rect.p1().y() - top_left.y()) / height,
1900 (tile_rect.p2().x() - top_left.x()) / width,
1901 (tile_rect.p2().y() - top_left.y()) / height,
1902 (tile_rect.p3().x() - top_left.x()) / width,
1903 (tile_rect.p3().y() - top_left.y()) / height,
1904 };
1905 PrepareGeometry(CLIPPED_BINDING);
1906 clipped_geometry_->InitializeCustomQuadWithUVs(
1907 gfx::QuadF(quad->visible_rect), gl_uv);
1908 } else {
1909 PrepareGeometry(SHARED_BINDING);
1910 }
1687 float gl_quad[8] = { 1911 float gl_quad[8] = {
1688 tile_rect.x(), 1912 tile_rect.p4().x(),
1689 tile_rect.bottom(), 1913 tile_rect.p4().y(),
1690 tile_rect.x(), 1914 tile_rect.p1().x(),
1691 tile_rect.y(), 1915 tile_rect.p1().y(),
1692 tile_rect.right(), 1916 tile_rect.p2().x(),
1693 tile_rect.y(), 1917 tile_rect.p2().y(),
1694 tile_rect.right(), 1918 tile_rect.p3().x(),
1695 tile_rect.bottom(), 1919 tile_rect.p3().y(),
1696 }; 1920 };
1697 GLC(gl_, gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad)); 1921 GLC(gl_, gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad));
1698 1922
1699 static float gl_matrix[16]; 1923 static float gl_matrix[16];
1700 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform()); 1924 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform());
1701 GLC(gl_, 1925 GLC(gl_,
1702 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0])); 1926 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]));
1703 1927
1704 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 1928 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
1705 } 1929 }
1706 1930
1707 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, 1931 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
1708 const YUVVideoDrawQuad* quad) { 1932 const YUVVideoDrawQuad* quad,
1933 const gfx::QuadF* clip_region) {
1709 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1934 SetBlendEnabled(quad->ShouldDrawWithBlending());
1710 1935
1711 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1936 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1712 gl_, 1937 gl_,
1713 &highp_threshold_cache_, 1938 &highp_threshold_cache_,
1714 highp_threshold_min_, 1939 highp_threshold_min_,
1715 quad->shared_quad_state->visible_content_rect.bottom_right()); 1940 quad->shared_quad_state->visible_content_rect.bottom_right());
1716 1941
1717 bool use_alpha_plane = quad->a_plane_resource_id != 0; 1942 bool use_alpha_plane = quad->a_plane_resource_id != 0;
1718 1943
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 case YUVVideoDrawQuad::REC_709: 2063 case YUVVideoDrawQuad::REC_709:
1839 yuv_to_rgb = yuv_to_rgb_rec709; 2064 yuv_to_rgb = yuv_to_rgb_rec709;
1840 yuv_adjust = yuv_adjust_constrained; 2065 yuv_adjust = yuv_adjust_constrained;
1841 break; 2066 break;
1842 case YUVVideoDrawQuad::JPEG: 2067 case YUVVideoDrawQuad::JPEG:
1843 yuv_to_rgb = yuv_to_rgb_jpeg; 2068 yuv_to_rgb = yuv_to_rgb_jpeg;
1844 yuv_adjust = yuv_adjust_full; 2069 yuv_adjust = yuv_adjust_full;
1845 break; 2070 break;
1846 } 2071 }
1847 2072
2073 // The transform and vertex data are used to figure out the extents that the
2074 // un-antialiased quad should have and which vertex this is and the float
2075 // quad passed in via uniform is the actual geometry that gets used to draw
2076 // it. This is why this centered rect is used and not the original quad_rect.
2077 gfx::RectF tile_rect = quad->visible_rect;
1848 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 2078 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1849 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 2079 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
1850 2080
1851 SetShaderOpacity(quad->opacity(), alpha_location); 2081 SetShaderOpacity(quad->opacity(), alpha_location);
1852 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 2082 if (!clip_region) {
2083 DrawQuadGeometry(frame, quad->quadTransform(), tile_rect, matrix_location);
2084 } else {
2085 float uvs[8] = {0};
2086 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2087 gfx::QuadF region_quad = *clip_region;
2088 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
2089 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2090 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), tile_rect,
2091 region_quad, matrix_location, uvs);
2092 }
1853 } 2093 }
1854 2094
1855 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 2095 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1856 const StreamVideoDrawQuad* quad) { 2096 const StreamVideoDrawQuad* quad,
2097 const gfx::QuadF* clip_region) {
1857 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2098 SetBlendEnabled(quad->ShouldDrawWithBlending());
1858 2099
1859 static float gl_matrix[16]; 2100 static float gl_matrix[16];
1860 2101
1861 DCHECK(capabilities_.using_egl_image); 2102 DCHECK(capabilities_.using_egl_image);
1862 2103
1863 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2104 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1864 gl_, 2105 gl_,
1865 &highp_threshold_cache_, 2106 &highp_threshold_cache_,
1866 highp_threshold_min_, 2107 highp_threshold_min_,
(...skipping 10 matching lines...) Expand all
1877 2118
1878 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2119 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1879 quad->resource_id); 2120 quad->resource_id);
1880 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2121 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
1881 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); 2122 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1882 2123
1883 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2124 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1884 2125
1885 SetShaderOpacity(quad->opacity(), 2126 SetShaderOpacity(quad->opacity(),
1886 program->fragment_shader().alpha_location()); 2127 program->fragment_shader().alpha_location());
1887 DrawQuadGeometry(frame, 2128 if (!clip_region) {
1888 quad->quadTransform(), 2129 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
1889 quad->rect, 2130 program->vertex_shader().matrix_location());
1890 program->vertex_shader().matrix_location()); 2131 } else {
2132 gfx::QuadF region_quad(*clip_region);
2133 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2134 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2135 float uvs[8] = {0};
2136 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2137 DrawQuadGeometryClippedByQuadF(
2138 frame, quad->quadTransform(), quad->rect, region_quad,
2139 program->vertex_shader().matrix_location(), uvs);
2140 }
1891 } 2141 }
1892 2142
1893 struct TextureProgramBinding { 2143 struct TextureProgramBinding {
1894 template <class Program> 2144 template <class Program>
1895 void Set(Program* program) { 2145 void Set(Program* program) {
1896 DCHECK(program); 2146 DCHECK(program);
1897 program_id = program->program(); 2147 program_id = program->program();
1898 sampler_location = program->fragment_shader().sampler_location(); 2148 sampler_location = program->fragment_shader().sampler_location();
1899 matrix_location = program->vertex_shader().matrix_location(); 2149 matrix_location = program->vertex_shader().matrix_location();
1900 background_color_location = 2150 background_color_location =
1901 program->fragment_shader().background_color_location(); 2151 program->fragment_shader().background_color_location();
1902 } 2152 }
1903 int program_id; 2153 int program_id;
1904 int sampler_location; 2154 int sampler_location;
1905 int matrix_location; 2155 int matrix_location;
2156 int transform_location;
1906 int background_color_location; 2157 int background_color_location;
1907 }; 2158 };
1908 2159
1909 struct TexTransformTextureProgramBinding : TextureProgramBinding { 2160 struct TexTransformTextureProgramBinding : TextureProgramBinding {
1910 template <class Program> 2161 template <class Program>
1911 void Set(Program* program) { 2162 void Set(Program* program) {
1912 TextureProgramBinding::Set(program); 2163 TextureProgramBinding::Set(program);
1913 tex_transform_location = program->vertex_shader().tex_transform_location(); 2164 tex_transform_location = program->vertex_shader().tex_transform_location();
1914 vertex_opacity_location = 2165 vertex_opacity_location =
1915 program->vertex_shader().vertex_opacity_location(); 2166 program->vertex_shader().vertex_opacity_location();
1916 } 2167 }
1917 int tex_transform_location; 2168 int tex_transform_location;
1918 int vertex_opacity_location; 2169 int vertex_opacity_location;
1919 }; 2170 };
1920 2171
1921 void GLRenderer::FlushTextureQuadCache() { 2172 void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
1922 // Check to see if we have anything to draw. 2173 // Check to see if we have anything to draw.
1923 if (draw_cache_.program_id == -1) 2174 if (draw_cache_.program_id == -1)
1924 return; 2175 return;
1925 2176
2177 PrepareGeometry(flush_binding);
2178
1926 // Set the correct blending mode. 2179 // Set the correct blending mode.
1927 SetBlendEnabled(draw_cache_.needs_blending); 2180 SetBlendEnabled(draw_cache_.needs_blending);
1928 2181
1929 // Bind the program to the GL state. 2182 // Bind the program to the GL state.
1930 SetUseProgram(draw_cache_.program_id); 2183 SetUseProgram(draw_cache_.program_id);
1931 2184
1932 // Bind the correct texture sampler location. 2185 // Bind the correct texture sampler location.
1933 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); 2186 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
1934 2187
1935 // Assume the current active textures is 0. 2188 // Assume the current active textures is 0.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 gl_->DrawElements(GL_TRIANGLES, 2229 gl_->DrawElements(GL_TRIANGLES,
1977 6 * draw_cache_.matrix_data.size(), 2230 6 * draw_cache_.matrix_data.size(),
1978 GL_UNSIGNED_SHORT, 2231 GL_UNSIGNED_SHORT,
1979 0)); 2232 0));
1980 2233
1981 // Clear the cache. 2234 // Clear the cache.
1982 draw_cache_.program_id = -1; 2235 draw_cache_.program_id = -1;
1983 draw_cache_.uv_xform_data.resize(0); 2236 draw_cache_.uv_xform_data.resize(0);
1984 draw_cache_.vertex_opacity_data.resize(0); 2237 draw_cache_.vertex_opacity_data.resize(0);
1985 draw_cache_.matrix_data.resize(0); 2238 draw_cache_.matrix_data.resize(0);
2239
2240 // If we had a clipped binding, prepare the shared binding for the
2241 // next inserts.
2242 if (flush_binding == CLIPPED_BINDING) {
2243 PrepareGeometry(SHARED_BINDING);
2244 }
1986 } 2245 }
1987 2246
1988 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, 2247 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
1989 const TextureDrawQuad* quad) { 2248 const TextureDrawQuad* quad,
2249 const gfx::QuadF* clip_region) {
2250 // If we have a clip_region then we have to render the next quad
2251 // with dynamic geometry, therefore we must flush all pending
2252 // texture quads.
2253 if (clip_region) {
2254 // We send in false here because we want to flush what's currently in the
2255 // queue using the shared_geometry and not clipped_geometry
2256 FlushTextureQuadCache(SHARED_BINDING);
2257 }
2258
1990 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2259 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1991 gl_, 2260 gl_,
1992 &highp_threshold_cache_, 2261 &highp_threshold_cache_,
1993 highp_threshold_min_, 2262 highp_threshold_min_,
1994 quad->shared_quad_state->visible_content_rect.bottom_right()); 2263 quad->shared_quad_state->visible_content_rect.bottom_right());
1995 2264
1996 // Choose the correct texture program binding 2265 // Choose the correct texture program binding
1997 TexTransformTextureProgramBinding binding; 2266 TexTransformTextureProgramBinding binding;
1998 if (quad->premultiplied_alpha) { 2267 if (quad->premultiplied_alpha) {
1999 if (quad->background_color == SK_ColorTRANSPARENT) { 2268 if (quad->background_color == SK_ColorTRANSPARENT) {
(...skipping 11 matching lines...) Expand all
2011 } 2280 }
2012 2281
2013 int resource_id = quad->resource_id; 2282 int resource_id = quad->resource_id;
2014 2283
2015 if (draw_cache_.program_id != binding.program_id || 2284 if (draw_cache_.program_id != binding.program_id ||
2016 draw_cache_.resource_id != resource_id || 2285 draw_cache_.resource_id != resource_id ||
2017 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || 2286 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() ||
2018 draw_cache_.nearest_neighbor != quad->nearest_neighbor || 2287 draw_cache_.nearest_neighbor != quad->nearest_neighbor ||
2019 draw_cache_.background_color != quad->background_color || 2288 draw_cache_.background_color != quad->background_color ||
2020 draw_cache_.matrix_data.size() >= 8) { 2289 draw_cache_.matrix_data.size() >= 8) {
2021 FlushTextureQuadCache(); 2290 FlushTextureQuadCache(SHARED_BINDING);
2022 draw_cache_.program_id = binding.program_id; 2291 draw_cache_.program_id = binding.program_id;
2023 draw_cache_.resource_id = resource_id; 2292 draw_cache_.resource_id = resource_id;
2024 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); 2293 draw_cache_.needs_blending = quad->ShouldDrawWithBlending();
2025 draw_cache_.nearest_neighbor = quad->nearest_neighbor; 2294 draw_cache_.nearest_neighbor = quad->nearest_neighbor;
2026 draw_cache_.background_color = quad->background_color; 2295 draw_cache_.background_color = quad->background_color;
2027 2296
2028 draw_cache_.uv_xform_location = binding.tex_transform_location; 2297 draw_cache_.uv_xform_location = binding.tex_transform_location;
2029 draw_cache_.background_color_location = binding.background_color_location; 2298 draw_cache_.background_color_location = binding.background_color_location;
2030 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; 2299 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location;
2031 draw_cache_.matrix_location = binding.matrix_location; 2300 draw_cache_.matrix_location = binding.matrix_location;
2032 draw_cache_.sampler_location = binding.sampler_location; 2301 draw_cache_.sampler_location = binding.sampler_location;
2033 } 2302 }
2034 2303
2035 // Generate the uv-transform 2304 // Generate the uv-transform
2036 draw_cache_.uv_xform_data.push_back(UVTransform(quad)); 2305 if (!clip_region) {
2306 draw_cache_.uv_xform_data.push_back(UVTransform(quad));
2307 } else {
2308 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2309 draw_cache_.uv_xform_data.push_back(uv_transform);
2310 }
2037 2311
2038 // Generate the vertex opacity 2312 // Generate the vertex opacity
2039 const float opacity = quad->opacity(); 2313 const float opacity = quad->opacity();
2040 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2314 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
2041 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); 2315 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity);
2042 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); 2316 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity);
2043 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); 2317 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity);
2044 2318
2045 // Generate the transform matrix 2319 // Generate the transform matrix
2046 gfx::Transform quad_rect_matrix; 2320 gfx::Transform quad_rect_matrix;
2047 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 2321 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
2048 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; 2322 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix;
2049 2323
2050 Float16 m; 2324 Float16 m;
2051 quad_rect_matrix.matrix().asColMajorf(m.data); 2325 quad_rect_matrix.matrix().asColMajorf(m.data);
2052 draw_cache_.matrix_data.push_back(m); 2326 draw_cache_.matrix_data.push_back(m);
2327
2328 if (clip_region) {
2329 gfx::QuadF scaled_region;
2330 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) {
2331 scaled_region = SharedGeometryQuad().BoundingBox();
2332 }
2333 // Both the scaled region and the SharedGeomtryQuad are in the space
2334 // -0.5->0.5. We need to move that to the space 0->1.
2335 float uv[8];
2336 uv[0] = scaled_region.p1().x() + 0.5f;
2337 uv[1] = scaled_region.p1().y() + 0.5f;
2338 uv[2] = scaled_region.p2().x() + 0.5f;
2339 uv[3] = scaled_region.p2().y() + 0.5f;
2340 uv[4] = scaled_region.p3().x() + 0.5f;
2341 uv[5] = scaled_region.p3().y() + 0.5f;
2342 uv[6] = scaled_region.p4().x() + 0.5f;
2343 uv[7] = scaled_region.p4().y() + 0.5f;
2344 PrepareGeometry(CLIPPED_BINDING);
2345 clipped_geometry_->InitializeCustomQuadWithUVs(scaled_region, uv);
2346 FlushTextureQuadCache(CLIPPED_BINDING);
2347 }
2053 } 2348 }
2054 2349
2055 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, 2350 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
2056 const IOSurfaceDrawQuad* quad) { 2351 const IOSurfaceDrawQuad* quad,
2352 const gfx::QuadF* clip_region) {
2057 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2353 SetBlendEnabled(quad->ShouldDrawWithBlending());
2058 2354
2059 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2355 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2060 gl_, 2356 gl_,
2061 &highp_threshold_cache_, 2357 &highp_threshold_cache_,
2062 highp_threshold_min_, 2358 highp_threshold_min_,
2063 quad->shared_quad_state->visible_content_rect.bottom_right()); 2359 quad->shared_quad_state->visible_content_rect.bottom_right());
2064 2360
2065 TexTransformTextureProgramBinding binding; 2361 TexTransformTextureProgramBinding binding;
2066 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); 2362 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
(...skipping 18 matching lines...) Expand all
2085 2381
2086 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), 2382 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
2087 quad->opacity(), quad->opacity()}; 2383 quad->opacity(), quad->opacity()};
2088 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); 2384 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
2089 2385
2090 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2386 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2091 quad->io_surface_resource_id); 2387 quad->io_surface_resource_id);
2092 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2388 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2093 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); 2389 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
2094 2390
2095 DrawQuadGeometry( 2391 if (!clip_region) {
2096 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 2392 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
2393 binding.matrix_location);
2394 } else {
2395 float uvs[8] = {0};
2396 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2397 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), quad->rect,
2398 *clip_region, binding.matrix_location, uvs);
2399 }
2097 2400
2098 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 2401 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
2099 } 2402 }
2100 2403
2101 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2404 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2102 if (use_sync_query_) { 2405 if (use_sync_query_) {
2103 DCHECK(current_sync_query_); 2406 DCHECK(current_sync_query_);
2104 current_sync_query_->End(); 2407 current_sync_query_->End();
2105 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2408 pending_sync_queries_.push_back(current_sync_query_.Pass());
2106 } 2409 }
2107 2410
2108 current_framebuffer_lock_ = nullptr; 2411 current_framebuffer_lock_ = nullptr;
2109 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2412 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2110 2413
2111 GLC(gl_, gl_->Disable(GL_BLEND)); 2414 GLC(gl_, gl_->Disable(GL_BLEND));
2112 blend_shadow_ = false; 2415 blend_shadow_ = false;
2113 2416
2114 ScheduleOverlays(frame); 2417 ScheduleOverlays(frame);
2115 } 2418 }
2116 2419
2117 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } 2420 void GLRenderer::FinishDrawingQuadList() {
2421 FlushTextureQuadCache(SHARED_BINDING);
2422 }
2118 2423
2119 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const { 2424 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const {
2120 if (frame->current_render_pass != frame->root_render_pass) 2425 if (frame->current_render_pass != frame->root_render_pass)
2121 return true; 2426 return true;
2122 return FlippedRootFramebuffer(); 2427 return FlippedRootFramebuffer();
2123 } 2428 }
2124 2429
2125 bool GLRenderer::FlippedRootFramebuffer() const { 2430 bool GLRenderer::FlippedRootFramebuffer() const {
2126 // GL is normally flipped, so a flipped output results in an unflipping. 2431 // GL is normally flipped, so a flipped output results in an unflipping.
2127 return !output_surface_->capabilities().flipped_output_surface; 2432 return !output_surface_->capabilities().flipped_output_surface;
2128 } 2433 }
2129 2434
2130 void GLRenderer::EnsureScissorTestEnabled() { 2435 void GLRenderer::EnsureScissorTestEnabled() {
2131 if (is_scissor_enabled_) 2436 if (is_scissor_enabled_)
2132 return; 2437 return;
2133 2438
2134 FlushTextureQuadCache(); 2439 FlushTextureQuadCache(SHARED_BINDING);
2135 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST)); 2440 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
2136 is_scissor_enabled_ = true; 2441 is_scissor_enabled_ = true;
2137 } 2442 }
2138 2443
2139 void GLRenderer::EnsureScissorTestDisabled() { 2444 void GLRenderer::EnsureScissorTestDisabled() {
2140 if (!is_scissor_enabled_) 2445 if (!is_scissor_enabled_)
2141 return; 2446 return;
2142 2447
2143 FlushTextureQuadCache(); 2448 FlushTextureQuadCache(SHARED_BINDING);
2144 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 2449 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
2145 is_scissor_enabled_ = false; 2450 is_scissor_enabled_ = false;
2146 } 2451 }
2147 2452
2148 void GLRenderer::CopyCurrentRenderPassToBitmap( 2453 void GLRenderer::CopyCurrentRenderPassToBitmap(
2149 DrawingFrame* frame, 2454 DrawingFrame* frame,
2150 scoped_ptr<CopyOutputRequest> request) { 2455 scoped_ptr<CopyOutputRequest> request) {
2151 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); 2456 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap");
2152 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 2457 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2153 if (request->has_area()) 2458 if (request->has_area())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 blend_shadow_ = enabled; 2507 blend_shadow_ = enabled;
2203 } 2508 }
2204 2509
2205 void GLRenderer::SetUseProgram(unsigned program) { 2510 void GLRenderer::SetUseProgram(unsigned program) {
2206 if (program == program_shadow_) 2511 if (program == program_shadow_)
2207 return; 2512 return;
2208 gl_->UseProgram(program); 2513 gl_->UseProgram(program);
2209 program_shadow_ = program; 2514 program_shadow_ = program;
2210 } 2515 }
2211 2516
2517 void GLRenderer::DrawQuadGeometryClippedByQuadF(
2518 const DrawingFrame* frame,
2519 const gfx::Transform& draw_transform,
2520 const gfx::RectF& quad_rect,
2521 const gfx::QuadF& clipping_region_quad,
2522 int matrix_location,
2523 const float* uvs) {
2524 PrepareGeometry(CLIPPED_BINDING);
2525 if (uvs) {
2526 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs);
2527 } else {
2528 clipped_geometry_->InitializeCustomQuad(clipping_region_quad);
2529 }
2530 gfx::Transform quad_rect_matrix;
2531 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2532 static float gl_matrix[16];
2533 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2534 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2535
2536 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
2537 reinterpret_cast<const void*>(0)));
2538 }
2539
2212 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2540 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
2213 const gfx::Transform& draw_transform, 2541 const gfx::Transform& draw_transform,
2214 const gfx::RectF& quad_rect, 2542 const gfx::RectF& quad_rect,
2215 int matrix_location) { 2543 int matrix_location) {
2544 PrepareGeometry(SHARED_BINDING);
2216 gfx::Transform quad_rect_matrix; 2545 gfx::Transform quad_rect_matrix;
2217 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2546 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2218 static float gl_matrix[16]; 2547 static float gl_matrix[16];
2219 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2548 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2220 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); 2549 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2221 2550
2222 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 2551 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
2223 } 2552 }
2224 2553
2225 void GLRenderer::Finish() { 2554 void GLRenderer::Finish() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 2597
2269 void GLRenderer::EnforceMemoryPolicy() { 2598 void GLRenderer::EnforceMemoryPolicy() {
2270 if (!visible()) { 2599 if (!visible()) {
2271 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); 2600 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
2272 ReleaseRenderPassTextures(); 2601 ReleaseRenderPassTextures();
2273 DiscardBackbuffer(); 2602 DiscardBackbuffer();
2274 resource_provider_->ReleaseCachedData(); 2603 resource_provider_->ReleaseCachedData();
2275 output_surface_->context_provider()->DeleteCachedResources(); 2604 output_surface_->context_provider()->DeleteCachedResources();
2276 GLC(gl_, gl_->Flush()); 2605 GLC(gl_, gl_->Flush());
2277 } 2606 }
2607 PrepareGeometry(NO_BINDING);
2278 } 2608 }
2279 2609
2280 void GLRenderer::DiscardBackbuffer() { 2610 void GLRenderer::DiscardBackbuffer() {
2281 if (is_backbuffer_discarded_) 2611 if (is_backbuffer_discarded_)
2282 return; 2612 return;
2283 2613
2284 output_surface_->DiscardBackbuffer(); 2614 output_surface_->DiscardBackbuffer();
2285 2615
2286 is_backbuffer_discarded_ = true; 2616 is_backbuffer_discarded_ = true;
2287 2617
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 2929
2600 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { 2930 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
2601 EnsureScissorTestEnabled(); 2931 EnsureScissorTestEnabled();
2602 2932
2603 // Don't unnecessarily ask the context to change the scissor, because it 2933 // Don't unnecessarily ask the context to change the scissor, because it
2604 // may cause undesired GPU pipeline flushes. 2934 // may cause undesired GPU pipeline flushes.
2605 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) 2935 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_)
2606 return; 2936 return;
2607 2937
2608 scissor_rect_ = scissor_rect; 2938 scissor_rect_ = scissor_rect;
2609 FlushTextureQuadCache(); 2939 FlushTextureQuadCache(SHARED_BINDING);
2610 GLC(gl_, 2940 GLC(gl_,
2611 gl_->Scissor(scissor_rect.x(), 2941 gl_->Scissor(scissor_rect.x(),
2612 scissor_rect.y(), 2942 scissor_rect.y(),
2613 scissor_rect.width(), 2943 scissor_rect.width(),
2614 scissor_rect.height())); 2944 scissor_rect.height()));
2615 2945
2616 scissor_rect_needs_reset_ = false; 2946 scissor_rect_needs_reset_ = false;
2617 } 2947 }
2618 2948
2619 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) { 2949 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
2620 viewport_ = window_space_viewport; 2950 viewport_ = window_space_viewport;
2621 GLC(gl_, 2951 GLC(gl_,
2622 gl_->Viewport(window_space_viewport.x(), 2952 gl_->Viewport(window_space_viewport.x(),
2623 window_space_viewport.y(), 2953 window_space_viewport.y(),
2624 window_space_viewport.width(), 2954 window_space_viewport.width(),
2625 window_space_viewport.height())); 2955 window_space_viewport.height()));
2626 } 2956 }
2627 2957
2628 void GLRenderer::InitializeSharedObjects() { 2958 void GLRenderer::InitializeSharedObjects() {
2629 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 2959 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2630 2960
2631 // Create an FBO for doing offscreen rendering. 2961 // Create an FBO for doing offscreen rendering.
2632 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_)); 2962 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
2633 2963
2634 shared_geometry_ = make_scoped_ptr( 2964 shared_geometry_ =
2635 new GeometryBinding(gl_, QuadVertexRect())); 2965 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect()));
2966 clipped_geometry_ = make_scoped_ptr(new DynamicGeometryBinding(gl_));
2967 }
2968
2969 void GLRenderer::PrepareGeometry(BoundGeometry binding) {
2970 if (binding == bound_geometry_) {
2971 return;
2972 }
2973
2974 switch (binding) {
2975 case SHARED_BINDING:
2976 shared_geometry_->PrepareForDraw();
2977 break;
2978 case CLIPPED_BINDING:
2979 clipped_geometry_->PrepareForDraw();
2980 break;
2981 case NO_BINDING:
2982 break;
2983 }
2984 bound_geometry_ = binding;
2636 } 2985 }
2637 2986
2638 const GLRenderer::TileCheckerboardProgram* 2987 const GLRenderer::TileCheckerboardProgram*
2639 GLRenderer::GetTileCheckerboardProgram() { 2988 GLRenderer::GetTileCheckerboardProgram() {
2640 if (!tile_checkerboard_program_.initialized()) { 2989 if (!tile_checkerboard_program_.initialized()) {
2641 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); 2990 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
2642 tile_checkerboard_program_.Initialize(output_surface_->context_provider(), 2991 tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
2643 TEX_COORD_PRECISION_NA, 2992 TEX_COORD_PRECISION_NA,
2644 SAMPLER_TYPE_NA); 2993 SAMPLER_TYPE_NA);
2645 } 2994 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 scissor_rect_needs_reset_ = true; 3454 scissor_rect_needs_reset_ = true;
3106 stencil_shadow_ = false; 3455 stencil_shadow_ = false;
3107 blend_shadow_ = true; 3456 blend_shadow_ = true;
3108 program_shadow_ = 0; 3457 program_shadow_ = 0;
3109 3458
3110 RestoreGLState(); 3459 RestoreGLState();
3111 } 3460 }
3112 3461
3113 void GLRenderer::RestoreGLState() { 3462 void GLRenderer::RestoreGLState() {
3114 // This restores the current GLRenderer state to the GL context. 3463 // This restores the current GLRenderer state to the GL context.
3115 3464 bound_geometry_ = NO_BINDING;
3116 shared_geometry_->PrepareForDraw(); 3465 PrepareGeometry(SHARED_BINDING);
3117 3466
3118 GLC(gl_, gl_->Disable(GL_DEPTH_TEST)); 3467 GLC(gl_, gl_->Disable(GL_DEPTH_TEST));
3119 GLC(gl_, gl_->Disable(GL_CULL_FACE)); 3468 GLC(gl_, gl_->Disable(GL_CULL_FACE));
3120 GLC(gl_, gl_->ColorMask(true, true, true, true)); 3469 GLC(gl_, gl_->ColorMask(true, true, true, true));
3121 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 3470 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
3122 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); 3471 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
3123 3472
3124 if (program_shadow_) 3473 if (program_shadow_)
3125 gl_->UseProgram(program_shadow_); 3474 gl_->UseProgram(program_shadow_);
3126 3475
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 context_support_->ScheduleOverlayPlane( 3523 context_support_->ScheduleOverlayPlane(
3175 overlay.plane_z_order, 3524 overlay.plane_z_order,
3176 overlay.transform, 3525 overlay.transform,
3177 pending_overlay_resources_.back()->texture_id(), 3526 pending_overlay_resources_.back()->texture_id(),
3178 overlay.display_rect, 3527 overlay.display_rect,
3179 overlay.uv_rect); 3528 overlay.uv_rect);
3180 } 3529 }
3181 } 3530 }
3182 3531
3183 } // namespace cc 3532 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698