OLD | NEW |
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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 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) |
30 : m_graphicsContext(graphicsContext) | 30 : m_graphicsContext(graphicsContext) |
31 , m_renderLayer(renderLayer) | 31 , m_renderLayer(renderLayer) |
32 { | 32 { |
33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
35 graphicsContext->save(); | 35 graphicsContext->save(); |
36 graphicsContext->clip(snappedClipRect); | 36 graphicsContext->clip(snappedClipRect); |
37 } else { | 37 } else { |
38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe
dClipRect); | 38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe
dClipRect); |
39 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip
DisplayItem)); | 39 ViewDisplayList::fromRenderLayer(m_renderLayer).add(adoptPtr(m_clipDispl
ayItem)); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) | 43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) |
44 { | 44 { |
45 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 45 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
46 m_clipDisplayItem->roundedRectClips().append(roundedRect); | 46 m_clipDisplayItem->roundedRectClips().append(roundedRect); |
47 else | 47 else |
48 m_graphicsContext->clipRoundedRect(roundedRect); | 48 m_graphicsContext->clipRoundedRect(roundedRect); |
49 } | 49 } |
50 | 50 |
51 ClipRecorder::~ClipRecorder() | 51 ClipRecorder::~ClipRecorder() |
52 { | 52 { |
53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); | 54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); |
55 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release
()); | 55 ViewDisplayList::fromRenderLayer(m_renderLayer).add(endClip.release()); |
56 } else { | 56 } else { |
57 m_graphicsContext->restore(); | 57 m_graphicsContext->restore(); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 #ifndef NDEBUG | 61 #ifndef NDEBUG |
62 WTF::String ClipDisplayItem::asDebugString() const | 62 WTF::String ClipDisplayItem::asDebugString() const |
63 { | 63 { |
64 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}", | 64 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}", |
65 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), | 65 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), |
66 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
; | 66 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
; |
67 } | 67 } |
68 #endif | 68 #endif |
69 | 69 |
70 } // namespace blink | 70 } // namespace blink |
OLD | NEW |