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

Side by Side Diff: Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp

Issue 10383299: Merge 117645 - [chromium] add back-face visibility check for renderSurfaces (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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 | « no previous file | Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // This bounding rectangle may be larger than it needs to be (being 59 // This bounding rectangle may be larger than it needs to be (being
60 // axis-aligned), but is a reasonable filter on the space to consider. 60 // axis-aligned), but is a reasonable filter on the space to consider.
61 // Non-invertible transforms will create an empty rect here. 61 // Non-invertible transforms will create an empty rect here.
62 const TransformationMatrix surfaceToLayer = transform.inverse(); 62 const TransformationMatrix surfaceToLayer = transform.inverse();
63 IntRect layerRect = enclosingIntRect(CCMathUtil::projectClippedRect(surfaceT oLayer, FloatRect(minimalSurfaceRect))); 63 IntRect layerRect = enclosingIntRect(CCMathUtil::projectClippedRect(surfaceT oLayer, FloatRect(minimalSurfaceRect)));
64 layerRect.intersect(layerBoundRect); 64 layerRect.intersect(layerBoundRect);
65 return layerRect; 65 return layerRect;
66 } 66 }
67 67
68 template<typename LayerType> 68 template<typename LayerType>
69 static inline bool layerIsInExisting3DRenderingContext(LayerType* layer)
70 {
71 // According to current W3C spec on CSS transforms, a layer is part of an es tablished
72 // 3d rendering context if its parent has transform-style of preserves-3d.
73 return layer->parent() && layer->parent()->preserves3D();
74 }
75
76 template<typename LayerType>
69 static IntRect calculateVisibleLayerRect(LayerType* layer) 77 static IntRect calculateVisibleLayerRect(LayerType* layer)
70 { 78 {
71 ASSERT(layer->targetRenderSurface()); 79 ASSERT(layer->targetRenderSurface());
72 80
73 // Animated layers can exist in the render surface tree that are not visible currently 81 // Animated layers can exist in the render surface tree that are not visible currently
74 // and have their back face showing. In this case, their visible rect should be empty. 82 // and have their back face showing. In this case, their visible rect should be empty.
75 if (!layer->doubleSided() && layer->screenSpaceTransform().isBackFaceVisible ()) 83 if (!layer->doubleSided() && layer->screenSpaceTransform().isBackFaceVisible ())
76 return IntRect(); 84 return IntRect();
77 85
78 IntRect targetSurfaceRect = layer->targetRenderSurface()->contentRect(); 86 IntRect targetSurfaceRect = layer->targetRenderSurface()->contentRect();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // If the layer has a reflection. 212 // If the layer has a reflection.
205 if (layer->replicaLayer()) 213 if (layer->replicaLayer())
206 return true; 214 return true;
207 215
208 // If the layer uses a CSS filter. 216 // If the layer uses a CSS filter.
209 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty()) 217 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty())
210 return true; 218 return true;
211 219
212 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is 220 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is
213 // treated as a 3D object by its parent (i.e. parent does preserve-3d). 221 // treated as a 3D object by its parent (i.e. parent does preserve-3d).
214 if (layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D () && descendantDrawsContent) 222 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && d escendantDrawsContent)
215 return true; 223 return true;
216 224
217 // On the main thread side, animating transforms are unknown, and may cause a RenderSurface on the impl side. 225 // On the main thread side, animating transforms are unknown, and may cause a RenderSurface on the impl side.
218 // Since they are cheap, we create a rendersurface for all animating transfo rms to cover these cases, and so 226 // Since they are cheap, we create a rendersurface for all animating transfo rms to cover these cases, and so
219 // that we can consider descendants as not animating relative to their targe t to aid culling. 227 // that we can consider descendants as not animating relative to their targe t to aid culling.
220 if (!transformToParentIsKnown(layer) && descendantDrawsContent) 228 if (!transformToParentIsKnown(layer) && descendantDrawsContent)
221 return true; 229 return true;
222 230
223 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent. 231 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent.
224 if (layer->masksToBounds() && !axisAlignedWithRespectToParent && descendantD rawsContent) 232 if (layer->masksToBounds() && !axisAlignedWithRespectToParent && descendantD rawsContent)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 IntRect transformedLayerRect; 383 IntRect transformedLayerRect;
376 384
377 // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurface's space. 385 // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurface's space.
378 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa ce, otherwise remains the same. 386 // nextHierarchyMatrix will only change if this layer uses a new RenderSurfa ce, otherwise remains the same.
379 TransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix; 387 TransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix;
380 388
381 // FIXME: This seems like the wrong place to set this 389 // FIXME: This seems like the wrong place to set this
382 layer->setUsesLayerClipping(false); 390 layer->setUsesLayerClipping(false);
383 391
384 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine dTransform))) { 392 if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combine dTransform))) {
393
394 // We need to check back-face visibility before continuing with this sur face.
395 // We cannot early exit here, however, if the transform is animating and not known on the main thread.
396 // FIXME: Also compute back-face visibility for surfaces that are not in existing 3D rendering context, using
397 // the layer's local transform. https://bugs.webkit.org/show_bug. cgi?id=84195
398 if (layerIsInExisting3DRenderingContext(layer) && transformToParentIsKno wn(layer) && !layer->doubleSided() && combinedTransform.isBackFaceVisible())
399 return false;
400
385 if (!layer->renderSurface()) 401 if (!layer->renderSurface())
386 layer->createRenderSurface(); 402 layer->createRenderSurface();
387 403
388 RenderSurfaceType* renderSurface = layer->renderSurface(); 404 RenderSurfaceType* renderSurface = layer->renderSurface();
389 renderSurface->clearLayerList(); 405 renderSurface->clearLayerList();
390 406
391 // The origin of the new surface is the upper left corner of the layer. 407 // The origin of the new surface is the upper left corner of the layer.
392 TransformationMatrix drawTransform; 408 TransformationMatrix drawTransform;
393 drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0 ); 409 drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0 );
394 layer->setDrawTransform(drawTransform); 410 layer->setDrawTransform(drawTransform);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 walkLayersAndCalculateVisibleLayerRects<LayerChromium, Vector<RefPtr<LayerCh romium> >, RenderSurfaceChromium>(renderSurfaceLayerList); 678 walkLayersAndCalculateVisibleLayerRects<LayerChromium, Vector<RefPtr<LayerCh romium> >, RenderSurfaceChromium>(renderSurfaceLayerList);
663 } 679 }
664 680
665 void CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(CCLayerImpl* la yer, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const Tra nsformationMatrix& fullHierarchyMatrix, Vector<CCLayerImpl*>& renderSurfaceLayer List, Vector<CCLayerImpl*>& layerList, CCLayerSorter* layerSorter, int maxTextur eSize) 681 void CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(CCLayerImpl* la yer, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const Tra nsformationMatrix& fullHierarchyMatrix, Vector<CCLayerImpl*>& renderSurfaceLayer List, Vector<CCLayerImpl*>& layerList, CCLayerSorter* layerSorter, int maxTextur eSize)
666 { 682 {
667 calculateDrawTransformsAndVisibilityInternal<CCLayerImpl, Vector<CCLayerImpl *>, CCRenderSurface, CCLayerSorter>(layer, rootLayer, parentMatrix, fullHierarch yMatrix, 0, renderSurfaceLayerList, layerList, layerSorter, maxTextureSize); 683 calculateDrawTransformsAndVisibilityInternal<CCLayerImpl, Vector<CCLayerImpl *>, CCRenderSurface, CCLayerSorter>(layer, rootLayer, parentMatrix, fullHierarch yMatrix, 0, renderSurfaceLayerList, layerList, layerSorter, maxTextureSize);
668 walkLayersAndCalculateVisibleLayerRects<CCLayerImpl, Vector<CCLayerImpl*>, C CRenderSurface>(renderSurfaceLayerList); 684 walkLayersAndCalculateVisibleLayerRects<CCLayerImpl, Vector<CCLayerImpl*>, C CRenderSurface>(renderSurfaceLayerList);
669 } 685 }
670 686
671 } // namespace WebCore 687 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698