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

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

Issue 757183003: Revert of Enable fast/images with slimming paint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/LayerClipRecorderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/LayerClipRecorder.h"
7
8 #include "core/paint/ClipRecorder.h"
9 #include "core/rendering/ClipRect.h"
10 #include "core/rendering/RenderLayer.h"
11 #include "core/rendering/RenderView.h"
12 #include "platform/RuntimeEnabledFeatures.h"
13 #include "platform/geometry/IntRect.h"
14 #include "platform/graphics/GraphicsContext.h"
15
16 namespace blink {
17
18 void ClipDisplayItem::replay(GraphicsContext* context)
19 {
20 context->save();
21 context->clip(m_clipRect);
22 for (RoundedRect roundedRect : m_roundedRectClips)
23 context->clipRoundedRect(roundedRect);
24 }
25
26 void EndClipDisplayItem::replay(GraphicsContext* context)
27 {
28 context->restore();
29 }
30
31 LayerClipRecorder::LayerClipRecorder(const RenderLayerModelObject* renderer, Gra phicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipR ect,
32 const LayerPaintingInfo* localPaintingInfo, const LayoutPoint& fragmentOffse t, PaintLayerFlags paintFlags, BorderRadiusClippingRule rule)
33 : m_graphicsContext(graphicsContext)
34 , m_renderer(renderer)
35 {
36 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
37 OwnPtr<ClipDisplayItem> clipDisplayItem = adoptPtr(new ClipDisplayItem(rende rer, clipType, snappedClipRect));
38 if (localPaintingInfo && clipRect.hasRadius())
39 collectRoundedRectClips(*renderer->layer(), *localPaintingInfo, graphics Context, fragmentOffset, paintFlags, rule, clipDisplayItem->roundedRectClips());
40 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
41 clipDisplayItem->replay(graphicsContext);
42 } else {
43 m_renderer->view()->viewDisplayList().add(clipDisplayItem.release());
44 }
45 }
46
47 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye r)
48 {
49 if (startLayer == endLayer)
50 return true;
51
52 RenderView* view = startLayer->renderer()->view();
53 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) {
54 if (currentBlock->layer() == endLayer)
55 return true;
56 }
57
58 return false;
59 }
60
61 void LayerClipRecorder::collectRoundedRectClips(RenderLayer& renderLayer, const LayerPaintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoin t& fragmentOffset, PaintLayerFlags paintFlags,
62 BorderRadiusClippingRule rule, Vector<RoundedRect>& roundedRectClips)
63 {
64 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from
65 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our
66 // containing block chain so we check that also.
67 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer : renderLayer.parent(); layer; layer = layer->parent()) {
68 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not
69 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering
70 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so
71 // that it can in turn clip the scrolled contents in the compositor.
72 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti ngChildClippingMaskPhase))
73 break;
74
75 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) {
76 LayoutPoint delta(fragmentOffset);
77 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta);
78 roundedRectClips.append(layer->renderer()->style()->getRoundedInnerB orderFor(LayoutRect(delta, LayoutSize(layer->size()))));
79 }
80
81 if (layer == localPaintingInfo.rootLayer)
82 break;
83 }
84 }
85
86 LayerClipRecorder::~LayerClipRecorder()
87 {
88 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
89 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem(m_r enderer));
90 m_renderer->view()->viewDisplayList().add(endClip.release());
91 } else {
92 m_graphicsContext->restore();
93 }
94 }
95
96 #ifndef NDEBUG
97 WTF::String ClipDisplayItem::asDebugString() const
98 {
99 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}",
100 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(),
101 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) ;
102 }
103 #endif
104
105 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerClipRecorder.h ('k') | Source/core/paint/LayerClipRecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698