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

Side by Side Diff: Source/core/paint/LayerPainter.cpp

Issue 744163002: Enable fast/images with slimming paint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToT-ed with enum. Created 6 years, 1 month 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
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 "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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice. 73 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th e transform twice.
74 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) { 74 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint Flags & PaintLayerAppliedTransform)) {
75 paintLayerWithTransform(context, paintingInfo, paintFlags); 75 paintLayerWithTransform(context, paintingInfo, paintFlags);
76 return; 76 return;
77 } 77 }
78 78
79 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 79 paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
80 } 80 }
81 81
82 class TransparencyLayerHelper {
83 public:
84 TransparencyLayerHelper(GraphicsContext* context, RenderLayer& renderLayer, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize & subPixelAccumulation, PaintBehavior paintBehavior)
85 : m_transparencyLayerInProgress(false)
86 , m_context(context)
87 , m_renderLayer(renderLayer)
88 {
89 // Blending operations must be performed only with the nearest ancestor stacking context.
90 // Note that there is no need to create a transparency layer if we're pa inting the root.
91 // FIXME: this should be unified further into RenderLayer::paintsWithTra nsparency().
92 bool shouldUseTransparencyLayerForBlendMode = !renderLayer.renderer()->i sDocumentElement() && renderLayer.stackingNode()->isStackingContext() && renderL ayer.hasNonIsolatedDescendantWithBlendMode();
93 if (!shouldUseTransparencyLayerForBlendMode && !renderLayer.paintsWithTr ansparency(paintBehavior))
94 return;
95
96 OwnPtr<BeginTransparencyDisplayItem> beginTransparencyDisplayItem = adop tPtr(new BeginTransparencyDisplayItem(
97 renderLayer.renderer(), DisplayItem::BeginTransparency, renderLayer. paintingExtent(rootLayer, paintDirtyRect, subPixelAccumulation, paintBehavior),
98 renderLayer.renderer()->style()->blendMode(), renderLayer.renderer() ->opacity()));
99 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
100 renderLayer.renderer()->view()->viewDisplayList().add(beginTranspare ncyDisplayItem.release());
101 else
102 beginTransparencyDisplayItem->replay(context);
103
104 m_transparencyLayerInProgress = true;
105 }
106
107 ~TransparencyLayerHelper()
108 {
109 if (!m_transparencyLayerInProgress)
110 return;
111 OwnPtr<EndTransparencyDisplayItem> endTransparencyDisplayItem = adoptPtr (new EndTransparencyDisplayItem(m_renderLayer.renderer(), DisplayItem::EndTransp arency));
112 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
113 m_renderLayer.renderer()->view()->viewDisplayList().add(endTranspare ncyDisplayItem.release());
114 else
115 endTransparencyDisplayItem->replay(m_context);
116 }
117 private:
118 bool m_transparencyLayerInProgress;
119 GraphicsContext* m_context;
120 const RenderLayer& m_renderLayer;
121 };
122
123 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 82 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
124 { 83 {
125 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant()); 84 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL ayerDescendant());
126 85
127 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; 86 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ;
128 87
129 // Paint the reflection first if we have one. 88 // Paint the reflection first if we have one.
130 if (m_renderLayer.reflectionInfo()) 89 if (m_renderLayer.reflectionInfo())
131 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF lags | PaintLayerPaintingReflection); 90 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF lags | PaintLayerPaintingReflection);
132 91
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 195
237 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) 196 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking)
238 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); 197 offsetFromRoot.move(m_renderLayer.subpixelAccumulation());
239 198
240 LayoutRect rootRelativeBounds; 199 LayoutRect rootRelativeBounds;
241 bool rootRelativeBoundsComputed = false; 200 bool rootRelativeBoundsComputed = false;
242 201
243 // These helpers output clip and transparency layers using a RAII pattern. S tack-allocated-varibles are destructed in the reverse order of construction, 202 // These helpers output clip and transparency layers using a RAII pattern. S tack-allocated-varibles are destructed in the reverse order of construction,
244 // so they are nested properly. 203 // so they are nested properly.
245 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 204 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);
246 TransparencyLayerHelper transparencyLayerHelper(context, m_renderLayer, pain tingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulati on, paintingInfo.paintBehavior); 205
206 OwnPtr<TransparencyRecorder> transparencyRecorder;
207 // Blending operations must be performed only with the nearest ancestor stac king context.
208 // Note that there is no need to create a transparency layer if we're painti ng the root.
209 // FIXME: this should be unified further into RenderLayer::paintsWithTranspa rency().
210 bool shouldUseTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isD ocumentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_rende rLayer.hasNonIsolatedDescendantWithBlendMode();
211 if (shouldUseTransparencyLayerForBlendMode || m_renderLayer.paintsWithTransp arency(paintingInfo.paintBehavior)) {
212 transparencyRecorder = adoptPtr(new TransparencyRecorder(context, m_rend erLayer.renderer(), DisplayItem::BeginTransparency, m_renderLayer.paintingExtent (paintingInfo.rootLayer, paintingInfo.paintDirtyRect,
pdr. 2014/11/21 20:09:05 What do you think about emiting a clip here with t
213 paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior), m_re nderLayer.renderer()->style()->blendMode(), m_renderLayer.renderer()->opacity()) );
214 }
247 215
248 LayerPaintingInfo localPaintingInfo(paintingInfo); 216 LayerPaintingInfo localPaintingInfo(paintingInfo);
249 217
250 LayerFragments layerFragments; 218 LayerFragments layerFragments;
251 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 219 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
252 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 220 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
253 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay er, localPaintingInfo.paintDirtyRect, 221 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay er, localPaintingInfo.paintDirtyRect,
254 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai ntingClipRects, IgnoreOverlayScrollbarSize, 222 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai ntingClipRects, IgnoreOverlayScrollbarSize,
255 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of fsetFromRoot, localPaintingInfo.subPixelAccumulation); 223 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of fsetFromRoot, localPaintingInfo.subPixelAccumulation);
256 if (shouldPaintContent) 224 if (shouldPaintContent)
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 if (!m_renderLayer.containsDirtyOverlayScrollbars()) 727 if (!m_renderLayer.containsDirtyOverlayScrollbars())
760 return; 728 return;
761 729
762 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot); 730 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect), paintBehavior, LayoutSize(), paintingRoot);
763 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 731 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
764 732
765 m_renderLayer.setContainsDirtyOverlayScrollbars(false); 733 m_renderLayer.setContainsDirtyOverlayScrollbars(false);
766 } 734 }
767 735
768 } // namespace blink 736 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698