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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 23455060: mix-blend-mode implementation for accelerated layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed src/webkit/renderer/compositor_bindings Created 7 years, 1 month 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && 580 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() &&
581 num_descendants_that_draw_content > 0) { 581 num_descendants_that_draw_content > 0) {
582 TRACE_EVENT_INSTANT0( 582 TRACE_EVENT_INSTANT0(
583 "cc", 583 "cc",
584 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", 584 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening",
585 TRACE_EVENT_SCOPE_THREAD); 585 TRACE_EVENT_SCOPE_THREAD);
586 DCHECK(!is_root); 586 DCHECK(!is_root);
587 return true; 587 return true;
588 } 588 }
589 589
590 // If the layer has blending.
591 // TODO(rosca): this is temporary, until blending is implemented for other
592 // types of quads than RenderPassQuad. Layers having descendants that draw
danakj 2013/11/13 21:02:03 RenderPassDrawQuad
rosca 2013/11/14 21:56:34 Done.
593 // content will still create a separate rendering surface.
594 if (!layer->uses_default_blend_mode()) {
595 TRACE_EVENT_INSTANT0(
596 "cc",
597 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface blending",
598 TRACE_EVENT_SCOPE_THREAD);
599 DCHECK(!is_root);
600 return true;
601 }
602
603 // If the layer has isolation.
604 // TODO(rosca): to be optimized - create separate rendering surface only when
605 // the blending descendants might have access to the content behind this layer
606 // (layer has transparent background or descendants overflow)
danakj 2013/11/13 21:02:03 period at the end.
rosca 2013/11/14 21:56:34 Done.
607 // https://code.google.com/p/chromium/issues/detail?id=301738
608 if (layer->is_root_for_isolated_group()) {
609 TRACE_EVENT_INSTANT0(
610 "cc",
611 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface isolation",
612 TRACE_EVENT_SCOPE_THREAD);
613 return true;
danakj 2013/11/13 21:02:03 Can you move this down before the if (is_root) cas
rosca 2013/11/14 21:56:34 Done.
614 }
615
590 // If the layer clips its descendants but it is not axis-aligned with respect 616 // If the layer clips its descendants but it is not axis-aligned with respect
591 // to its parent. 617 // to its parent.
592 bool layer_clips_external_content = 618 bool layer_clips_external_content =
593 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); 619 LayerClipsSubtree(layer) || layer->HasDelegatedContent();
594 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && 620 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent &&
595 num_descendants_that_draw_content > 0) { 621 num_descendants_that_draw_content > 0) {
596 TRACE_EVENT_INSTANT0( 622 TRACE_EVENT_INSTANT0(
597 "cc", 623 "cc",
598 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", 624 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping",
599 TRACE_EVENT_SCOPE_THREAD); 625 TRACE_EVENT_SCOPE_THREAD);
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 clipped_content_rect.set_width( 2067 clipped_content_rect.set_width(
2042 std::min(clipped_content_rect.width(), globals.max_texture_size)); 2068 std::min(clipped_content_rect.width(), globals.max_texture_size));
2043 clipped_content_rect.set_height( 2069 clipped_content_rect.set_height(
2044 std::min(clipped_content_rect.height(), globals.max_texture_size)); 2070 std::min(clipped_content_rect.height(), globals.max_texture_size));
2045 2071
2046 if (clipped_content_rect.IsEmpty()) { 2072 if (clipped_content_rect.IsEmpty()) {
2047 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 2073 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
2048 return; 2074 return;
2049 } 2075 }
2050 2076
2077 // Layers having a non-default blend mode will blend with the content
2078 // inside its parent's render target. This render target should be
2079 // either root_for_isolated_group, or the root of the layer tree.
2080 // Otherwise, this layer will use an incomplete backdrop, limited to its
2081 // render target and the blending result will be incorrect.
2082 DCHECK(layer->uses_default_blend_mode() || !layer->parent() ||
danakj 2013/11/13 21:02:03 Can you add DCHECK(...) << each << of << the << va
rosca 2013/11/14 21:56:34 They are disjunctions, so it will fail only when a
danakj 2013/11/20 03:32:50 Oh, no you're right :) I just knee-jerk when I see
2083 !layer->parent()->render_target() ||
2084 IsRootLayer(layer->parent()->render_target()) ||
2085 layer->parent()->render_target()->is_root_for_isolated_group());
2086
2051 render_surface->SetContentRect(clipped_content_rect); 2087 render_surface->SetContentRect(clipped_content_rect);
2052 2088
2053 // The owning layer's screen_space_transform has a scale from content to 2089 // The owning layer's screen_space_transform has a scale from content to
2054 // layer space which we need to undo and replace with a scale from the 2090 // layer space which we need to undo and replace with a scale from the
2055 // surface's subtree into layer space. 2091 // surface's subtree into layer space.
2056 gfx::Transform screen_space_transform = layer->screen_space_transform(); 2092 gfx::Transform screen_space_transform = layer->screen_space_transform();
2057 screen_space_transform.Scale( 2093 screen_space_transform.Scale(
2058 layer->contents_scale_x() / render_surface_sublayer_scale.x(), 2094 layer->contents_scale_x() / render_surface_sublayer_scale.x(),
2059 layer->contents_scale_y() / render_surface_sublayer_scale.y()); 2095 layer->contents_scale_y() / render_surface_sublayer_scale.y());
2060 render_surface->SetScreenSpaceTransform(screen_space_transform); 2096 render_surface->SetScreenSpaceTransform(screen_space_transform);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 // At this point, we think the point does hit the touch event handler region 2451 // At this point, we think the point does hit the touch event handler region
2416 // on the layer, but we need to walk up the parents to ensure that the layer 2452 // on the layer, but we need to walk up the parents to ensure that the layer
2417 // was not clipped in such a way that the hit point actually should not hit 2453 // was not clipped in such a way that the hit point actually should not hit
2418 // the layer. 2454 // the layer.
2419 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2455 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2420 return false; 2456 return false;
2421 2457
2422 return true; 2458 return true;
2423 } 2459 }
2424 } // namespace cc 2460 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698