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

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

Issue 719353004: [Slimming Paint] Track clip renderers (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
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 "core/rendering/RenderView.h"
11 #include "platform/RuntimeEnabledFeatures.h" 11 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 void ClipDisplayItem::replay(GraphicsContext* context) 16 void ClipDisplayItem::replay(GraphicsContext* context)
17 { 17 {
18 context->save(); 18 context->save();
19 context->clip(m_clipRect); 19 context->clip(m_clipRect);
20 for (RoundedRect roundedRect : m_roundedRectClips) 20 for (RoundedRect roundedRect : m_roundedRectClips)
21 context->clipRoundedRect(roundedRect); 21 context->clipRoundedRect(roundedRect);
22 } 22 }
23 23
24 void EndClipDisplayItem::replay(GraphicsContext* context) 24 void EndClipDisplayItem::replay(GraphicsContext* context)
25 { 25 {
26 context->restore(); 26 context->restore();
27 } 27 }
28 28
29 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, DisplayItem::Type clipType, const ClipRect& clipRect) 29 ClipRecorder::ClipRecorder(const RenderObject* renderer, RenderLayer* renderLaye r, GraphicsContext* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect)
30 : m_graphicsContext(graphicsContext) 30 : m_graphicsContext(graphicsContext)
31 , m_renderLayer(renderLayer) 31 , m_renderLayer(renderLayer)
32 , m_renderer(renderer)
32 { 33 {
33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 34 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { 35 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
35 graphicsContext->save(); 36 graphicsContext->save();
36 graphicsContext->clip(snappedClipRect); 37 graphicsContext->clip(snappedClipRect);
37 } else { 38 } else {
38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe dClipRect); 39 m_clipDisplayItem = new ClipDisplayItem(renderer, renderLayer, clipType, snappedClipRect);
39 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip DisplayItem)); 40 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip DisplayItem));
chrishtr 2014/11/13 01:46:11 Just use m_renderLayer->renderer() rather than pas
leviw_travelin_and_unemployed 2014/11/13 01:46:40 Remove m_renderLayer and assert we have a layer.
pdr. 2014/11/13 06:49:28 I switched this to not track the render layer at a
40 } 41 }
41 } 42 }
42 43
43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) 44 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
44 { 45 {
45 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 46 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
46 m_clipDisplayItem->roundedRectClips().append(roundedRect); 47 m_clipDisplayItem->roundedRectClips().append(roundedRect);
47 else 48 else
48 m_graphicsContext->clipRoundedRect(roundedRect); 49 m_graphicsContext->clipRoundedRect(roundedRect);
49 } 50 }
50 51
51 ClipRecorder::~ClipRecorder() 52 ClipRecorder::~ClipRecorder()
52 { 53 {
53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { 54 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); 55 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem(m_r enderer));
55 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release ()); 56 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release ());
56 } else { 57 } else {
57 m_graphicsContext->restore(); 58 m_graphicsContext->restore();
58 } 59 }
59 } 60 }
60 61
61 #ifndef NDEBUG 62 #ifndef NDEBUG
62 WTF::String ClipDisplayItem::asDebugString() const 63 WTF::String ClipDisplayItem::asDebugString() const
63 { 64 {
64 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}", 65 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}",
65 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(), 66 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(),
66 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) ; 67 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) ;
67 } 68 }
68 #endif 69 #endif
69 70
70 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698