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

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

Issue 1221273003: cc: Convert backface LTHCommon tests from Layer->LayerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delete_main_thread_cdp
Patch Set: Tests passing Created 5 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
« no previous file with comments | « cc/test/layer_tree_host_common_test.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 template <typename LayerType> 130 template <typename LayerType>
131 static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { 131 static bool IsRootLayerOfNewRenderingContext(LayerType* layer) {
132 if (layer->parent()) 132 if (layer->parent())
133 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); 133 return !layer->parent()->Is3dSorted() && layer->Is3dSorted();
134 return layer->Is3dSorted(); 134 return layer->Is3dSorted();
135 } 135 }
136 136
137 template <typename LayerType> 137 template <typename LayerType>
138 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { 138 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) {
139 return layer->Is3dSorted() && layer->parent() && 139 return layer->Is3dSorted() && layer->parent() &&
140 layer->parent()->Is3dSorted(); 140 layer->parent()->Is3dSorted() &&
141 layer->parent()->sorting_context_id() == layer->sorting_context_id();
141 } 142 }
142 143
143 template <typename LayerType> 144 template <typename LayerType>
144 static bool TransformToScreenIsKnown(LayerType* layer, 145 static bool TransformToScreenIsKnown(LayerType* layer,
145 const TransformTree& tree) { 146 const TransformTree& tree) {
146 const TransformNode* node = tree.Node(layer->transform_tree_index()); 147 const TransformNode* node = tree.Node(layer->transform_tree_index());
147 return !node->data.to_screen_is_animated; 148 return !node->data.to_screen_is_animated;
148 } 149 }
149 150
150 template <typename LayerType> 151 template <typename LayerType>
(...skipping 12 matching lines...) Expand all
163 164
164 if (LayerIsInExisting3DRenderingContext(layer)) 165 if (LayerIsInExisting3DRenderingContext(layer))
165 return DrawTransformFromPropertyTrees(layer, tree).IsBackFaceVisible(); 166 return DrawTransformFromPropertyTrees(layer, tree).IsBackFaceVisible();
166 167
167 // In this case, either the layer establishes a new 3d rendering context, or 168 // In this case, either the layer establishes a new 3d rendering context, or
168 // is not in a 3d rendering context at all. 169 // is not in a 3d rendering context at all.
169 return layer->transform().IsBackFaceVisible(); 170 return layer->transform().IsBackFaceVisible();
170 } 171 }
171 172
172 template <typename LayerType> 173 template <typename LayerType>
174 static bool IsSurfaceBackFaceVisible(LayerType* layer,
175 const TransformTree& tree) {
176 if (LayerIsInExisting3DRenderingContext(layer)) {
177 const TransformNode* node = tree.Node(layer->transform_tree_index());
178 // Draw transform as a contributing render surface.
179 return node->data.local.IsBackFaceVisible();
enne (OOO) 2015/07/10 22:22:34 to_target is just identity for something that crea
ajuma 2015/07/10 22:56:53 I think we want the transform from this node to no
180 }
181
182 if (IsRootLayerOfNewRenderingContext(layer))
183 return layer->transform().IsBackFaceVisible();
184
185 // If the render_surface is not part of a new or existing rendering context,
186 // then the layers that contribute to this surface will decide back-face
187 // visibility for themselves.
188 return false;
189 }
190
191 template <typename LayerType>
173 static bool IsAnimatingTransformToScreen(LayerType* layer, 192 static bool IsAnimatingTransformToScreen(LayerType* layer,
174 const TransformTree& tree) { 193 const TransformTree& tree) {
175 const TransformNode* node = tree.Node(layer->transform_tree_index()); 194 const TransformNode* node = tree.Node(layer->transform_tree_index());
176 return node->data.to_screen_is_animated; 195 return node->data.to_screen_is_animated;
177 } 196 }
178 197
179 static inline bool TransformToScreenIsKnown(Layer* layer, 198 static inline bool TransformToScreenIsKnown(Layer* layer,
180 const TransformTree& tree) { 199 const TransformTree& tree) {
181 return !IsAnimatingTransformToScreen(layer, tree); 200 return !IsAnimatingTransformToScreen(layer, tree);
182 } 201 }
183 202
184 static inline bool TransformToScreenIsKnown(LayerImpl* layer, 203 static inline bool TransformToScreenIsKnown(LayerImpl* layer,
185 const TransformTree& tree) { 204 const TransformTree& tree) {
186 return true; 205 return true;
187 } 206 }
188 207
189 template <typename LayerType> 208 template <typename LayerType>
190 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { 209 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) {
191 return layer->transform_is_invertible() || layer->TransformIsAnimating(); 210 return layer->transform_is_invertible() || layer->TransformIsAnimating();
192 } 211 }
193 212
194 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, 213 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer,
195 bool layer_is_drawn) { 214 bool layer_is_drawn,
215 const TransformTree& tree) {
196 // If the layer transform is not invertible, it should not be drawn. 216 // If the layer transform is not invertible, it should not be drawn.
197 // TODO(ajuma): Correctly process subtrees with singular transform for the 217 // TODO(ajuma): Correctly process subtrees with singular transform for the
198 // case where we may animate to a non-singular transform and wish to 218 // case where we may animate to a non-singular transform and wish to
199 // pre-raster. 219 // pre-raster.
200 if (!HasInvertibleOrAnimatedTransform(layer)) 220 if (!HasInvertibleOrAnimatedTransform(layer))
201 return true; 221 return true;
202 222
203 // When we need to do a readback/copy of a layer's output, we can not skip 223 // When we need to do a readback/copy of a layer's output, we can not skip
204 // it or any of its ancestors. 224 // it or any of its ancestors.
205 if (layer->draw_properties().layer_or_descendant_has_copy_request) 225 if (layer->draw_properties().layer_or_descendant_has_copy_request)
206 return false; 226 return false;
207 227
208 // We cannot skip the the subtree if a descendant has a wheel or touch handler 228 // We cannot skip the the subtree if a descendant has a wheel or touch handler
209 // or the hit testing code will break (it requires fresh transforms, etc). 229 // or the hit testing code will break (it requires fresh transforms, etc).
210 if (layer->draw_properties().layer_or_descendant_has_input_handler) 230 if (layer->draw_properties().layer_or_descendant_has_input_handler)
211 return false; 231 return false;
212 232
213 // If the layer is not drawn, then skip it and its subtree. 233 // If the layer is not drawn, then skip it and its subtree.
214 if (!layer_is_drawn) 234 if (!layer_is_drawn)
215 return true; 235 return true;
216 236
237 if (layer->render_surface() && !layer->double_sided() &&
238 IsSurfaceBackFaceVisible(layer, tree))
239 return true;
240
217 // If layer is on the pending tree and opacity is being animated then 241 // If layer is on the pending tree and opacity is being animated then
218 // this subtree can't be skipped as we need to create, prioritize and 242 // this subtree can't be skipped as we need to create, prioritize and
219 // include tiles for this layer when deciding if tree can be activated. 243 // include tiles for this layer when deciding if tree can be activated.
220 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) 244 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating())
221 return false; 245 return false;
222 246
223 // The opacity of a layer always applies to its children (either implicitly 247 // The opacity of a layer always applies to its children (either implicitly
224 // via a render surface or explicitly if the parent preserves 3D), so the 248 // via a render surface or explicitly if the parent preserves 3D), so the
225 // entire subtree can be skipped if this layer is fully transparent. 249 // entire subtree can be skipped if this layer is fully transparent.
226 return !layer->opacity(); 250 return !layer->opacity();
227 } 251 }
228 252
229 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { 253 static inline bool SubtreeShouldBeSkipped(Layer* layer,
254 bool layer_is_drawn,
255 const TransformTree& tree) {
230 // If the layer transform is not invertible, it should not be drawn. 256 // If the layer transform is not invertible, it should not be drawn.
231 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating()) 257 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating())
232 return true; 258 return true;
233 259
234 // When we need to do a readback/copy of a layer's output, we can not skip 260 // When we need to do a readback/copy of a layer's output, we can not skip
235 // it or any of its ancestors. 261 // it or any of its ancestors.
236 if (layer->draw_properties().layer_or_descendant_has_copy_request) 262 if (layer->draw_properties().layer_or_descendant_has_copy_request)
237 return false; 263 return false;
238 264
239 // We cannot skip the the subtree if a descendant has a wheel or touch handler 265 // We cannot skip the the subtree if a descendant has a wheel or touch handler
240 // or the hit testing code will break (it requires fresh transforms, etc). 266 // or the hit testing code will break (it requires fresh transforms, etc).
241 if (layer->draw_properties().layer_or_descendant_has_input_handler) 267 if (layer->draw_properties().layer_or_descendant_has_input_handler)
242 return false; 268 return false;
243 269
244 // If the layer is not drawn, then skip it and its subtree. 270 // If the layer is not drawn, then skip it and its subtree.
245 if (!layer_is_drawn) 271 if (!layer_is_drawn)
246 return true; 272 return true;
247 273
274 if (layer->render_surface() && !layer->double_sided() &&
275 !layer->TransformIsAnimating() && IsSurfaceBackFaceVisible(layer, tree))
276 return true;
277
248 // If the opacity is being animated then the opacity on the main thread is 278 // 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 279 // unreliable (since the impl thread may be using a different opacity), so it
250 // should not be trusted. 280 // should not be trusted.
251 // In particular, it should not cause the subtree to be skipped. 281 // In particular, it should not cause the subtree to be skipped.
252 // Similarly, for layers that might animate opacity using an impl-only 282 // Similarly, for layers that might animate opacity using an impl-only
253 // animation, their subtree should also not be skipped. 283 // animation, their subtree should also not be skipped.
254 return !layer->opacity() && !layer->OpacityIsAnimating() && 284 return !layer->opacity() && !layer->OpacityIsAnimating() &&
255 !layer->OpacityCanAnimateOnImplThread(); 285 !layer->OpacityCanAnimateOnImplThread();
256 } 286 }
257 287
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 void FindLayersThatNeedUpdates( 332 void FindLayersThatNeedUpdates(
303 LayerType* layer, 333 LayerType* layer,
304 const TransformTree& tree, 334 const TransformTree& tree,
305 bool subtree_is_visible_from_ancestor, 335 bool subtree_is_visible_from_ancestor,
306 typename LayerType::LayerListType* update_layer_list, 336 typename LayerType::LayerListType* update_layer_list,
307 std::vector<LayerType*>* visible_layer_list) { 337 std::vector<LayerType*>* visible_layer_list) {
308 bool layer_is_drawn = 338 bool layer_is_drawn =
309 layer->HasCopyRequest() || 339 layer->HasCopyRequest() ||
310 (subtree_is_visible_from_ancestor && !layer->hide_layer_and_subtree()); 340 (subtree_is_visible_from_ancestor && !layer->hide_layer_and_subtree());
311 341
312 if (layer->parent() && SubtreeShouldBeSkipped(layer, layer_is_drawn)) 342 if (layer->parent() && SubtreeShouldBeSkipped(layer, layer_is_drawn, tree))
313 return; 343 return;
314 344
315 if (!LayerShouldBeSkipped(layer, layer_is_drawn, tree)) { 345 if (!LayerShouldBeSkipped(layer, layer_is_drawn, tree)) {
316 visible_layer_list->push_back(layer); 346 visible_layer_list->push_back(layer);
317 update_layer_list->push_back(layer); 347 update_layer_list->push_back(layer);
318 } 348 }
319 349
320 // Append mask layers to the update layer list. They don't have valid visible 350 // Append mask layers to the update layer list. They don't have valid visible
321 // rects, so need to get added after the above calculation. Replica layers 351 // rects, so need to get added after the above calculation. Replica layers
322 // don't need to be updated. 352 // don't need to be updated.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (static_cast<int>(layer->offset_to_transform_parent().x()) != 656 if (static_cast<int>(layer->offset_to_transform_parent().x()) !=
627 layer->offset_to_transform_parent().x()) 657 layer->offset_to_transform_parent().x())
628 return false; 658 return false;
629 if (static_cast<int>(layer->offset_to_transform_parent().y()) != 659 if (static_cast<int>(layer->offset_to_transform_parent().y()) !=
630 layer->offset_to_transform_parent().y()) 660 layer->offset_to_transform_parent().y())
631 return false; 661 return false;
632 return true; 662 return true;
633 } 663 }
634 664
635 } // namespace cc 665 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_host_common_test.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