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

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: Fixes from issues introduced by the rebase, added tests for video_quads. Created 5 years, 11 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/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h"
19 #include "build/build_config.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/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/quads/draw_polygon.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"
28 #include "cc/quads/texture_draw_quad.h" 34 #include "cc/quads/texture_draw_quad.h"
29 #include "cc/resources/layer_quad.h" 35 #include "cc/resources/layer_quad.h"
30 #include "cc/resources/scoped_gpu_raster.h" 36 #include "cc/resources/scoped_gpu_raster.h"
31 #include "cc/resources/scoped_resource.h" 37 #include "cc/resources/scoped_resource.h"
32 #include "cc/resources/texture_mailbox_deleter.h" 38 #include "cc/resources/texture_mailbox_deleter.h"
33 #include "gpu/GLES2/gl2extchromium.h" 39 #include "gpu/GLES2/gl2extchromium.h"
34 #include "gpu/command_buffer/client/context_support.h" 40 #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()), 323 context_support_(output_surface->context_provider()->ContextSupport()),
318 texture_mailbox_deleter_(texture_mailbox_deleter), 324 texture_mailbox_deleter_(texture_mailbox_deleter),
319 is_backbuffer_discarded_(false), 325 is_backbuffer_discarded_(false),
320 is_scissor_enabled_(false), 326 is_scissor_enabled_(false),
321 scissor_rect_needs_reset_(true), 327 scissor_rect_needs_reset_(true),
322 stencil_shadow_(false), 328 stencil_shadow_(false),
323 blend_shadow_(false), 329 blend_shadow_(false),
324 highp_threshold_min_(highp_threshold_min), 330 highp_threshold_min_(highp_threshold_min),
325 highp_threshold_cache_(0), 331 highp_threshold_cache_(0),
326 use_sync_query_(false), 332 use_sync_query_(false),
327 on_demand_tile_raster_resource_id_(0) { 333 on_demand_tile_raster_resource_id_(0),
334 bound_geometry_(NoBinding) {
328 DCHECK(gl_); 335 DCHECK(gl_);
329 DCHECK(context_support_); 336 DCHECK(context_support_);
330 337
331 ContextProvider::Capabilities context_caps = 338 ContextProvider::Capabilities context_caps =
332 output_surface_->context_provider()->ContextCapabilities(); 339 output_surface_->context_provider()->ContextCapabilities();
333 340
334 capabilities_.using_partial_swap = 341 capabilities_.using_partial_swap =
335 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer; 342 settings_->partial_swap_enabled && context_caps.gpu.post_sub_buffer;
336 343
337 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle); 344 DCHECK(!context_caps.gpu.iosurface || context_caps.gpu.texture_rectangle);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 494
488 // TODO(enne): Do we need to reinitialize all of this state per frame? 495 // TODO(enne): Do we need to reinitialize all of this state per frame?
489 ReinitializeGLState(); 496 ReinitializeGLState();
490 } 497 }
491 498
492 void GLRenderer::DoNoOp() { 499 void GLRenderer::DoNoOp() {
493 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 500 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
494 GLC(gl_, gl_->Flush()); 501 GLC(gl_, gl_->Flush());
495 } 502 }
496 503
497 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { 504 void GLRenderer::DoDrawQuad(DrawingFrame* frame,
505 const DrawQuad* quad,
506 const gfx::QuadF* draw_region) {
498 DCHECK(quad->rect.Contains(quad->visible_rect)); 507 DCHECK(quad->rect.Contains(quad->visible_rect));
499 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 508 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
500 FlushTextureQuadCache(); 509 FlushTextureQuadCache(false);
501 } 510 }
502 511
503 switch (quad->material) { 512 switch (quad->material) {
504 case DrawQuad::INVALID: 513 case DrawQuad::INVALID:
505 NOTREACHED(); 514 NOTREACHED();
506 break; 515 break;
507 case DrawQuad::CHECKERBOARD: 516 case DrawQuad::CHECKERBOARD:
508 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); 517 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad),
518 draw_region);
509 break; 519 break;
510 case DrawQuad::DEBUG_BORDER: 520 case DrawQuad::DEBUG_BORDER:
511 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); 521 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad));
512 break; 522 break;
513 case DrawQuad::IO_SURFACE_CONTENT: 523 case DrawQuad::IO_SURFACE_CONTENT:
514 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); 524 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad),
525 draw_region);
515 break; 526 break;
516 case DrawQuad::PICTURE_CONTENT: 527 case DrawQuad::PICTURE_CONTENT:
517 DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad)); 528 DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad), draw_region);
518 break; 529 break;
519 case DrawQuad::RENDER_PASS: 530 case DrawQuad::RENDER_PASS:
520 DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); 531 DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad),
532 draw_region);
521 break; 533 break;
522 case DrawQuad::SOLID_COLOR: 534 case DrawQuad::SOLID_COLOR:
523 DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad)); 535 DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad),
536 draw_region);
524 break; 537 break;
525 case DrawQuad::STREAM_VIDEO_CONTENT: 538 case DrawQuad::STREAM_VIDEO_CONTENT:
526 DrawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad)); 539 DrawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad),
540 draw_region);
527 break; 541 break;
528 case DrawQuad::SURFACE_CONTENT: 542 case DrawQuad::SURFACE_CONTENT:
529 // Surface content should be fully resolved to other quad types before 543 // Surface content should be fully resolved to other quad types before
530 // reaching a direct renderer. 544 // reaching a direct renderer.
531 NOTREACHED(); 545 NOTREACHED();
532 break; 546 break;
533 case DrawQuad::TEXTURE_CONTENT: 547 case DrawQuad::TEXTURE_CONTENT:
534 EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); 548 EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad),
549 draw_region);
535 break; 550 break;
536 case DrawQuad::TILED_CONTENT: 551 case DrawQuad::TILED_CONTENT:
537 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); 552 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad), draw_region);
538 break; 553 break;
539 case DrawQuad::YUV_VIDEO_CONTENT: 554 case DrawQuad::YUV_VIDEO_CONTENT:
540 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); 555 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad),
556 draw_region);
541 break; 557 break;
542 } 558 }
543 } 559 }
544 560
545 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame, 561 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
546 const CheckerboardDrawQuad* quad) { 562 const CheckerboardDrawQuad* quad,
563 const gfx::QuadF* clip_region) {
564 // TODO(thildebr) For now since checkerboards shouldn't be part of a 3D
565 // context, clipping regions aren't supported so we skip drawing them
566 // if this becomes the case.
567 if (clip_region) {
568 return;
569 }
547 SetBlendEnabled(quad->ShouldDrawWithBlending()); 570 SetBlendEnabled(quad->ShouldDrawWithBlending());
548 571
549 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); 572 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
550 DCHECK(program && (program->initialized() || IsContextLost())); 573 DCHECK(program && (program->initialized() || IsContextLost()));
551 SetUseProgram(program->program()); 574 SetUseProgram(program->program());
552 575
553 SkColor color = quad->color; 576 SkColor color = quad->color;
554 GLC(gl_, 577 GLC(gl_,
555 gl_->Uniform4f(program->fragment_shader().color_location(), 578 gl_->Uniform4f(program->fragment_shader().color_location(),
556 SkColorGetR(color) * (1.0f / 255.0f), 579 SkColorGetR(color) * (1.0f / 255.0f),
(...skipping 21 matching lines...) Expand all
578 frequency)); 601 frequency));
579 602
580 SetShaderOpacity(quad->opacity(), 603 SetShaderOpacity(quad->opacity(),
581 program->fragment_shader().alpha_location()); 604 program->fragment_shader().alpha_location());
582 DrawQuadGeometry(frame, 605 DrawQuadGeometry(frame,
583 quad->quadTransform(), 606 quad->quadTransform(),
584 quad->rect, 607 quad->rect,
585 program->vertex_shader().matrix_location()); 608 program->vertex_shader().matrix_location());
586 } 609 }
587 610
611 // This function does not handle 3D sorting right now, since the debug border
612 // quads are just drawn as their original quads and not in split pieces. This
613 // results in some debug border quads drawing over foreground quads.
588 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 614 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
589 const DebugBorderDrawQuad* quad) { 615 const DebugBorderDrawQuad* quad) {
590 SetBlendEnabled(quad->ShouldDrawWithBlending()); 616 SetBlendEnabled(quad->ShouldDrawWithBlending());
591 617
592 static float gl_matrix[16]; 618 static float gl_matrix[16];
593 const DebugBorderProgram* program = GetDebugBorderProgram(); 619 const DebugBorderProgram* program = GetDebugBorderProgram();
594 DCHECK(program && (program->initialized() || IsContextLost())); 620 DCHECK(program && (program->initialized() || IsContextLost()));
595 SetUseProgram(program->program()); 621 SetUseProgram(program->program());
596 622
597 // Use the full quad_rect for debug quads to not move the edges based on 623 // Use the full quad_rect for debug quads to not move the edges based on
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 if (frame->current_render_pass->has_transparent_background) 830 if (frame->current_render_pass->has_transparent_background)
805 return false; 831 return false;
806 832
807 // TODO(ajuma): Add support for reference filters once 833 // TODO(ajuma): Add support for reference filters once
808 // FilterOperations::GetOutsets supports reference filters. 834 // FilterOperations::GetOutsets supports reference filters.
809 if (quad->background_filters.HasReferenceFilter()) 835 if (quad->background_filters.HasReferenceFilter())
810 return false; 836 return false;
811 return true; 837 return true;
812 } 838 }
813 839
840 bool GetScaledRegion(const gfx::Rect& rect,
enne (OOO) 2015/02/04 21:24:00 This function needs a comment about what it's doin
awoloszyn 2015/02/12 16:48:51 Done.
841 const gfx::QuadF* clip,
842 gfx::QuadF* scaled_region) {
843 if (clip) {
844 gfx::PointF p1(((clip->p1().x() - rect.x()) / rect.width()) - 0.5f,
845 ((clip->p1().y() - rect.y()) / rect.height()) - 0.5f);
846 gfx::PointF p2(((clip->p2().x() - rect.x()) / rect.width()) - 0.5f,
847 ((clip->p2().y() - rect.y()) / rect.height()) - 0.5f);
848 gfx::PointF p3(((clip->p3().x() - rect.x()) / rect.width()) - 0.5f,
849 ((clip->p3().y() - rect.y()) / rect.height()) - 0.5f);
850 gfx::PointF p4(((clip->p4().x() - rect.x()) / rect.width()) - 0.5f,
851 ((clip->p4().y() - rect.y()) / rect.height()) - 0.5f);
852 *scaled_region = gfx::QuadF(p1, p2, p3, p4);
853 return true;
854 }
855 return false;
856 }
857
814 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad( 858 gfx::Rect GLRenderer::GetBackdropBoundingBoxForRenderPassQuad(
815 DrawingFrame* frame, 859 DrawingFrame* frame,
816 const RenderPassDrawQuad* quad, 860 const RenderPassDrawQuad* quad,
817 const gfx::Transform& contents_device_transform, 861 const gfx::Transform& contents_device_transform,
862 const gfx::QuadF* clip_region,
818 bool use_aa) { 863 bool use_aa) {
864 gfx::QuadF scaled_region;
865 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) {
866 scaled_region = SharedGeometryQuad().BoundingBox();
867 }
868
819 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( 869 gfx::Rect backdrop_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect(
820 contents_device_transform, SharedGeometryQuad().BoundingBox())); 870 contents_device_transform, scaled_region.BoundingBox()));
821 871
822 if (ShouldApplyBackgroundFilters(frame, quad)) { 872 if (ShouldApplyBackgroundFilters(frame, quad)) {
823 int top, right, bottom, left; 873 int top, right, bottom, left;
824 quad->background_filters.GetOutsets(&top, &right, &bottom, &left); 874 quad->background_filters.GetOutsets(&top, &right, &bottom, &left);
825 backdrop_rect.Inset(-left, -top, -right, -bottom); 875 backdrop_rect.Inset(-left, -top, -right, -bottom);
826 } 876 }
827 877
828 if (!backdrop_rect.IsEmpty() && use_aa) { 878 if (!backdrop_rect.IsEmpty() && use_aa) {
829 const int kOutsetForAntialiasing = 1; 879 const int kOutsetForAntialiasing = 1;
830 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing); 880 backdrop_rect.Inset(-kOutsetForAntialiasing, -kOutsetForAntialiasing);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), 913 ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
864 resource_provider_, 914 resource_provider_,
865 quad->rect.origin(), 915 quad->rect.origin(),
866 quad->filters_scale, 916 quad->filters_scale,
867 filter.get(), 917 filter.get(),
868 background_texture); 918 background_texture);
869 return background_with_filters; 919 return background_with_filters;
870 } 920 }
871 921
872 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 922 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
873 const RenderPassDrawQuad* quad) { 923 const RenderPassDrawQuad* quad,
924 const gfx::QuadF* clip_region) {
874 ScopedResource* contents_texture = 925 ScopedResource* contents_texture =
875 render_pass_textures_.get(quad->render_pass_id); 926 render_pass_textures_.get(quad->render_pass_id);
876 if (!contents_texture || !contents_texture->id()) 927 if (!contents_texture || !contents_texture->id())
877 return; 928 return;
878 929
879 gfx::Transform quad_rect_matrix; 930 gfx::Transform quad_rect_matrix;
880 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 931 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
881 gfx::Transform contents_device_transform = 932 gfx::Transform contents_device_transform =
882 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 933 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
883 contents_device_transform.FlattenTo2d(); 934 contents_device_transform.FlattenTo2d();
884 935
885 // Can only draw surface if device matrix is invertible. 936 // Can only draw surface if device matrix is invertible.
886 if (!contents_device_transform.IsInvertible()) 937 if (!contents_device_transform.IsInvertible())
887 return; 938 return;
888 939
889 gfx::QuadF surface_quad = SharedGeometryQuad(); 940 gfx::QuadF surface_quad = SharedGeometryQuad();
890 float edge[24]; 941 float edge[24];
891 bool use_aa = settings_->allow_antialiasing && 942 bool use_aa = settings_->allow_antialiasing &&
892 ShouldAntialiasQuad(contents_device_transform, quad, 943 ShouldAntialiasQuad(contents_device_transform, quad,
893 settings_->force_antialiasing); 944 settings_->force_antialiasing);
894 945
895 if (use_aa) 946 SetupQuadForClippingAndAntialiasing(contents_device_transform, quad, use_aa,
896 SetupQuadForAntialiasing(contents_device_transform, quad, 947 clip_region, &surface_quad, edge);
897 &surface_quad, edge);
898
899 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; 948 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode;
900 bool use_shaders_for_blending = 949 bool use_shaders_for_blending =
901 !CanApplyBlendModeUsingBlendFunc(blend_mode) || 950 !CanApplyBlendModeUsingBlendFunc(blend_mode) ||
902 ShouldApplyBackgroundFilters(frame, quad) || 951 ShouldApplyBackgroundFilters(frame, quad) ||
903 settings_->force_blending_with_shaders; 952 settings_->force_blending_with_shaders;
904 953
905 scoped_ptr<ScopedResource> background_texture; 954 scoped_ptr<ScopedResource> background_texture;
906 skia::RefPtr<SkImage> background_image; 955 skia::RefPtr<SkImage> background_image;
907 gfx::Rect background_rect; 956 gfx::Rect background_rect;
908 if (use_shaders_for_blending) { 957 if (use_shaders_for_blending) {
909 // Compute a bounding box around the pixels that will be visible through 958 // Compute a bounding box around the pixels that will be visible through
910 // the quad. 959 // the quad.
911 background_rect = GetBackdropBoundingBoxForRenderPassQuad( 960 background_rect = GetBackdropBoundingBoxForRenderPassQuad(
912 frame, quad, contents_device_transform, use_aa); 961 frame, quad, contents_device_transform, clip_region, use_aa);
913 962
914 if (!background_rect.IsEmpty()) { 963 if (!background_rect.IsEmpty()) {
915 // The pixels from the filtered background should completely replace the 964 // The pixels from the filtered background should completely replace the
916 // current pixel values. 965 // current pixel values.
917 if (blend_enabled()) 966 if (blend_enabled())
918 SetBlendEnabled(false); 967 SetBlendEnabled(false);
919 968
920 // Read the pixels in the bounding box into a buffer R. 969 // Read the pixels in the bounding box into a buffer R.
921 // This function allocates a texture, which should contribute to the 970 // This function allocates a texture, which should contribute to the
922 // amount of memory used by render surfaces: 971 // amount of memory used by render surfaces:
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 static void SolidColorUniformLocation(T program, 1377 static void SolidColorUniformLocation(T program,
1329 SolidColorProgramUniforms* uniforms) { 1378 SolidColorProgramUniforms* uniforms) {
1330 uniforms->program = program->program(); 1379 uniforms->program = program->program();
1331 uniforms->matrix_location = program->vertex_shader().matrix_location(); 1380 uniforms->matrix_location = program->vertex_shader().matrix_location();
1332 uniforms->viewport_location = program->vertex_shader().viewport_location(); 1381 uniforms->viewport_location = program->vertex_shader().viewport_location();
1333 uniforms->quad_location = program->vertex_shader().quad_location(); 1382 uniforms->quad_location = program->vertex_shader().quad_location();
1334 uniforms->edge_location = program->vertex_shader().edge_location(); 1383 uniforms->edge_location = program->vertex_shader().edge_location();
1335 uniforms->color_location = program->fragment_shader().color_location(); 1384 uniforms->color_location = program->fragment_shader().color_location();
1336 } 1385 }
1337 1386
1387 bool is_top(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1388 if (!quad->IsTopEdge())
1389 return false;
1390 if (!clip_region) {
1391 return true;
1392 }
1393 return std::abs(clip_region->p1().y()) < kAntiAliasingEpsilon &&
1394 std::abs(clip_region->p2().y()) < kAntiAliasingEpsilon;
1395 }
1396
1397 bool is_bottom(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1398 if (!quad->IsBottomEdge())
1399 return false;
1400 if (!clip_region) {
1401 return true;
1402 }
1403 return std::abs(clip_region->p3().y() -
1404 quad->shared_quad_state->content_bounds.height()) <
1405 kAntiAliasingEpsilon &&
1406 std::abs(clip_region->p4().y() -
1407 quad->shared_quad_state->content_bounds.height()) <
1408 kAntiAliasingEpsilon;
1409 }
1410
1411 bool is_left(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1412 if (!quad->IsLeftEdge())
1413 return false;
1414 if (!clip_region) {
1415 return true;
1416 }
1417 return std::abs(clip_region->p1().x()) < kAntiAliasingEpsilon &&
1418 std::abs(clip_region->p4().x()) < kAntiAliasingEpsilon;
1419 }
1420
1421 bool is_right(const gfx::QuadF* clip_region, const DrawQuad* quad) {
1422 if (!quad->IsRightEdge())
1423 return false;
1424 if (!clip_region) {
1425 return true;
1426 }
1427 return std::abs(clip_region->p2().x() -
1428 quad->shared_quad_state->content_bounds.width()) <
1429 kAntiAliasingEpsilon &&
1430 std::abs(clip_region->p3().x() -
1431 quad->shared_quad_state->content_bounds.width()) <
1432 kAntiAliasingEpsilon;
1433 }
1434
1338 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( 1435 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges(
1339 const LayerQuad& device_layer_edges, 1436 const LayerQuad& device_layer_edges,
1340 const gfx::Transform& device_transform, 1437 const gfx::Transform& device_transform,
1438 const gfx::QuadF* clip_region,
1341 const DrawQuad* quad) { 1439 const DrawQuad* quad) {
1342 gfx::Rect tile_rect = quad->visible_rect; 1440 gfx::RectF tile_rect = quad->visible_rect;
1343 gfx::PointF bottom_right = tile_rect.bottom_right(); 1441 gfx::QuadF tile_quad(tile_rect);
1344 gfx::PointF bottom_left = tile_rect.bottom_left(); 1442
1345 gfx::PointF top_left = tile_rect.origin(); 1443 if (clip_region) {
1346 gfx::PointF top_right = tile_rect.top_right(); 1444 if (quad->material != DrawQuad::RENDER_PASS) {
1445 tile_quad = *clip_region;
1446 } else {
1447 GetScaledRegion(quad->rect, clip_region, &tile_quad);
1448 }
1449 }
1450
1451 gfx::PointF bottom_right = tile_quad.p3();
1452 gfx::PointF bottom_left = tile_quad.p4();
1453 gfx::PointF top_left = tile_quad.p1();
1454 gfx::PointF top_right = tile_quad.p2();
1347 bool clipped = false; 1455 bool clipped = false;
1348 1456
1349 // Map points to device space. We ignore |clipped|, since the result of 1457 // Map points to device space. We ignore |clipped|, since the result of
1350 // |MapPoint()| still produces a valid point to draw the quad with. When 1458 // |MapPoint()| still produces a valid point to draw the quad with. When
1351 // clipped, the point will be outside of the viewport. See crbug.com/416367. 1459 // clipped, the point will be outside of the viewport. See crbug.com/416367.
1352 bottom_right = MathUtil::MapPoint(device_transform, bottom_right, &clipped); 1460 bottom_right = MathUtil::MapPoint(device_transform, bottom_right, &clipped);
1353 bottom_left = MathUtil::MapPoint(device_transform, bottom_left, &clipped); 1461 bottom_left = MathUtil::MapPoint(device_transform, bottom_left, &clipped);
1354 top_left = MathUtil::MapPoint(device_transform, top_left, &clipped); 1462 top_left = MathUtil::MapPoint(device_transform, top_left, &clipped);
1355 top_right = MathUtil::MapPoint(device_transform, top_right, &clipped); 1463 top_right = MathUtil::MapPoint(device_transform, top_right, &clipped);
1356 1464
1357 LayerQuad::Edge bottom_edge(bottom_right, bottom_left); 1465 LayerQuad::Edge bottom_edge(bottom_right, bottom_left);
1358 LayerQuad::Edge left_edge(bottom_left, top_left); 1466 LayerQuad::Edge left_edge(bottom_left, top_left);
1359 LayerQuad::Edge top_edge(top_left, top_right); 1467 LayerQuad::Edge top_edge(top_left, top_right);
1360 LayerQuad::Edge right_edge(top_right, bottom_right); 1468 LayerQuad::Edge right_edge(top_right, bottom_right);
1361 1469
1362 // Only apply anti-aliasing to edges not clipped by culling or scissoring. 1470 // Only apply anti-aliasing to edges not clipped by culling or scissoring.
1363 if (quad->IsTopEdge() && tile_rect.y() == quad->rect.y()) 1471 // If an edge is degenerate we do not want to replace it with a "proper" edge
enne (OOO) 2015/02/04 21:24:00 Oh! Good catch. I didn't think about that.
1472 // as that will cause the quad to possibly expand is strange ways.
1473 if (!top_edge.degenerate() && is_top(clip_region, quad) &&
1474 tile_rect.y() == quad->rect.y()) {
1364 top_edge = device_layer_edges.top(); 1475 top_edge = device_layer_edges.top();
1365 if (quad->IsLeftEdge() && tile_rect.x() == quad->rect.x()) 1476 }
1477 if (!left_edge.degenerate() && is_left(clip_region, quad) &&
1478 tile_rect.x() == quad->rect.x()) {
1366 left_edge = device_layer_edges.left(); 1479 left_edge = device_layer_edges.left();
1367 if (quad->IsRightEdge() && tile_rect.right() == quad->rect.right()) 1480 }
1481 if (!right_edge.degenerate() && is_right(clip_region, quad) &&
1482 tile_rect.right() == quad->rect.right()) {
1368 right_edge = device_layer_edges.right(); 1483 right_edge = device_layer_edges.right();
1369 if (quad->IsBottomEdge() && tile_rect.bottom() == quad->rect.bottom()) 1484 }
1485 if (!bottom_edge.degenerate() && is_bottom(clip_region, quad) &&
1486 tile_rect.bottom() == quad->rect.bottom()) {
1370 bottom_edge = device_layer_edges.bottom(); 1487 bottom_edge = device_layer_edges.bottom();
1488 }
1371 1489
1372 float sign = gfx::QuadF(tile_rect).IsCounterClockwise() ? -1 : 1; 1490 float sign = tile_quad.IsCounterClockwise() ? -1 : 1;
1373 bottom_edge.scale(sign); 1491 bottom_edge.scale(sign);
1374 left_edge.scale(sign); 1492 left_edge.scale(sign);
1375 top_edge.scale(sign); 1493 top_edge.scale(sign);
1376 right_edge.scale(sign); 1494 right_edge.scale(sign);
1377 1495
1378 // Create device space quad. 1496 // Create device space quad.
1379 return LayerQuad(left_edge, top_edge, right_edge, bottom_edge).ToQuadF(); 1497 return LayerQuad(left_edge, top_edge, right_edge, bottom_edge).ToQuadF();
1380 } 1498 }
1381 1499
1500 float GetTotalQuadError(const gfx::QuadF* clipped_quad,
1501 const gfx::QuadF* ideal_rect) {
1502 return (clipped_quad->p1() - ideal_rect->p1()).LengthSquared() +
1503 (clipped_quad->p2() - ideal_rect->p2()).LengthSquared() +
1504 (clipped_quad->p3() - ideal_rect->p3()).LengthSquared() +
1505 (clipped_quad->p4() - ideal_rect->p4()).LengthSquared();
1506 }
1507
1508 // Attempt to rotate the clipped quad until it lines up the most
1509 // correctly. This is necessary because we check the edges of this
1510 // quad against the expected left/right/top/bottom for anti-aliasing.
1511 void RotateQuad(gfx::QuadF* clipped_quad) {
enne (OOO) 2015/02/04 21:23:59 Maybe call this RotateQuadToMatchBoudingQuad? (Or
awoloszyn 2015/02/12 16:48:51 Done.
1512 gfx::QuadF bounding_quad = gfx::QuadF(clipped_quad->BoundingBox());
1513 size_t least_error = 0;
1514 float least_error_amount = GetTotalQuadError(clipped_quad, &bounding_quad);
1515 for (size_t i = 1; i < 4; ++i) {
1516 clipped_quad->Rotate(1);
1517 float new_error = GetTotalQuadError(clipped_quad, &bounding_quad);
1518 if (new_error < least_error_amount) {
1519 least_error = i;
1520 least_error_amount = new_error;
1521 }
1522 }
1523 clipped_quad->Rotate((least_error + 1) % 4);
enne (OOO) 2015/02/04 21:24:00 This maybe needs some explanation? Also, a unit te
awoloszyn 2015/02/12 16:48:51 Replaced this with a temporary, it is much clearer
1524 }
1525
1382 // static 1526 // static
1383 bool GLRenderer::ShouldAntialiasQuad(const gfx::Transform& device_transform, 1527 bool GLRenderer::ShouldAntialiasQuad(const gfx::Transform& device_transform,
1384 const DrawQuad* quad, 1528 const DrawQuad* quad,
1385 bool force_antialiasing) { 1529 bool force_antialiasing) {
1386 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS); 1530 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS);
1387 // For render pass quads, |device_transform| already contains quad's rect. 1531 // For render pass quads, |device_transform| already contains quad's rect.
1388 // TODO(rosca@adobe.com): remove branching on is_render_pass_quad 1532 // TODO(rosca@adobe.com): remove branching on is_render_pass_quad
1389 // crbug.com/429702 1533 // crbug.com/429702
1390 if (!is_render_pass_quad && !quad->IsEdge()) 1534 if (!is_render_pass_quad && !quad->IsEdge())
1391 return false; 1535 return false;
(...skipping 11 matching lines...) Expand all
1403 bool is_nearest_rect_within_epsilon = 1547 bool is_nearest_rect_within_epsilon =
1404 is_axis_aligned_in_target && 1548 is_axis_aligned_in_target &&
1405 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), 1549 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(),
1406 kAntiAliasingEpsilon); 1550 kAntiAliasingEpsilon);
1407 // AAing clipped quads is not supported by the code yet. 1551 // AAing clipped quads is not supported by the code yet.
1408 bool use_aa = !clipped && !is_nearest_rect_within_epsilon; 1552 bool use_aa = !clipped && !is_nearest_rect_within_epsilon;
1409 return use_aa || force_antialiasing; 1553 return use_aa || force_antialiasing;
1410 } 1554 }
1411 1555
1412 // static 1556 // static
1413 void GLRenderer::SetupQuadForAntialiasing( 1557 void GLRenderer::SetupQuadForClippingAndAntialiasing(
1414 const gfx::Transform& device_transform, 1558 const gfx::Transform& device_transform,
1415 const DrawQuad* quad, 1559 const DrawQuad* quad,
1560 bool use_aa,
1561 const gfx::QuadF* clip_region_,
enne (OOO) 2015/02/04 21:24:00 clip_region (no underscore)
awoloszyn 2015/02/12 16:48:51 Done.
1416 gfx::QuadF* local_quad, 1562 gfx::QuadF* local_quad,
1417 float edge[24]) { 1563 float edge[24]) {
1418 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS); 1564 bool is_render_pass_quad = (quad->material == DrawQuad::RENDER_PASS);
1419 gfx::RectF content_rect = 1565 gfx::QuadF rotated_clip;
1420 is_render_pass_quad ? QuadVertexRect() : quad->visibleContentRect(); 1566 const gfx::QuadF* clip_region = clip_region_;
1567 if (clip_region_) {
1568 rotated_clip = *clip_region_;
1569 RotateQuad(&rotated_clip);
1570 clip_region = &rotated_clip;
1571 }
1421 1572
1573 gfx::QuadF content_rect = is_render_pass_quad
1574 ? gfx::QuadF(QuadVertexRect())
1575 : gfx::QuadF(quad->visibleContentRect());
1576 if (!use_aa) {
1577 if (clip_region) {
1578 if (!is_render_pass_quad) {
1579 content_rect = *clip_region;
1580 } else {
1581 GetScaledRegion(quad->rect, clip_region, &content_rect);
1582 }
1583 *local_quad = content_rect;
1584 }
1585 return;
1586 }
1422 bool clipped = false; 1587 bool clipped = false;
1423 gfx::QuadF device_layer_quad = 1588 gfx::QuadF device_layer_quad =
1424 MathUtil::MapQuad(device_transform, gfx::QuadF(content_rect), &clipped); 1589 MathUtil::MapQuad(device_transform, content_rect, &clipped);
1425 1590
1426 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox())); 1591 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox()));
1427 device_layer_bounds.InflateAntiAliasingDistance(); 1592 device_layer_bounds.InflateAntiAliasingDistance();
1428 1593
1429 LayerQuad device_layer_edges(device_layer_quad); 1594 LayerQuad device_layer_edges(device_layer_quad);
1430 device_layer_edges.InflateAntiAliasingDistance(); 1595 device_layer_edges.InflateAntiAliasingDistance();
1431 1596
1432 device_layer_edges.ToFloatArray(edge); 1597 device_layer_edges.ToFloatArray(edge);
1433 device_layer_bounds.ToFloatArray(&edge[12]); 1598 device_layer_bounds.ToFloatArray(&edge[12]);
1434 1599
1600 // If we have a clip_region then we are split, and therefore
1601 // by necessity, at least one of our edges is not an external
1602 // one.
1435 bool use_aa_on_all_four_edges = 1603 bool use_aa_on_all_four_edges =
1436 is_render_pass_quad || 1604 !clip_region &&
1437 (quad->IsTopEdge() && quad->IsLeftEdge() && quad->IsBottomEdge() && 1605 (is_render_pass_quad ||
1438 quad->IsRightEdge() && quad->visible_rect == quad->rect); 1606 (is_top(clip_region, quad) && is_left(clip_region, quad) &&
1607 is_bottom(clip_region, quad) && is_right(clip_region, quad) &&
1608 quad->visible_rect == quad->rect));
1439 1609
1440 gfx::QuadF device_quad = 1610 gfx::QuadF device_quad =
1441 use_aa_on_all_four_edges 1611 use_aa_on_all_four_edges
1442 ? device_layer_edges.ToQuadF() 1612 ? device_layer_edges.ToQuadF()
1443 : GetDeviceQuadWithAntialiasingOnExteriorEdges( 1613 : GetDeviceQuadWithAntialiasingOnExteriorEdges(
1444 device_layer_edges, device_transform, quad); 1614 device_layer_edges, device_transform, clip_region, quad);
1445 1615
1446 // Map device space quad to local space. device_transform has no 3d 1616 // Map device space quad to local space. device_transform has no 3d
1447 // component since it was flattened, so we don't need to project. We should 1617 // component since it was flattened, so we don't need to project. We should
1448 // have already checked that the transform was uninvertible above. 1618 // have already checked that the transform was uninvertible above.
1449 gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization); 1619 gfx::Transform inverse_device_transform(gfx::Transform::kSkipInitialization);
1450 bool did_invert = device_transform.GetInverse(&inverse_device_transform); 1620 bool did_invert = device_transform.GetInverse(&inverse_device_transform);
1451 DCHECK(did_invert); 1621 DCHECK(did_invert);
1452 *local_quad = 1622 *local_quad =
1453 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped); 1623 MathUtil::MapQuad(inverse_device_transform, device_quad, &clipped);
1454 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may 1624 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may
1455 // cause device_quad to become clipped. To our knowledge this scenario does 1625 // cause device_quad to become clipped. To our knowledge this scenario does
1456 // not need to be handled differently than the unclipped case. 1626 // not need to be handled differently than the unclipped case.
1457 } 1627 }
1458 1628
1459 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame, 1629 void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
1460 const SolidColorDrawQuad* quad) { 1630 const SolidColorDrawQuad* quad,
1631 const gfx::QuadF* clip_region) {
1461 gfx::Rect tile_rect = quad->visible_rect; 1632 gfx::Rect tile_rect = quad->visible_rect;
1462 1633
1463 SkColor color = quad->color; 1634 SkColor color = quad->color;
1464 float opacity = quad->opacity(); 1635 float opacity = quad->opacity();
1465 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; 1636 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
1466 1637
1467 // Early out if alpha is small enough that quad doesn't contribute to output. 1638 // Early out if alpha is small enough that quad doesn't contribute to output.
1468 if (alpha < std::numeric_limits<float>::epsilon() && 1639 if (alpha < std::numeric_limits<float>::epsilon() &&
1469 quad->ShouldDrawWithBlending()) 1640 quad->ShouldDrawWithBlending())
1470 return; 1641 return;
1471 1642
1472 gfx::Transform device_transform = 1643 gfx::Transform device_transform =
1473 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1644 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1474 device_transform.FlattenTo2d(); 1645 device_transform.FlattenTo2d();
1475 if (!device_transform.IsInvertible()) 1646 if (!device_transform.IsInvertible())
1476 return; 1647 return;
1477 1648
1478 bool force_aa = false; 1649 bool force_aa = false;
1479 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1650 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1480 float edge[24]; 1651 float edge[24];
1481 bool use_aa = settings_->allow_antialiasing && 1652 bool use_aa = settings_->allow_antialiasing &&
1482 !quad->force_anti_aliasing_off && 1653 !quad->force_anti_aliasing_off &&
1483 ShouldAntialiasQuad(device_transform, quad, force_aa); 1654 ShouldAntialiasQuad(device_transform, quad, force_aa);
1655 SetupQuadForClippingAndAntialiasing(device_transform, quad, use_aa,
1656 clip_region, &local_quad, edge);
1484 1657
1485 SolidColorProgramUniforms uniforms; 1658 SolidColorProgramUniforms uniforms;
1486 if (use_aa) { 1659 if (use_aa) {
1487 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge);
1488 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); 1660 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms);
1489 } else { 1661 } else {
1490 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); 1662 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
1491 } 1663 }
1492 SetUseProgram(uniforms.program); 1664 SetUseProgram(uniforms.program);
1493 1665
1494 GLC(gl_, 1666 GLC(gl_,
1495 gl_->Uniform4f(uniforms.color_location, 1667 gl_->Uniform4f(uniforms.color_location,
1496 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1668 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1497 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1669 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 uniforms->vertex_tex_transform_location = 1720 uniforms->vertex_tex_transform_location =
1549 program->vertex_shader().vertex_tex_transform_location(); 1721 program->vertex_shader().vertex_tex_transform_location();
1550 1722
1551 uniforms->sampler_location = program->fragment_shader().sampler_location(); 1723 uniforms->sampler_location = program->fragment_shader().sampler_location();
1552 uniforms->alpha_location = program->fragment_shader().alpha_location(); 1724 uniforms->alpha_location = program->fragment_shader().alpha_location();
1553 uniforms->fragment_tex_transform_location = 1725 uniforms->fragment_tex_transform_location =
1554 program->fragment_shader().fragment_tex_transform_location(); 1726 program->fragment_shader().fragment_tex_transform_location();
1555 } 1727 }
1556 1728
1557 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, 1729 void GLRenderer::DrawTileQuad(const DrawingFrame* frame,
1558 const TileDrawQuad* quad) { 1730 const TileDrawQuad* quad,
1559 DrawContentQuad(frame, quad, quad->resource_id); 1731 const gfx::QuadF* clip_region) {
1732 DrawContentQuad(frame, quad, quad->resource_id, clip_region);
1560 } 1733 }
1561 1734
1562 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, 1735 void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
1563 const ContentDrawQuadBase* quad, 1736 const ContentDrawQuadBase* quad,
1564 ResourceProvider::ResourceId resource_id) { 1737 ResourceProvider::ResourceId resource_id,
1738 const gfx::QuadF* clip_region) {
1565 gfx::Transform device_transform = 1739 gfx::Transform device_transform =
1566 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); 1740 frame->window_matrix * frame->projection_matrix * quad->quadTransform();
1567 device_transform.FlattenTo2d(); 1741 device_transform.FlattenTo2d();
1568 1742
1569 bool use_aa = settings_->allow_antialiasing && 1743 bool use_aa = settings_->allow_antialiasing &&
1570 ShouldAntialiasQuad(device_transform, quad, false); 1744 ShouldAntialiasQuad(device_transform, quad, false);
1571 1745
1572 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA 1746 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA
1573 // similar to the way DrawContentQuadNoAA works and then consider 1747 // similar to the way DrawContentQuadNoAA works and then consider
1574 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. 1748 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method.
1575 if (use_aa) 1749 if (use_aa)
1576 DrawContentQuadAA(frame, quad, resource_id, device_transform); 1750 DrawContentQuadAA(frame, quad, resource_id, device_transform, clip_region);
1577 else 1751 else
1578 DrawContentQuadNoAA(frame, quad, resource_id); 1752 DrawContentQuadNoAA(frame, quad, resource_id, clip_region);
1579 } 1753 }
1580 1754
1581 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame, 1755 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame,
1582 const ContentDrawQuadBase* quad, 1756 const ContentDrawQuadBase* quad,
1583 ResourceProvider::ResourceId resource_id, 1757 ResourceProvider::ResourceId resource_id,
1584 const gfx::Transform& device_transform) { 1758 const gfx::Transform& device_transform,
1759 const gfx::QuadF* clip_region) {
1585 if (!device_transform.IsInvertible()) 1760 if (!device_transform.IsInvertible())
1586 return; 1761 return;
1587 1762
1588 gfx::Rect tile_rect = quad->visible_rect; 1763 gfx::Rect tile_rect = quad->visible_rect;
1589 1764
1590 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1765 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1591 quad->tex_coord_rect, quad->rect, tile_rect); 1766 quad->tex_coord_rect, quad->rect, tile_rect);
1592 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1767 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1593 float tex_to_geom_scale_y = 1768 float tex_to_geom_scale_y =
1594 quad->rect.height() / quad->tex_coord_rect.height(); 1769 quad->rect.height() / quad->tex_coord_rect.height();
(...skipping 24 matching lines...) Expand all
1619 float vertex_tex_translate_y = 1794 float vertex_tex_translate_y =
1620 -clamp_geom_rect.y() / clamp_geom_rect.height(); 1795 -clamp_geom_rect.y() / clamp_geom_rect.height();
1621 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); 1796 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width();
1622 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); 1797 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
1623 1798
1624 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1799 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1625 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1800 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
1626 1801
1627 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1802 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1628 float edge[24]; 1803 float edge[24];
1629 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); 1804 SetupQuadForClippingAndAntialiasing(device_transform, quad, true, clip_region,
1630 1805 &local_quad, edge);
1631 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1806 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1632 resource_provider_, resource_id, 1807 resource_provider_, resource_id,
1633 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR); 1808 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR);
1634 SamplerType sampler = 1809 SamplerType sampler =
1635 SamplerTypeFromTextureTarget(quad_resource_lock.target()); 1810 SamplerTypeFromTextureTarget(quad_resource_lock.target());
1636 1811
1637 float fragment_tex_translate_x = clamp_tex_rect.x(); 1812 float fragment_tex_translate_x = clamp_tex_rect.x();
1638 float fragment_tex_translate_y = clamp_tex_rect.y(); 1813 float fragment_tex_translate_y = clamp_tex_rect.y();
1639 float fragment_tex_scale_x = clamp_tex_rect.width(); 1814 float fragment_tex_scale_x = clamp_tex_rect.width();
1640 float fragment_tex_scale_y = clamp_tex_rect.height(); 1815 float fragment_tex_scale_y = clamp_tex_rect.height();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 // it. This is why this centered rect is used and not the original quad_rect. 1873 // it. This is why this centered rect is used and not the original quad_rect.
1699 gfx::RectF centered_rect( 1874 gfx::RectF centered_rect(
1700 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1875 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1701 tile_rect.size()); 1876 tile_rect.size());
1702 DrawQuadGeometry( 1877 DrawQuadGeometry(
1703 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); 1878 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location);
1704 } 1879 }
1705 1880
1706 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 1881 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
1707 const ContentDrawQuadBase* quad, 1882 const ContentDrawQuadBase* quad,
1708 ResourceProvider::ResourceId resource_id) { 1883 ResourceProvider::ResourceId resource_id,
1884 const gfx::QuadF* clip_region) {
1709 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1885 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1710 quad->tex_coord_rect, quad->rect, quad->visible_rect); 1886 quad->tex_coord_rect, quad->rect, quad->visible_rect);
1711 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1887 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1712 float tex_to_geom_scale_y = 1888 float tex_to_geom_scale_y =
1713 quad->rect.height() / quad->tex_coord_rect.height(); 1889 quad->rect.height() / quad->tex_coord_rect.height();
1714 1890
1715 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); 1891 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
1716 GLenum filter = 1892 GLenum filter =
1717 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) && 1893 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) &&
1718 !quad->nearest_neighbor 1894 !quad->nearest_neighbor
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 vertex_tex_scale_y)); 1948 vertex_tex_scale_y));
1773 1949
1774 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1950 SetBlendEnabled(quad->ShouldDrawWithBlending());
1775 1951
1776 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1952 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1777 1953
1778 // Pass quad coordinates to the uniform in the same order as GeometryBinding 1954 // Pass quad coordinates to the uniform in the same order as GeometryBinding
1779 // does, then vertices will match the texture mapping in the vertex buffer. 1955 // does, then vertices will match the texture mapping in the vertex buffer.
1780 // The method SetShaderQuadF() changes the order of vertices and so it's 1956 // The method SetShaderQuadF() changes the order of vertices and so it's
1781 // not used here. 1957 // not used here.
1782 1958 gfx::QuadF tile_rect(quad->visible_rect);
1783 gfx::RectF tile_rect = quad->visible_rect; 1959 float width = quad->visible_rect.width();
1960 float height = quad->visible_rect.height();
1961 gfx::PointF top_left = quad->visible_rect.origin();
1962 if (clip_region) {
1963 tile_rect = *clip_region;
1964 float gl_uv[8] = {
1965 (tile_rect.p4().x() - top_left.x()) / width,
1966 (tile_rect.p4().y() - top_left.y()) / height,
1967 (tile_rect.p1().x() - top_left.x()) / width,
1968 (tile_rect.p1().y() - top_left.y()) / height,
1969 (tile_rect.p2().x() - top_left.x()) / width,
1970 (tile_rect.p2().y() - top_left.y()) / height,
1971 (tile_rect.p3().x() - top_left.x()) / width,
1972 (tile_rect.p3().y() - top_left.y()) / height,
1973 };
1974 PrepareGeometry(ClippedBinding);
1975 clipped_geometry_->InitializeCustomQuadWithUVs(
1976 gfx::QuadF(quad->visible_rect), gl_uv);
1977 } else {
1978 PrepareGeometry(SharedBinding);
1979 }
1784 float gl_quad[8] = { 1980 float gl_quad[8] = {
1785 tile_rect.x(), 1981 tile_rect.p4().x(),
1786 tile_rect.bottom(), 1982 tile_rect.p4().y(),
1787 tile_rect.x(), 1983 tile_rect.p1().x(),
1788 tile_rect.y(), 1984 tile_rect.p1().y(),
1789 tile_rect.right(), 1985 tile_rect.p2().x(),
1790 tile_rect.y(), 1986 tile_rect.p2().y(),
1791 tile_rect.right(), 1987 tile_rect.p3().x(),
1792 tile_rect.bottom(), 1988 tile_rect.p3().y(),
1793 }; 1989 };
1794 GLC(gl_, gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad)); 1990 GLC(gl_, gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad));
1795 1991
1796 static float gl_matrix[16]; 1992 static float gl_matrix[16];
1797 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform()); 1993 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform());
1798 GLC(gl_, 1994 GLC(gl_,
1799 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0])); 1995 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]));
1800 1996
1801 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 1997 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
1802 } 1998 }
1803 1999
1804 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, 2000 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
1805 const YUVVideoDrawQuad* quad) { 2001 const YUVVideoDrawQuad* quad,
2002 const gfx::QuadF* clip_region) {
1806 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2003 SetBlendEnabled(quad->ShouldDrawWithBlending());
1807 2004
1808 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2005 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1809 gl_, 2006 gl_,
1810 &highp_threshold_cache_, 2007 &highp_threshold_cache_,
1811 highp_threshold_min_, 2008 highp_threshold_min_,
1812 quad->shared_quad_state->visible_content_rect.bottom_right()); 2009 quad->shared_quad_state->visible_content_rect.bottom_right());
1813 2010
1814 bool use_alpha_plane = quad->a_plane_resource_id != 0; 2011 bool use_alpha_plane = quad->a_plane_resource_id != 0;
1815 2012
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 case YUVVideoDrawQuad::REC_601: 2111 case YUVVideoDrawQuad::REC_601:
1915 yuv_to_rgb = yuv_to_rgb_rec601; 2112 yuv_to_rgb = yuv_to_rgb_rec601;
1916 yuv_adjust = yuv_adjust_rec601; 2113 yuv_adjust = yuv_adjust_rec601;
1917 break; 2114 break;
1918 case YUVVideoDrawQuad::REC_601_JPEG: 2115 case YUVVideoDrawQuad::REC_601_JPEG:
1919 yuv_to_rgb = yuv_to_rgb_rec601_jpeg; 2116 yuv_to_rgb = yuv_to_rgb_rec601_jpeg;
1920 yuv_adjust = yuv_adjust_rec601_jpeg; 2117 yuv_adjust = yuv_adjust_rec601_jpeg;
1921 break; 2118 break;
1922 } 2119 }
1923 2120
2121 // The transform and vertex data are used to figure out the extents that the
2122 // un-antialiased quad should have and which vertex this is and the float
2123 // quad passed in via uniform is the actual geometry that gets used to draw
2124 // it. This is why this centered rect is used and not the original quad_rect.
2125 gfx::RectF tile_rect = quad->visible_rect;
1924 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 2126 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb));
1925 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 2127 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust));
1926 2128
1927 SetShaderOpacity(quad->opacity(), alpha_location); 2129 SetShaderOpacity(quad->opacity(), alpha_location);
1928 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); 2130 if (!clip_region) {
2131 DrawQuadGeometry(frame, quad->quadTransform(), tile_rect, matrix_location);
2132 } else {
2133 gfx::QuadF region_quad = *clip_region;
2134 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
2135 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2136 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), tile_rect,
2137 region_quad, matrix_location);
2138 }
1929 } 2139 }
1930 2140
1931 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 2141 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
1932 const StreamVideoDrawQuad* quad) { 2142 const StreamVideoDrawQuad* quad,
2143 const gfx::QuadF* clip_region) {
1933 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2144 SetBlendEnabled(quad->ShouldDrawWithBlending());
1934 2145
1935 static float gl_matrix[16]; 2146 static float gl_matrix[16];
1936 2147
1937 DCHECK(capabilities_.using_egl_image); 2148 DCHECK(capabilities_.using_egl_image);
1938 2149
1939 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2150 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1940 gl_, 2151 gl_,
1941 &highp_threshold_cache_, 2152 &highp_threshold_cache_,
1942 highp_threshold_min_, 2153 highp_threshold_min_,
(...skipping 10 matching lines...) Expand all
1953 2164
1954 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2165 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1955 quad->resource_id); 2166 quad->resource_id);
1956 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2167 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
1957 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); 2168 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1958 2169
1959 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2170 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1960 2171
1961 SetShaderOpacity(quad->opacity(), 2172 SetShaderOpacity(quad->opacity(),
1962 program->fragment_shader().alpha_location()); 2173 program->fragment_shader().alpha_location());
1963 DrawQuadGeometry(frame, 2174 if (!clip_region) {
1964 quad->quadTransform(), 2175 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
1965 quad->rect, 2176 program->vertex_shader().matrix_location());
1966 program->vertex_shader().matrix_location()); 2177 } else {
2178 gfx::QuadF region_quad(*clip_region);
2179 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2180 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2181 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), quad->rect,
2182 region_quad,
2183 program->vertex_shader().matrix_location());
2184 }
1967 } 2185 }
1968 2186
1969 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, 2187 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame,
1970 const PictureDrawQuad* quad) { 2188 const PictureDrawQuad* quad,
2189 const gfx::QuadF* clip_region) {
1971 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || 2190 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() ||
1972 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { 2191 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) {
1973 on_demand_tile_raster_bitmap_.allocN32Pixels(quad->texture_size.width(), 2192 on_demand_tile_raster_bitmap_.allocN32Pixels(quad->texture_size.width(),
1974 quad->texture_size.height()); 2193 quad->texture_size.height());
1975 2194
1976 if (on_demand_tile_raster_resource_id_) 2195 if (on_demand_tile_raster_resource_id_)
1977 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 2196 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1978 2197
1979 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 2198 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
1980 quad->texture_size, 2199 quad->texture_size,
(...skipping 23 matching lines...) Expand all
2004 bitmap_pixels = 2223 bitmap_pixels =
2005 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()); 2224 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels());
2006 } 2225 }
2007 2226
2008 resource_provider_->SetPixels(on_demand_tile_raster_resource_id_, 2227 resource_provider_->SetPixels(on_demand_tile_raster_resource_id_,
2009 bitmap_pixels, 2228 bitmap_pixels,
2010 gfx::Rect(quad->texture_size), 2229 gfx::Rect(quad->texture_size),
2011 gfx::Rect(quad->texture_size), 2230 gfx::Rect(quad->texture_size),
2012 gfx::Vector2d()); 2231 gfx::Vector2d());
2013 2232
2014 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 2233 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_, clip_region);
2015 } 2234 }
2016 2235
2017 struct TextureProgramBinding { 2236 struct TextureProgramBinding {
2018 template <class Program> 2237 template <class Program>
2019 void Set(Program* program) { 2238 void Set(Program* program) {
2020 DCHECK(program); 2239 DCHECK(program);
2021 program_id = program->program(); 2240 program_id = program->program();
2022 sampler_location = program->fragment_shader().sampler_location(); 2241 sampler_location = program->fragment_shader().sampler_location();
2023 matrix_location = program->vertex_shader().matrix_location(); 2242 matrix_location = program->vertex_shader().matrix_location();
2024 background_color_location = 2243 background_color_location =
2025 program->fragment_shader().background_color_location(); 2244 program->fragment_shader().background_color_location();
2026 } 2245 }
2027 int program_id; 2246 int program_id;
2028 int sampler_location; 2247 int sampler_location;
2029 int matrix_location; 2248 int matrix_location;
2249 int transform_location;
2030 int background_color_location; 2250 int background_color_location;
2031 }; 2251 };
2032 2252
2033 struct TexTransformTextureProgramBinding : TextureProgramBinding { 2253 struct TexTransformTextureProgramBinding : TextureProgramBinding {
2034 template <class Program> 2254 template <class Program>
2035 void Set(Program* program) { 2255 void Set(Program* program) {
2036 TextureProgramBinding::Set(program); 2256 TextureProgramBinding::Set(program);
2037 tex_transform_location = program->vertex_shader().tex_transform_location(); 2257 tex_transform_location = program->vertex_shader().tex_transform_location();
2038 vertex_opacity_location = 2258 vertex_opacity_location =
2039 program->vertex_shader().vertex_opacity_location(); 2259 program->vertex_shader().vertex_opacity_location();
2040 } 2260 }
2041 int tex_transform_location; 2261 int tex_transform_location;
2042 int vertex_opacity_location; 2262 int vertex_opacity_location;
2043 }; 2263 };
2044 2264
2045 void GLRenderer::FlushTextureQuadCache() { 2265 void GLRenderer::FlushTextureQuadCache(bool using_clip_region) {
2046 // Check to see if we have anything to draw. 2266 // Check to see if we have anything to draw.
2047 if (draw_cache_.program_id == -1) 2267 if (draw_cache_.program_id == -1)
2048 return; 2268 return;
2049 2269
2270 PrepareGeometry(using_clip_region ? ClippedBinding : SharedBinding);
2271
2050 // Set the correct blending mode. 2272 // Set the correct blending mode.
2051 SetBlendEnabled(draw_cache_.needs_blending); 2273 SetBlendEnabled(draw_cache_.needs_blending);
2052 2274
2053 // Bind the program to the GL state. 2275 // Bind the program to the GL state.
2054 SetUseProgram(draw_cache_.program_id); 2276 SetUseProgram(draw_cache_.program_id);
2055 2277
2056 // Bind the correct texture sampler location. 2278 // Bind the correct texture sampler location.
2057 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); 2279 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
2058 2280
2059 // Assume the current active textures is 0. 2281 // Assume the current active textures is 0.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 gl_->DrawElements(GL_TRIANGLES, 2322 gl_->DrawElements(GL_TRIANGLES,
2101 6 * draw_cache_.matrix_data.size(), 2323 6 * draw_cache_.matrix_data.size(),
2102 GL_UNSIGNED_SHORT, 2324 GL_UNSIGNED_SHORT,
2103 0)); 2325 0));
2104 2326
2105 // Clear the cache. 2327 // Clear the cache.
2106 draw_cache_.program_id = -1; 2328 draw_cache_.program_id = -1;
2107 draw_cache_.uv_xform_data.resize(0); 2329 draw_cache_.uv_xform_data.resize(0);
2108 draw_cache_.vertex_opacity_data.resize(0); 2330 draw_cache_.vertex_opacity_data.resize(0);
2109 draw_cache_.matrix_data.resize(0); 2331 draw_cache_.matrix_data.resize(0);
2332
2333 if (using_clip_region) {
2334 PrepareGeometry(SharedBinding);
2335 }
2110 } 2336 }
2111 2337
2112 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, 2338 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
2113 const TextureDrawQuad* quad) { 2339 const TextureDrawQuad* quad,
2340 const gfx::QuadF* clip_region) {
2341 // If we have a clip_region then we have to render the next quad
2342 // with dynamic geometry, therefore we must flush all pending
2343 // texture quads.
2344 if (clip_region) {
2345 // We send in false here because we want to flush what's currently in the
2346 // queue using the shared_geometry and not clipped_geometry
2347 FlushTextureQuadCache(false);
2348 }
2349
2114 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2350 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2115 gl_, 2351 gl_,
2116 &highp_threshold_cache_, 2352 &highp_threshold_cache_,
2117 highp_threshold_min_, 2353 highp_threshold_min_,
2118 quad->shared_quad_state->visible_content_rect.bottom_right()); 2354 quad->shared_quad_state->visible_content_rect.bottom_right());
2119 2355
2120 // Choose the correct texture program binding 2356 // Choose the correct texture program binding
2121 TexTransformTextureProgramBinding binding; 2357 TexTransformTextureProgramBinding binding;
2122 if (quad->premultiplied_alpha) { 2358 if (quad->premultiplied_alpha) {
2123 if (quad->background_color == SK_ColorTRANSPARENT) { 2359 if (quad->background_color == SK_ColorTRANSPARENT) {
(...skipping 11 matching lines...) Expand all
2135 } 2371 }
2136 2372
2137 int resource_id = quad->resource_id; 2373 int resource_id = quad->resource_id;
2138 2374
2139 if (draw_cache_.program_id != binding.program_id || 2375 if (draw_cache_.program_id != binding.program_id ||
2140 draw_cache_.resource_id != resource_id || 2376 draw_cache_.resource_id != resource_id ||
2141 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || 2377 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() ||
2142 draw_cache_.nearest_neighbor != quad->nearest_neighbor || 2378 draw_cache_.nearest_neighbor != quad->nearest_neighbor ||
2143 draw_cache_.background_color != quad->background_color || 2379 draw_cache_.background_color != quad->background_color ||
2144 draw_cache_.matrix_data.size() >= 8) { 2380 draw_cache_.matrix_data.size() >= 8) {
2145 FlushTextureQuadCache(); 2381 FlushTextureQuadCache(false);
2146 draw_cache_.program_id = binding.program_id; 2382 draw_cache_.program_id = binding.program_id;
2147 draw_cache_.resource_id = resource_id; 2383 draw_cache_.resource_id = resource_id;
2148 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); 2384 draw_cache_.needs_blending = quad->ShouldDrawWithBlending();
2149 draw_cache_.nearest_neighbor = quad->nearest_neighbor; 2385 draw_cache_.nearest_neighbor = quad->nearest_neighbor;
2150 draw_cache_.background_color = quad->background_color; 2386 draw_cache_.background_color = quad->background_color;
2151 2387
2152 draw_cache_.uv_xform_location = binding.tex_transform_location; 2388 draw_cache_.uv_xform_location = binding.tex_transform_location;
2153 draw_cache_.background_color_location = binding.background_color_location; 2389 draw_cache_.background_color_location = binding.background_color_location;
2154 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; 2390 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location;
2155 draw_cache_.matrix_location = binding.matrix_location; 2391 draw_cache_.matrix_location = binding.matrix_location;
2156 draw_cache_.sampler_location = binding.sampler_location; 2392 draw_cache_.sampler_location = binding.sampler_location;
2157 } 2393 }
2158 2394
2159 // Generate the uv-transform 2395 // Generate the uv-transform
2160 draw_cache_.uv_xform_data.push_back(UVTransform(quad)); 2396 if (!clip_region) {
2397 draw_cache_.uv_xform_data.push_back(UVTransform(quad));
2398 } else {
2399 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2400 draw_cache_.uv_xform_data.push_back(uv_transform);
2401 }
2161 2402
2162 // Generate the vertex opacity 2403 // Generate the vertex opacity
2163 const float opacity = quad->opacity(); 2404 const float opacity = quad->opacity();
2164 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2405 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
2165 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); 2406 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity);
2166 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); 2407 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity);
2167 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); 2408 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity);
2168 2409
2169 // Generate the transform matrix 2410 // Generate the transform matrix
2170 gfx::Transform quad_rect_matrix; 2411 gfx::Transform quad_rect_matrix;
2171 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); 2412 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect);
2172 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; 2413 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix;
2173 2414
2174 Float16 m; 2415 Float16 m;
2175 quad_rect_matrix.matrix().asColMajorf(m.data); 2416 quad_rect_matrix.matrix().asColMajorf(m.data);
2176 draw_cache_.matrix_data.push_back(m); 2417 draw_cache_.matrix_data.push_back(m);
2418
2419 if (clip_region) {
2420 gfx::QuadF scaled_region;
2421 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) {
2422 scaled_region = SharedGeometryQuad().BoundingBox();
2423 }
2424
2425 float uv[8];
2426 uv[0] = scaled_region.p1().x() + 0.5f;
2427 uv[1] = scaled_region.p1().y() + 0.5f;
2428 uv[2] = scaled_region.p2().x() + 0.5f;
2429 uv[3] = scaled_region.p2().y() + 0.5f;
2430 uv[4] = scaled_region.p3().x() + 0.5f;
2431 uv[5] = scaled_region.p3().y() + 0.5f;
2432 uv[6] = scaled_region.p4().x() + 0.5f;
2433 uv[7] = scaled_region.p4().y() + 0.5f;
2434 PrepareGeometry(ClippedBinding);
2435 clipped_geometry_->InitializeCustomQuadWithUVs(scaled_region, uv);
2436 FlushTextureQuadCache(true);
2437 }
2177 } 2438 }
2178 2439
2179 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, 2440 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame,
2180 const IOSurfaceDrawQuad* quad) { 2441 const IOSurfaceDrawQuad* quad,
2442 const gfx::QuadF* clip_region) {
2181 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2443 SetBlendEnabled(quad->ShouldDrawWithBlending());
2182 2444
2183 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2445 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2184 gl_, 2446 gl_,
2185 &highp_threshold_cache_, 2447 &highp_threshold_cache_,
2186 highp_threshold_min_, 2448 highp_threshold_min_,
2187 quad->shared_quad_state->visible_content_rect.bottom_right()); 2449 quad->shared_quad_state->visible_content_rect.bottom_right());
2188 2450
2189 TexTransformTextureProgramBinding binding; 2451 TexTransformTextureProgramBinding binding;
2190 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); 2452 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
(...skipping 18 matching lines...) Expand all
2209 2471
2210 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), 2472 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
2211 quad->opacity(), quad->opacity()}; 2473 quad->opacity(), quad->opacity()};
2212 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); 2474 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
2213 2475
2214 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2476 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2215 quad->io_surface_resource_id); 2477 quad->io_surface_resource_id);
2216 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2478 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2217 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); 2479 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
2218 2480
2219 DrawQuadGeometry( 2481 if (!clip_region) {
2220 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 2482 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
2483 binding.matrix_location);
2484 } else {
2485 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), quad->rect,
2486 *clip_region, binding.matrix_location);
2487 }
2221 2488
2222 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 2489 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
2223 } 2490 }
2224 2491
2225 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2492 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2226 if (use_sync_query_) { 2493 if (use_sync_query_) {
2227 DCHECK(current_sync_query_); 2494 DCHECK(current_sync_query_);
2228 current_sync_query_->End(); 2495 current_sync_query_->End();
2229 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2496 pending_sync_queries_.push_back(current_sync_query_.Pass());
2230 } 2497 }
2231 2498
2232 current_framebuffer_lock_ = nullptr; 2499 current_framebuffer_lock_ = nullptr;
2233 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2500 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2234 2501
2235 GLC(gl_, gl_->Disable(GL_BLEND)); 2502 GLC(gl_, gl_->Disable(GL_BLEND));
2236 blend_shadow_ = false; 2503 blend_shadow_ = false;
2237 2504
2238 ScheduleOverlays(frame); 2505 ScheduleOverlays(frame);
2239 } 2506 }
2240 2507
2241 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } 2508 void GLRenderer::FinishDrawingQuadList() {
2509 FlushTextureQuadCache(false);
2510 }
2242 2511
2243 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const { 2512 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const {
2244 if (frame->current_render_pass != frame->root_render_pass) 2513 if (frame->current_render_pass != frame->root_render_pass)
2245 return true; 2514 return true;
2246 return FlippedRootFramebuffer(); 2515 return FlippedRootFramebuffer();
2247 } 2516 }
2248 2517
2249 bool GLRenderer::FlippedRootFramebuffer() const { 2518 bool GLRenderer::FlippedRootFramebuffer() const {
2250 // GL is normally flipped, so a flipped output results in an unflipping. 2519 // GL is normally flipped, so a flipped output results in an unflipping.
2251 return !output_surface_->capabilities().flipped_output_surface; 2520 return !output_surface_->capabilities().flipped_output_surface;
2252 } 2521 }
2253 2522
2254 void GLRenderer::EnsureScissorTestEnabled() { 2523 void GLRenderer::EnsureScissorTestEnabled() {
2255 if (is_scissor_enabled_) 2524 if (is_scissor_enabled_)
2256 return; 2525 return;
2257 2526
2258 FlushTextureQuadCache(); 2527 FlushTextureQuadCache(false);
2259 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST)); 2528 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST));
2260 is_scissor_enabled_ = true; 2529 is_scissor_enabled_ = true;
2261 } 2530 }
2262 2531
2263 void GLRenderer::EnsureScissorTestDisabled() { 2532 void GLRenderer::EnsureScissorTestDisabled() {
2264 if (!is_scissor_enabled_) 2533 if (!is_scissor_enabled_)
2265 return; 2534 return;
2266 2535
2267 FlushTextureQuadCache(); 2536 FlushTextureQuadCache(false);
2268 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 2537 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
2269 is_scissor_enabled_ = false; 2538 is_scissor_enabled_ = false;
2270 } 2539 }
2271 2540
2272 void GLRenderer::CopyCurrentRenderPassToBitmap( 2541 void GLRenderer::CopyCurrentRenderPassToBitmap(
2273 DrawingFrame* frame, 2542 DrawingFrame* frame,
2274 scoped_ptr<CopyOutputRequest> request) { 2543 scoped_ptr<CopyOutputRequest> request) {
2275 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); 2544 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap");
2276 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 2545 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2277 if (request->has_area()) 2546 if (request->has_area())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 blend_shadow_ = enabled; 2595 blend_shadow_ = enabled;
2327 } 2596 }
2328 2597
2329 void GLRenderer::SetUseProgram(unsigned program) { 2598 void GLRenderer::SetUseProgram(unsigned program) {
2330 if (program == program_shadow_) 2599 if (program == program_shadow_)
2331 return; 2600 return;
2332 gl_->UseProgram(program); 2601 gl_->UseProgram(program);
2333 program_shadow_ = program; 2602 program_shadow_ = program;
2334 } 2603 }
2335 2604
2605 void GLRenderer::DrawQuadGeometryClippedByQuadF(
2606 const DrawingFrame* frame,
2607 const gfx::Transform& draw_transform,
2608 const gfx::RectF& quad_rect,
2609 const gfx::QuadF& clipping_region_quad,
2610 int matrix_location,
2611 const float* uvs) {
2612 PrepareGeometry(ClippedBinding);
2613 if (uvs) {
2614 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs);
2615 } else {
2616 clipped_geometry_->InitializeCustomQuad(clipping_region_quad);
2617 }
2618 gfx::Transform quad_rect_matrix;
2619 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2620 static float gl_matrix[16];
2621 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2622 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2623
2624 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
2625 reinterpret_cast<const void*>(0)));
2626 }
2627
2336 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2628 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
2337 const gfx::Transform& draw_transform, 2629 const gfx::Transform& draw_transform,
2338 const gfx::RectF& quad_rect, 2630 const gfx::RectF& quad_rect,
2339 int matrix_location) { 2631 int matrix_location) {
2632 PrepareGeometry(SharedBinding);
2340 gfx::Transform quad_rect_matrix; 2633 gfx::Transform quad_rect_matrix;
2341 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2634 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2342 static float gl_matrix[16]; 2635 static float gl_matrix[16];
2343 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2636 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2344 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); 2637 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]));
2345 2638
2346 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 2639 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0));
2347 } 2640 }
2348 2641
2349 void GLRenderer::Finish() { 2642 void GLRenderer::Finish() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 return; 2711 return;
2419 2712
2420 output_surface_->EnsureBackbuffer(); 2713 output_surface_->EnsureBackbuffer();
2421 is_backbuffer_discarded_ = false; 2714 is_backbuffer_discarded_ = false;
2422 } 2715 }
2423 2716
2424 void GLRenderer::GetFramebufferPixelsAsync( 2717 void GLRenderer::GetFramebufferPixelsAsync(
2425 const DrawingFrame* frame, 2718 const DrawingFrame* frame,
2426 const gfx::Rect& rect, 2719 const gfx::Rect& rect,
2427 scoped_ptr<CopyOutputRequest> request) { 2720 scoped_ptr<CopyOutputRequest> request) {
2721 PrepareGeometry(NoBinding);
enne (OOO) 2015/02/04 21:24:00 Why does this need to happen? Does NoBinding need
awoloszyn 2015/02/12 16:48:51 Once we have called GetFramebufferPixelsAsync, we
2428 DCHECK(!request->IsEmpty()); 2722 DCHECK(!request->IsEmpty());
2429 if (request->IsEmpty()) 2723 if (request->IsEmpty())
2430 return; 2724 return;
2431 if (rect.IsEmpty()) 2725 if (rect.IsEmpty())
2432 return; 2726 return;
2433 2727
2434 gfx::Rect window_rect = MoveFromDrawToWindowSpace(frame, rect); 2728 gfx::Rect window_rect = MoveFromDrawToWindowSpace(frame, rect);
2435 DCHECK_GE(window_rect.x(), 0); 2729 DCHECK_GE(window_rect.x(), 0);
2436 DCHECK_GE(window_rect.y(), 0); 2730 DCHECK_GE(window_rect.y(), 0);
2437 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2731 DCHECK_LE(window_rect.right(), current_surface_size_.width());
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 3015
2722 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { 3016 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
2723 EnsureScissorTestEnabled(); 3017 EnsureScissorTestEnabled();
2724 3018
2725 // Don't unnecessarily ask the context to change the scissor, because it 3019 // Don't unnecessarily ask the context to change the scissor, because it
2726 // may cause undesired GPU pipeline flushes. 3020 // may cause undesired GPU pipeline flushes.
2727 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) 3021 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_)
2728 return; 3022 return;
2729 3023
2730 scissor_rect_ = scissor_rect; 3024 scissor_rect_ = scissor_rect;
2731 FlushTextureQuadCache(); 3025 FlushTextureQuadCache(false);
2732 GLC(gl_, 3026 GLC(gl_,
2733 gl_->Scissor(scissor_rect.x(), 3027 gl_->Scissor(scissor_rect.x(),
2734 scissor_rect.y(), 3028 scissor_rect.y(),
2735 scissor_rect.width(), 3029 scissor_rect.width(),
2736 scissor_rect.height())); 3030 scissor_rect.height()));
2737 3031
2738 scissor_rect_needs_reset_ = false; 3032 scissor_rect_needs_reset_ = false;
2739 } 3033 }
2740 3034
2741 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) { 3035 void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
2742 viewport_ = window_space_viewport; 3036 viewport_ = window_space_viewport;
2743 GLC(gl_, 3037 GLC(gl_,
2744 gl_->Viewport(window_space_viewport.x(), 3038 gl_->Viewport(window_space_viewport.x(),
2745 window_space_viewport.y(), 3039 window_space_viewport.y(),
2746 window_space_viewport.width(), 3040 window_space_viewport.width(),
2747 window_space_viewport.height())); 3041 window_space_viewport.height()));
2748 } 3042 }
2749 3043
2750 void GLRenderer::InitializeSharedObjects() { 3044 void GLRenderer::InitializeSharedObjects() {
2751 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 3045 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2752 3046
2753 // Create an FBO for doing offscreen rendering. 3047 // Create an FBO for doing offscreen rendering.
2754 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_)); 3048 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_));
2755 3049
2756 shared_geometry_ = make_scoped_ptr( 3050 shared_geometry_ =
2757 new GeometryBinding(gl_, QuadVertexRect())); 3051 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect()));
3052 clipped_geometry_ = make_scoped_ptr(new DynamicGeometryBinding(gl_));
3053 }
3054
3055 void GLRenderer::PrepareGeometry(BoundGeometry binding) {
3056 if (binding == bound_geometry_) {
3057 return;
3058 }
3059
3060 switch (binding) {
3061 case SharedBinding:
3062 shared_geometry_->PrepareForDraw();
3063 break;
3064 case ClippedBinding:
3065 clipped_geometry_->PrepareForDraw();
3066 break;
3067 case NoBinding:
3068 break;
3069 }
3070 bound_geometry_ = binding;
2758 } 3071 }
2759 3072
2760 const GLRenderer::TileCheckerboardProgram* 3073 const GLRenderer::TileCheckerboardProgram*
2761 GLRenderer::GetTileCheckerboardProgram() { 3074 GLRenderer::GetTileCheckerboardProgram() {
2762 if (!tile_checkerboard_program_.initialized()) { 3075 if (!tile_checkerboard_program_.initialized()) {
2763 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); 3076 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
2764 tile_checkerboard_program_.Initialize(output_surface_->context_provider(), 3077 tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
2765 TexCoordPrecisionNA, 3078 TexCoordPrecisionNA,
2766 SamplerTypeNA); 3079 SamplerTypeNA);
2767 } 3080 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 scissor_rect_needs_reset_ = true; 3536 scissor_rect_needs_reset_ = true;
3224 stencil_shadow_ = false; 3537 stencil_shadow_ = false;
3225 blend_shadow_ = true; 3538 blend_shadow_ = true;
3226 program_shadow_ = 0; 3539 program_shadow_ = 0;
3227 3540
3228 RestoreGLState(); 3541 RestoreGLState();
3229 } 3542 }
3230 3543
3231 void GLRenderer::RestoreGLState() { 3544 void GLRenderer::RestoreGLState() {
3232 // This restores the current GLRenderer state to the GL context. 3545 // This restores the current GLRenderer state to the GL context.
3233 3546 bound_geometry_ = NoBinding;
3234 shared_geometry_->PrepareForDraw(); 3547 PrepareGeometry(SharedBinding);
3235 3548
3236 GLC(gl_, gl_->Disable(GL_DEPTH_TEST)); 3549 GLC(gl_, gl_->Disable(GL_DEPTH_TEST));
3237 GLC(gl_, gl_->Disable(GL_CULL_FACE)); 3550 GLC(gl_, gl_->Disable(GL_CULL_FACE));
3238 GLC(gl_, gl_->ColorMask(true, true, true, true)); 3551 GLC(gl_, gl_->ColorMask(true, true, true, true));
3239 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 3552 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
3240 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); 3553 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
3241 3554
3242 if (program_shadow_) 3555 if (program_shadow_)
3243 gl_->UseProgram(program_shadow_); 3556 gl_->UseProgram(program_shadow_);
3244 3557
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 context_support_->ScheduleOverlayPlane( 3605 context_support_->ScheduleOverlayPlane(
3293 overlay.plane_z_order, 3606 overlay.plane_z_order,
3294 overlay.transform, 3607 overlay.transform,
3295 pending_overlay_resources_.back()->texture_id(), 3608 pending_overlay_resources_.back()->texture_id(),
3296 overlay.display_rect, 3609 overlay.display_rect,
3297 overlay.uv_rect); 3610 overlay.uv_rect);
3298 } 3611 }
3299 } 3612 }
3300 3613
3301 } // namespace cc 3614 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698