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

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

Issue 723103002: Revert "Move ViewDisplayList to GraphicsLayer" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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"
10 #include "platform/RuntimeEnabledFeatures.h" 11 #include "platform/RuntimeEnabledFeatures.h"
11 #include "platform/graphics/GraphicsContext.h" 12 #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"
15 13
16 namespace blink { 14 namespace blink {
17 15
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
18 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, DisplayItem::Type clipType, const ClipRect& clipRect) 29 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, DisplayItem::Type clipType, const ClipRect& clipRect)
19 : m_graphicsContext(graphicsContext) 30 : m_graphicsContext(graphicsContext)
20 , m_renderLayer(renderLayer) 31 , m_renderLayer(renderLayer)
21 { 32 {
22 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
23 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { 34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
24 graphicsContext->save(); 35 graphicsContext->save();
25 graphicsContext->clip(snappedClipRect); 36 graphicsContext->clip(snappedClipRect);
26 } else { 37 } else {
27 m_clipDisplayItem = new ClipDisplayItem(nullptr, clipType, snappedClipRe ct); 38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe dClipRect);
28 #ifndef NDEBUG 39 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip DisplayItem));
29 m_clipDisplayItem->setClientDebugString("nullptr");
30 #endif
31 if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvali dationCrossingFrameBoundaries())
32 container->graphicsLayerBacking()->displayItemList().add(adoptPtr(m_ clipDisplayItem));
33 } 40 }
34 } 41 }
35 42
36 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) 43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
37 { 44 {
38 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 45 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
39 m_clipDisplayItem->roundedRectClips().append(roundedRect); 46 m_clipDisplayItem->roundedRectClips().append(roundedRect);
40 else 47 else
41 m_graphicsContext->clipRoundedRect(roundedRect); 48 m_graphicsContext->clipRoundedRect(roundedRect);
42 } 49 }
43 50
44 ClipRecorder::~ClipRecorder() 51 ClipRecorder::~ClipRecorder()
45 { 52 {
46 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
47 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); 54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
48 if (RenderLayer* container = m_renderLayer->enclosingLayerForPaintInvali dationCrossingFrameBoundaries()) 55 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release ());
49 container->graphicsLayerBacking()->displayItemList().add(endClip.rel ease());
50 } else { 56 } else {
51 m_graphicsContext->restore(); 57 m_graphicsContext->restore();
52 } 58 }
53 } 59 }
54 60
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
55 } // namespace blink 70 } // 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