OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2014 Google Inc. All rights reserved. | 3 * Copyright (C) 2014 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
32 #include "core/rendering/RenderLayerReflectionInfo.h" | 32 #include "core/rendering/RenderLayerReflectionInfo.h" |
33 #include "core/rendering/RenderPart.h" | 33 #include "core/rendering/RenderPart.h" |
34 #include "core/rendering/RenderView.h" | 34 #include "core/rendering/RenderView.h" |
35 #include "core/rendering/compositing/CompositedLayerMapping.h" | 35 #include "core/rendering/compositing/CompositedLayerMapping.h" |
36 #include "core/rendering/compositing/RenderLayerCompositor.h" | 36 #include "core/rendering/compositing/RenderLayerCompositor.h" |
37 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 bool shouldAppendLayer(const RenderLayer& layer) | 41 static bool shouldAppendLayer(const RenderLayer& layer) |
42 { | 42 { |
43 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) | 43 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) |
44 return true; | 44 return true; |
45 Node* node = layer.renderer()->node(); | 45 Node* node = layer.renderer()->node(); |
46 if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscr
een()) | 46 if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscr
een()) |
47 return false; | 47 return false; |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 GraphicsLayerUpdater::GraphicsLayerUpdater(RenderView& renderView) | 51 GraphicsLayerUpdater::GraphicsLayerUpdater() |
52 : m_renderView(renderView) | |
53 , m_pixelsWithoutPromotingAllTransitions(0.0) | |
54 , m_pixelsAddedByPromotingAllTransitions(0.0) | |
55 { | 52 { |
56 } | 53 } |
57 | 54 |
58 GraphicsLayerUpdater::~GraphicsLayerUpdater() | 55 GraphicsLayerUpdater::~GraphicsLayerUpdater() |
59 { | 56 { |
60 } | 57 } |
61 | 58 |
62 void GraphicsLayerUpdater::rebuildTree(RenderLayer& layer, UpdateType updateType
, GraphicsLayerVector& childLayersOfEnclosingLayer, int depth) | 59 void GraphicsLayerUpdater::rebuildTree(RenderLayer& layer, UpdateType updateType
, GraphicsLayerVector& childLayersOfEnclosingLayer) |
63 { | 60 { |
64 // Make the layer compositing if necessary, and set up clipping and content
layers. | 61 // Make the layer compositing if necessary, and set up clipping and content
layers. |
65 // Note that we can only do work here that is independent of whether the des
cendant layers | 62 // Note that we can only do work here that is independent of whether the des
cendant layers |
66 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. | 63 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. |
67 | 64 |
68 layer.stackingNode()->updateLayerListsIfNeeded(); | 65 layer.stackingNode()->updateLayerListsIfNeeded(); |
69 layer.update3dRenderingContext(); | 66 layer.update3dRenderingContext(); |
70 | 67 |
71 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); | 68 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); |
72 CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLa
yerMapping(); | 69 CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLa
yerMapping(); |
73 | 70 |
74 updateType = update(layer, updateType); | 71 updateType = update(layer, updateType); |
75 | 72 |
76 // Grab some stats for histograms. | |
77 if (hasCompositedLayerMapping) { | |
78 m_pixelsWithoutPromotingAllTransitions += layer.size().height() * layer.
size().width(); | |
79 } else { | |
80 if ((layer.renderer()->style()->transitionForProperty(CSSPropertyOpacity
) || | |
81 layer.renderer()->style()->transitionForProperty(CSSPropertyWebkitT
ransform)) && | |
82 m_renderView.viewRect().intersects(layer.absoluteBoundingBox())) | |
83 m_pixelsAddedByPromotingAllTransitions += layer.size().height() * la
yer.size().width(); | |
84 } | |
85 | |
86 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. | 73 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. |
87 // Otherwise children continue to append to the child list of the enclosing
layer. | 74 // Otherwise children continue to append to the child list of the enclosing
layer. |
88 GraphicsLayerVector layerChildren; | 75 GraphicsLayerVector layerChildren; |
89 GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren :
childLayersOfEnclosingLayer; | 76 GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren :
childLayersOfEnclosingLayer; |
90 | 77 |
91 #if !ASSERT_DISABLED | 78 #if !ASSERT_DISABLED |
92 LayerListMutationDetector mutationChecker(layer.stackingNode()); | 79 LayerListMutationDetector mutationChecker(layer.stackingNode()); |
93 #endif | 80 #endif |
94 | 81 |
95 if (layer.stackingNode()->isStackingContainer()) { | 82 if (layer.stackingNode()->isStackingContainer()) { |
96 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); | 83 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); |
97 while (RenderLayerStackingNode* curNode = iterator.next()) | 84 while (RenderLayerStackingNode* curNode = iterator.next()) |
98 rebuildTree(*curNode->layer(), updateType, childList, depth + 1); | 85 rebuildTree(*curNode->layer(), updateType, childList); |
99 | 86 |
100 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. | 87 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. |
101 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) | 88 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) |
102 childList.append(currentCompositedLayerMapping->foregroundLayer()); | 89 childList.append(currentCompositedLayerMapping->foregroundLayer()); |
103 } | 90 } |
104 | 91 |
105 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); | 92 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); |
106 while (RenderLayerStackingNode* curNode = iterator.next()) | 93 while (RenderLayerStackingNode* curNode = iterator.next()) |
107 rebuildTree(*curNode->layer(), updateType, childList, depth + 1); | 94 rebuildTree(*curNode->layer(), updateType, childList); |
108 | 95 |
109 if (hasCompositedLayerMapping) { | 96 if (hasCompositedLayerMapping) { |
110 bool parented = false; | 97 bool parented = false; |
111 if (layer.renderer()->isRenderPart()) | 98 if (layer.renderer()->isRenderPart()) |
112 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); | 99 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); |
113 | 100 |
114 if (!parented) | 101 if (!parented) |
115 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); | 102 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); |
116 | 103 |
117 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. | 104 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. |
(...skipping 11 matching lines...) Expand all Loading... |
129 | 116 |
130 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForScrollCorner()) { | 117 if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapp
ing->layerForScrollCorner()) { |
131 overflowControlLayer->removeFromParent(); | 118 overflowControlLayer->removeFromParent(); |
132 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); | 119 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); |
133 } | 120 } |
134 } | 121 } |
135 | 122 |
136 if (shouldAppendLayer(layer)) | 123 if (shouldAppendLayer(layer)) |
137 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->ch
ildForSuperlayers()); | 124 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->ch
ildForSuperlayers()); |
138 } | 125 } |
139 | |
140 if (!depth) { | |
141 int percentageIncreaseInPixels = static_cast<int>(m_pixelsAddedByPromoti
ngAllTransitions / m_pixelsWithoutPromotingAllTransitions * 100); | |
142 blink::Platform::current()->histogramCustomCounts("Renderer.PixelIncreas
eFromTransitions", percentageIncreaseInPixels, 0, 1000, 50); | |
143 } | |
144 } | 126 } |
145 | 127 |
146 // This just updates layer geometry without changing the hierarchy. | 128 // This just updates layer geometry without changing the hierarchy. |
147 void GraphicsLayerUpdater::updateRecursive(RenderLayer& layer, UpdateType update
Type) | 129 void GraphicsLayerUpdater::updateRecursive(RenderLayer& layer, UpdateType update
Type) |
148 { | 130 { |
149 updateType = update(layer, updateType); | 131 updateType = update(layer, updateType); |
150 | 132 |
151 #if !ASSERT_DISABLED | 133 #if !ASSERT_DISABLED |
152 LayerListMutationDetector mutationChecker(layer.stackingNode()); | 134 LayerListMutationDetector mutationChecker(layer.stackingNode()); |
153 #endif | 135 #endif |
(...skipping 26 matching lines...) Expand all Loading... |
180 if (!layer.parent()) | 162 if (!layer.parent()) |
181 layer.compositor()->updateRootLayerPosition(); | 163 layer.compositor()->updateRootLayerPosition(); |
182 | 164 |
183 if (mapping->hasUnpositionedOverflowControlsLayers()) | 165 if (mapping->hasUnpositionedOverflowControlsLayers()) |
184 layer.scrollableArea()->positionOverflowControls(); | 166 layer.scrollableArea()->positionOverflowControls(); |
185 | 167 |
186 return updateType; | 168 return updateType; |
187 } | 169 } |
188 | 170 |
189 } // namespace WebCore | 171 } // namespace WebCore |
OLD | NEW |