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

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

Issue 702633002: Move ViewDisplayList to GraphicsLayer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: copy & pasted test expectation from the wrong window. sorry. :( 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
« no previous file with comments | « Source/core/paint/ClipRecorder.h ('k') | Source/core/paint/ClipRecorderTest.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 // 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/ClipRecorder.h" 6 #include "core/paint/ClipRecorder.h"
7 7
8 #include "core/rendering/RenderLayer.h" 8 #include "core/rendering/RenderLayer.h"
9 #include "core/rendering/RenderObject.h" 9 #include "core/rendering/RenderObject.h"
10 #include "core/rendering/RenderView.h"
11 #include "platform/RuntimeEnabledFeatures.h" 10 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/graphics/GraphicsContext.h" 11 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/graphics/paint/ClipDisplayItem.h"
14 #include "platform/graphics/paint/DisplayItemList.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 void ClipDisplayItem::replay(GraphicsContext* context)
17 {
18 context->save();
19 context->clip(m_clipRect);
20 for (RoundedRect roundedRect : m_roundedRectClips)
21 context->clipRoundedRect(roundedRect);
22 }
23
24 void EndClipDisplayItem::replay(GraphicsContext* context)
25 {
26 context->restore();
27 }
28
29 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, DisplayItem::Type clipType, const ClipRect& clipRect) 18 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, DisplayItem::Type clipType, const ClipRect& clipRect)
30 : m_graphicsContext(graphicsContext) 19 : m_graphicsContext(graphicsContext)
31 , m_renderLayer(renderLayer) 20 , m_renderLayer(renderLayer)
32 { 21 {
33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 22 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { 23 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
35 graphicsContext->save(); 24 graphicsContext->save();
36 graphicsContext->clip(snappedClipRect); 25 graphicsContext->clip(snappedClipRect);
37 } else { 26 } else {
38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe dClipRect); 27 m_clipDisplayItem = new ClipDisplayItem(nullptr, clipType, snappedClipRe ct);
39 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip DisplayItem)); 28 #ifndef NDEBUG
29 m_clipDisplayItem->setClientDebugString("nullptr");
30 #endif
31 if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvali dationCrossingFrameBoundaries())
32 container->graphicsLayerBacking()->displayItemList().add(adoptPtr(m_ clipDisplayItem));
40 } 33 }
41 } 34 }
42 35
43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) 36 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
44 { 37 {
45 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 38 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
46 m_clipDisplayItem->roundedRectClips().append(roundedRect); 39 m_clipDisplayItem->roundedRectClips().append(roundedRect);
47 else 40 else
48 m_graphicsContext->clipRoundedRect(roundedRect); 41 m_graphicsContext->clipRoundedRect(roundedRect);
49 } 42 }
50 43
51 ClipRecorder::~ClipRecorder() 44 ClipRecorder::~ClipRecorder()
52 { 45 {
53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 46 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); 47 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
55 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release ()); 48 if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvali dationCrossingFrameBoundaries())
49 container->graphicsLayerBacking()->displayItemList().add(endClip.rel ease());
56 } else { 50 } else {
57 m_graphicsContext->restore(); 51 m_graphicsContext->restore();
58 } 52 }
59 } 53 }
60 54
61 #ifndef NDEBUG
62 WTF::String ClipDisplayItem::asDebugString() const
63 {
64 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}",
65 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(),
66 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) ;
67 }
68 #endif
69
70 } // namespace blink 55 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ClipRecorder.h ('k') | Source/core/paint/ClipRecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698