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

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

Issue 16896017: Add a hide_layer_and_subtree() flag to cc::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide-subtree-flag: SetIsDrawable on the new cc_layer Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // back of the layer is known to be facing the screen. 225 // back of the layer is known to be facing the screen.
226 if (!backface_test_layer->double_sided() && 226 if (!backface_test_layer->double_sided() &&
227 TransformToScreenIsKnown(backface_test_layer) && 227 TransformToScreenIsKnown(backface_test_layer) &&
228 IsLayerBackFaceVisible(backface_test_layer)) 228 IsLayerBackFaceVisible(backface_test_layer))
229 return true; 229 return true;
230 230
231 return false; 231 return false;
232 } 232 }
233 233
234 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer) { 234 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer) {
235 // The embedder can request to hide the entire layer's subtree.
236 if (layer->hide_layer_and_subtree())
237 return true;
238
235 // If layer is on the pending tree and opacity is being animated then 239 // If layer is on the pending tree and opacity is being animated then
236 // this subtree can't be skipped as we need to create, prioritize and 240 // this subtree can't be skipped as we need to create, prioritize and
237 // include tiles for this layer when deciding if tree can be activated. 241 // include tiles for this layer when deciding if tree can be activated.
238 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) 242 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating())
239 return false; 243 return false;
240 244
241 // The opacity of a layer always applies to its children (either implicitly 245 // The opacity of a layer always applies to its children (either implicitly
242 // via a render surface or explicitly if the parent preserves 3D), so the 246 // via a render surface or explicitly if the parent preserves 3D), so the
243 // entire subtree can be skipped if this layer is fully transparent. 247 // entire subtree can be skipped if this layer is fully transparent.
244 return !layer->opacity(); 248 return !layer->opacity();
245 } 249 }
246 250
247 static inline bool SubtreeShouldBeSkipped(Layer* layer) { 251 static inline bool SubtreeShouldBeSkipped(Layer* layer) {
252 // The embedder can request to hide the entire layer's subtree.
253 if (layer->hide_layer_and_subtree())
254 return true;
255
248 // If the opacity is being animated then the opacity on the main thread is 256 // If the opacity is being animated then the opacity on the main thread is
249 // unreliable (since the impl thread may be using a different opacity), so it 257 // unreliable (since the impl thread may be using a different opacity), so it
250 // should not be trusted. 258 // should not be trusted.
251 // In particular, it should not cause the subtree to be skipped. 259 // In particular, it should not cause the subtree to be skipped.
252 // Similarly, for layers that might animate opacity using an impl-only 260 // Similarly, for layers that might animate opacity using an impl-only
253 // animation, their subtree should also not be skipped. 261 // animation, their subtree should also not be skipped.
254 return !layer->opacity() && !layer->OpacityIsAnimating() && 262 return !layer->opacity() && !layer->OpacityIsAnimating() &&
255 !layer->OpacityCanAnimateOnImplThread(); 263 !layer->OpacityCanAnimateOnImplThread();
256 } 264 }
257 265
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 // replica's origin space to the screen's origin space. 1492 // replica's origin space to the screen's origin space.
1485 gfx::Transform replica_screen_space_transform = 1493 gfx::Transform replica_screen_space_transform =
1486 layer->render_surface()->screen_space_transform() * 1494 layer->render_surface()->screen_space_transform() *
1487 surface_origin_to_replica_origin_transform; 1495 surface_origin_to_replica_origin_transform;
1488 render_surface->SetReplicaScreenSpaceTransform( 1496 render_surface->SetReplicaScreenSpaceTransform(
1489 replica_screen_space_transform); 1497 replica_screen_space_transform);
1490 } 1498 }
1491 } 1499 }
1492 1500
1493 UpdateTilePrioritiesForLayer(layer); 1501 UpdateTilePrioritiesForLayer(layer);
1502 SavePaintPropertiesLayer(layer);
1494 1503
1495 // If neither this layer nor any of its children were added, early out. 1504 // If neither this layer nor any of its children were added, early out.
1496 if (sorting_start_index == descendants.size()) 1505 if (sorting_start_index == descendants.size())
1497 return; 1506 return;
1498 1507
1499 // If preserves-3d then sort all the descendants in 3D so that they can be 1508 // If preserves-3d then sort all the descendants in 3D so that they can be
1500 // drawn from back to front. If the preserves-3d property is also set on the 1509 // drawn from back to front. If the preserves-3d property is also set on the
1501 // parent then skip the sorting as the parent will sort all the descendants 1510 // parent then skip the sorting as the parent will sort all the descendants
1502 // anyway. 1511 // anyway.
1503 if (layer_sorter && descendants.size() && layer->preserves_3d() && 1512 if (layer_sorter && descendants.size() && layer->preserves_3d() &&
1504 (!layer->parent() || !layer->parent()->preserves_3d())) { 1513 (!layer->parent() || !layer->parent()->preserves_3d())) {
1505 SortLayers(descendants.begin() + sorting_start_index, 1514 SortLayers(descendants.begin() + sorting_start_index,
1506 descendants.end(), 1515 descendants.end(),
1507 layer_sorter); 1516 layer_sorter);
1508 } 1517 }
1509 1518
1510 if (layer->render_surface()) { 1519 if (layer->render_surface()) {
1511 *drawable_content_rect_of_subtree = 1520 *drawable_content_rect_of_subtree =
1512 gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect()); 1521 gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect());
1513 } else { 1522 } else {
1514 *drawable_content_rect_of_subtree = local_drawable_content_rect_of_subtree; 1523 *drawable_content_rect_of_subtree = local_drawable_content_rect_of_subtree;
1515 } 1524 }
1516 1525
1517 if (layer->HasContributingDelegatedRenderPasses()) { 1526 if (layer->HasContributingDelegatedRenderPasses()) {
1518 layer->render_target()->render_surface()-> 1527 layer->render_target()->render_surface()->
1519 AddContributingDelegatedRenderPassLayer(layer); 1528 AddContributingDelegatedRenderPassLayer(layer);
1520 } 1529 }
1521
1522 SavePaintPropertiesLayer(layer);
1523 } 1530 }
1524 1531
1525 void LayerTreeHostCommon::CalculateDrawProperties( 1532 void LayerTreeHostCommon::CalculateDrawProperties(
1526 Layer* root_layer, 1533 Layer* root_layer,
1527 gfx::Size device_viewport_size, 1534 gfx::Size device_viewport_size,
1528 const gfx::Transform& device_transform, 1535 const gfx::Transform& device_transform,
1529 float device_scale_factor, 1536 float device_scale_factor,
1530 float page_scale_factor, 1537 float page_scale_factor,
1531 Layer* page_scale_application_layer, 1538 Layer* page_scale_application_layer,
1532 int max_texture_size, 1539 int max_texture_size,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 // At this point, we think the point does hit the touch event handler region 1829 // At this point, we think the point does hit the touch event handler region
1823 // on the layer, but we need to walk up the parents to ensure that the layer 1830 // on the layer, but we need to walk up the parents to ensure that the layer
1824 // was not clipped in such a way that the hit point actually should not hit 1831 // was not clipped in such a way that the hit point actually should not hit
1825 // the layer. 1832 // the layer.
1826 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 1833 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
1827 return false; 1834 return false;
1828 1835
1829 return true; 1836 return true;
1830 } 1837 }
1831 } // namespace cc 1838 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698