OLD | NEW |
---|---|
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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/LayerPainter.h" | 6 #include "core/paint/LayerPainter.h" |
7 | 7 |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice. | 79 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice. |
80 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) { | 80 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) { |
81 paintLayerWithTransform(context, paintingInfo, paintFlags); | 81 paintLayerWithTransform(context, paintingInfo, paintFlags); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); | 85 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
86 } | 86 } |
87 | 87 |
88 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 88 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy f ragmentPolicy) |
89 { | 89 { |
90 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant()); | 90 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant()); |
91 | 91 |
92 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; | 92 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; |
93 | 93 |
94 // Paint the reflection first if we have one. | 94 // Paint the reflection first if we have one. |
95 if (m_renderLayer.reflectionInfo()) | 95 if (m_renderLayer.reflectionInfo()) |
96 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF lags | PaintLayerPaintingReflection); | 96 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF lags | PaintLayerPaintingReflection); |
97 | 97 |
98 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; | 98 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; |
99 paintLayerContents(context, paintingInfo, localPaintFlags); | 99 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); |
100 } | 100 } |
101 | 101 |
102 class ClipPathHelper { | 102 class ClipPathHelper { |
103 public: | 103 public: |
104 ClipPathHelper(GraphicsContext* context, const RenderLayer& renderLayer, con st LayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRe lativeBoundsComputed, | 104 ClipPathHelper(GraphicsContext* context, const RenderLayer& renderLayer, con st LayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRe lativeBoundsComputed, |
105 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) | 105 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) |
106 : m_resourceClipper(0), m_clipStateSaver(*context, false), m_renderLayer (renderLayer), m_context(context) | 106 : m_resourceClipper(0), m_clipStateSaver(*context, false), m_renderLayer (renderLayer), m_context(context) |
107 { | 107 { |
108 RenderStyle* style = renderLayer.renderer()->style(); | 108 RenderStyle* style = renderLayer.renderer()->style(); |
109 | 109 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer( ), m_context, m_clipperState); | 158 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer( ), m_context, m_clipperState); |
159 } | 159 } |
160 private: | 160 private: |
161 RenderSVGResourceClipper* m_resourceClipper; | 161 RenderSVGResourceClipper* m_resourceClipper; |
162 GraphicsContextStateSaver m_clipStateSaver; | 162 GraphicsContextStateSaver m_clipStateSaver; |
163 RenderSVGResourceClipper::ClipperState m_clipperState; | 163 RenderSVGResourceClipper::ClipperState m_clipperState; |
164 const RenderLayer& m_renderLayer; | 164 const RenderLayer& m_renderLayer; |
165 GraphicsContext* m_context; | 165 GraphicsContext* m_context; |
166 }; | 166 }; |
167 | 167 |
168 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint ingInfo& paintingInfo, PaintLayerFlags paintFlags) | 168 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy ) |
169 { | 169 { |
170 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant()); | 170 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant()); |
171 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 171 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
172 | 172 |
173 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); | 173 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); |
174 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars; | 174 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars; |
175 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing ScrollingPhase; | 175 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing ScrollingPhase; |
176 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi tingForegroundPhase; | 176 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi tingForegroundPhase; |
177 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi tingBackgroundPhase; | 177 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi tingBackgroundPhase; |
178 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon tents; | 178 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon tents; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 | 219 |
220 transparencyRecorder = adoptPtr(new TransparencyRecorder(context, m_rend erLayer.renderer()->displayItemClient(), | 220 transparencyRecorder = adoptPtr(new TransparencyRecorder(context, m_rend erLayer.renderer()->displayItemClient(), |
221 context->compositeOperation(), m_renderLayer.renderer()->style()->bl endMode(), m_renderLayer.renderer()->opacity(), context->compositeOperation())); | 221 context->compositeOperation(), m_renderLayer.renderer()->style()->bl endMode(), m_renderLayer.renderer()->opacity(), context->compositeOperation())); |
222 } | 222 } |
223 | 223 |
224 LayerPaintingInfo localPaintingInfo(paintingInfo); | 224 LayerPaintingInfo localPaintingInfo(paintingInfo); |
225 | 225 |
226 LayerFragments layerFragments; | 226 LayerFragments layerFragments; |
227 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { | 227 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { |
228 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. | 228 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. |
229 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay er, localPaintingInfo.paintDirtyRect, | 229 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; |
230 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai ntingClipRects, IgnoreOverlayScrollbarSize, | 230 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_renderLayer.renderer()); |
231 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of fsetFromRoot, localPaintingInfo.subPixelAccumulation); | 231 if (fragmentPolicy == ForceSingleFragment) |
232 m_renderLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignor eOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.s ubPixelAccumulation); | |
233 else | |
234 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.roo tLayer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); | |
232 if (shouldPaintContent) | 235 if (shouldPaintContent) |
233 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); | 236 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); |
234 } | 237 } |
235 | 238 |
236 bool selectionOnly = localPaintingInfo.paintBehavior & PaintBehaviorSelectio nOnly; | 239 bool selectionOnly = localPaintingInfo.paintBehavior & PaintBehaviorSelectio nOnly; |
237 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which | 240 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which |
238 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set). | 241 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set). |
239 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along | 242 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along |
240 // so it will be tested against as we descend through the renderers. | 243 // so it will be tested against as we descend through the renderers. |
241 RenderObject* paintingRootForRenderer = 0; | 244 RenderObject* paintingRootForRenderer = 0; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 if (parentLayer) { | 371 if (parentLayer) { |
369 ClipRect clipRectForFragment(clipRect); | 372 ClipRect clipRectForFragment(clipRect); |
370 clipRectForFragment.moveBy(fragment.paginationOffset); | 373 clipRectForFragment.moveBy(fragment.paginationOffset); |
371 clipRectForFragment.intersect(fragment.backgroundRect); | 374 clipRectForFragment.intersect(fragment.backgroundRect); |
372 if (clipRectForFragment.isEmpty()) | 375 if (clipRectForFragment.isEmpty()) |
373 continue; | 376 continue; |
374 if (needsToClip(paintingInfo, clipRectForFragment)) | 377 if (needsToClip(paintingInfo, clipRectForFragment)) |
375 clipRecorder = adoptPtr(new LayerClipRecorder(parentLayer->rende rer(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &paintingInfo , fragment.paginationOffset, paintFlags)); | 378 clipRecorder = adoptPtr(new LayerClipRecorder(parentLayer->rende rer(), context, DisplayItem::ClipLayerParent, clipRectForFragment, &paintingInfo , fragment.paginationOffset, paintFlags)); |
376 } | 379 } |
377 | 380 |
378 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset); | 381 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset); |
chrishtr
2015/01/15 18:49:47
It looks like a bunch of the complexity in this CL
mstensho (USE GERRIT)
2015/01/15 20:36:47
Sorry, I'm not sure if I understand. This CL isn't
| |
379 } | 382 } |
380 } | 383 } |
381 | 384 |
382 void LayerPainter::paintFragmentByApplyingTransform(GraphicsContext* context, co nst LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoi nt& fragmentTranslation) | 385 void LayerPainter::paintFragmentByApplyingTransform(GraphicsContext* context, co nst LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoi nt& fragmentTranslation) |
383 { | 386 { |
384 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving | 387 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving |
385 // the accumulated error for sub-pixel layout. | 388 // the accumulated error for sub-pixel layout. |
386 LayoutPoint delta; | 389 LayoutPoint delta; |
387 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 390 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
388 delta.moveBy(fragmentTranslation); | 391 delta.moveBy(fragmentTranslation); |
389 TransformationMatrix transform(m_renderLayer.renderableTransform(paintingInf o.paintBehavior)); | 392 TransformationMatrix transform(m_renderLayer.renderableTransform(paintingInf o.paintBehavior)); |
390 IntPoint roundedDelta = roundedIntPoint(delta); | 393 IntPoint roundedDelta = roundedIntPoint(delta); |
391 transform.translateRight(roundedDelta.x(), roundedDelta.y()); | 394 transform.translateRight(roundedDelta.x(), roundedDelta.y()); |
392 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); | 395 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); |
393 | 396 |
394 TransformRecorder transformRecorder(*context, m_renderLayer.renderer()->disp layItemClient(), transform.toAffineTransform()); | 397 TransformRecorder transformRecorder(*context, m_renderLayer.renderer()->disp layItemClient(), transform.toAffineTransform()); |
395 | 398 |
396 // Now do a paint with the root layer shifted to be us. | 399 // Now do a paint with the root layer shifted to be us. |
397 LayerPaintingInfo transformedPaintingInfo(&m_renderLayer, enclosingIntRect(t ransform.inverse().mapRect(paintingInfo.paintDirtyRect)), paintingInfo.paintBeha vior, | 400 LayerPaintingInfo transformedPaintingInfo(&m_renderLayer, enclosingIntRect(t ransform.inverse().mapRect(paintingInfo.paintDirtyRect)), paintingInfo.paintBeha vior, |
398 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); | 401 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); |
399 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags ); | 402 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags , ForceSingleFragment); |
chrishtr
2015/01/15 23:33:45
What I mean is that this call stack appears to be
mstensho (USE GERRIT)
2015/02/03 13:55:01
paintLayerWithTransform() collects fragment(s) for
| |
400 } | 403 } |
401 | 404 |
402 void LayerPainter::paintChildren(unsigned childrenToVisit, GraphicsContext* cont ext, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 405 void LayerPainter::paintChildren(unsigned childrenToVisit, GraphicsContext* cont ext, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
403 { | 406 { |
404 if (!m_renderLayer.hasSelfPaintingLayerDescendant()) | 407 if (!m_renderLayer.hasSelfPaintingLayerDescendant()) |
405 return; | 408 return; |
406 | 409 |
407 #if ENABLE(ASSERT) | 410 #if ENABLE(ASSERT) |
408 LayerListMutationDetector mutationChecker(m_renderLayer.stackingNode()); | 411 LayerListMutationDetector mutationChecker(m_renderLayer.stackingNode()); |
409 #endif | 412 #endif |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 if (!m_renderLayer.containsDirtyOverlayScrollbars()) | 724 if (!m_renderLayer.containsDirtyOverlayScrollbars()) |
722 return; | 725 return; |
723 | 726 |
724 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot); | 727 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot); |
725 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 728 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
726 | 729 |
727 m_renderLayer.setContainsDirtyOverlayScrollbars(false); | 730 m_renderLayer.setContainsDirtyOverlayScrollbars(false); |
728 } | 731 } |
729 | 732 |
730 } // namespace blink | 733 } // namespace blink |
OLD | NEW |