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

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: Adding compositor pixel tests, clang-format Created 7 years, 2 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 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && 577 if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() &&
578 num_descendants_that_draw_content > 0) { 578 num_descendants_that_draw_content > 0) {
579 TRACE_EVENT_INSTANT0( 579 TRACE_EVENT_INSTANT0(
580 "cc", 580 "cc",
581 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", 581 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening",
582 TRACE_EVENT_SCOPE_THREAD); 582 TRACE_EVENT_SCOPE_THREAD);
583 DCHECK(!is_root); 583 DCHECK(!is_root);
584 return true; 584 return true;
585 } 585 }
586 586
587 // If the layer has blending.
588 // TODO(rosca): this is temporary, until blending is implemented for other
589 // types of quads than RenderPassQuad. Layers having descendants that draw
590 // content will still create a separate rendering surface.
591 if (!layer->uses_default_blend_mode()) {
592 TRACE_EVENT_INSTANT0(
593 "cc",
594 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface blending",
595 TRACE_EVENT_SCOPE_THREAD);
596 DCHECK(!is_root);
597 return true;
598 }
599
600 // If the layer has isolation.
601 // TODO(rosca): to be optimized - create separate rendering surface only when
602 // the blending descendants might have access to the content behind this layer
603 // (layer has transparent background or descendants overflow)
604 // https://code.google.com/p/chromium/issues/detail?id=301738
605 if (layer->is_root_for_isolated_group()) {
606 TRACE_EVENT_INSTANT0(
607 "cc",
608 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface isolation",
609 TRACE_EVENT_SCOPE_THREAD);
610 DCHECK(!is_root);
611 return true;
612 }
613
587 // If the layer clips its descendants but it is not axis-aligned with respect 614 // If the layer clips its descendants but it is not axis-aligned with respect
588 // to its parent. 615 // to its parent.
589 bool layer_clips_external_content = 616 bool layer_clips_external_content =
590 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); 617 LayerClipsSubtree(layer) || layer->HasDelegatedContent();
591 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && 618 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent &&
592 num_descendants_that_draw_content > 0) { 619 num_descendants_that_draw_content > 0) {
593 TRACE_EVENT_INSTANT0( 620 TRACE_EVENT_INSTANT0(
594 "cc", 621 "cc",
595 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", 622 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping",
596 TRACE_EVENT_SCOPE_THREAD); 623 TRACE_EVENT_SCOPE_THREAD);
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 clipped_content_rect.set_width( 1872 clipped_content_rect.set_width(
1846 std::min(clipped_content_rect.width(), globals.max_texture_size)); 1873 std::min(clipped_content_rect.width(), globals.max_texture_size));
1847 clipped_content_rect.set_height( 1874 clipped_content_rect.set_height(
1848 std::min(clipped_content_rect.height(), globals.max_texture_size)); 1875 std::min(clipped_content_rect.height(), globals.max_texture_size));
1849 1876
1850 if (clipped_content_rect.IsEmpty()) { 1877 if (clipped_content_rect.IsEmpty()) {
1851 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 1878 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
1852 return; 1879 return;
1853 } 1880 }
1854 1881
1882 // Layers having a non-default blend mode will blend with the content
1883 // inside its parent's render target. This render target should be
1884 // either root_for_isolated_group, or the root of the layer tree.
enne (OOO) 2013/11/01 18:49:02 Can you also mention that if this is not true, the
rosca 2013/11/04 17:14:34 Done.
1885 DCHECK(layer->uses_default_blend_mode() || !layer->parent() ||
1886 !layer->parent()->render_target() ||
1887 IsRootLayer(layer->parent()->render_target()) ||
1888 layer->parent()->render_target()->is_root_for_isolated_group());
1889
1855 render_surface->SetContentRect(clipped_content_rect); 1890 render_surface->SetContentRect(clipped_content_rect);
1856 1891
1857 // The owning layer's screen_space_transform has a scale from content to 1892 // The owning layer's screen_space_transform has a scale from content to
1858 // layer space which we need to undo and replace with a scale from the 1893 // layer space which we need to undo and replace with a scale from the
1859 // surface's subtree into layer space. 1894 // surface's subtree into layer space.
1860 gfx::Transform screen_space_transform = layer->screen_space_transform(); 1895 gfx::Transform screen_space_transform = layer->screen_space_transform();
1861 screen_space_transform.Scale( 1896 screen_space_transform.Scale(
1862 layer->contents_scale_x() / render_surface_sublayer_scale.x(), 1897 layer->contents_scale_x() / render_surface_sublayer_scale.x(),
1863 layer->contents_scale_y() / render_surface_sublayer_scale.y()); 1898 layer->contents_scale_y() / render_surface_sublayer_scale.y());
1864 render_surface->SetScreenSpaceTransform(screen_space_transform); 1899 render_surface->SetScreenSpaceTransform(screen_space_transform);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 // At this point, we think the point does hit the touch event handler region 2264 // At this point, we think the point does hit the touch event handler region
2230 // on the layer, but we need to walk up the parents to ensure that the layer 2265 // on the layer, but we need to walk up the parents to ensure that the layer
2231 // was not clipped in such a way that the hit point actually should not hit 2266 // was not clipped in such a way that the hit point actually should not hit
2232 // the layer. 2267 // the layer.
2233 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2268 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2234 return false; 2269 return false;
2235 2270
2236 return true; 2271 return true;
2237 } 2272 }
2238 } // namespace cc 2273 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698