| 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/ClipRect.h" |
| 9 #include "core/rendering/RenderObject.h" | |
| 10 #include "core/rendering/RenderView.h" | 9 #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" |
| 13 | 12 |
| 14 namespace blink { | 13 namespace blink { |
| 15 | 14 |
| 16 void ClipDisplayItem::replay(GraphicsContext* context) | 15 void ClipDisplayItem::replay(GraphicsContext* context) |
| 17 { | 16 { |
| 18 context->save(); | 17 context->save(); |
| 19 context->clip(m_clipRect); | 18 context->clip(m_clipRect); |
| 20 for (RoundedRect roundedRect : m_roundedRectClips) | 19 for (RoundedRect roundedRect : m_roundedRectClips) |
| 21 context->clipRoundedRect(roundedRect); | 20 context->clipRoundedRect(roundedRect); |
| 22 } | 21 } |
| 23 | 22 |
| 24 void EndClipDisplayItem::replay(GraphicsContext* context) | 23 void EndClipDisplayItem::replay(GraphicsContext* context) |
| 25 { | 24 { |
| 26 context->restore(); | 25 context->restore(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo
ntext, DisplayItem::Type clipType, const ClipRect& clipRect) | 28 ClipRecorder::ClipRecorder(const RenderLayerModelObject* renderer, GraphicsConte
xt* graphicsContext, DisplayItem::Type clipType, const ClipRect& clipRect) |
| 30 : m_graphicsContext(graphicsContext) | 29 : m_graphicsContext(graphicsContext) |
| 31 , m_renderLayer(renderLayer) | 30 , m_renderer(renderer) |
| 32 { | 31 { |
| 33 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 32 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 34 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 33 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 35 graphicsContext->save(); | 34 graphicsContext->save(); |
| 36 graphicsContext->clip(snappedClipRect); | 35 graphicsContext->clip(snappedClipRect); |
| 37 } else { | 36 } else { |
| 38 m_clipDisplayItem = new ClipDisplayItem(0, renderLayer, clipType, snappe
dClipRect); | 37 m_clipDisplayItem = new ClipDisplayItem(renderer, clipType, snappedClipR
ect); |
| 39 m_renderLayer->renderer()->view()->viewDisplayList().add(adoptPtr(m_clip
DisplayItem)); | 38 m_renderer->view()->viewDisplayList().add(adoptPtr(m_clipDisplayItem)); |
| 40 } | 39 } |
| 41 } | 40 } |
| 42 | 41 |
| 43 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) | 42 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) |
| 44 { | 43 { |
| 45 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 44 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 46 m_clipDisplayItem->roundedRectClips().append(roundedRect); | 45 m_clipDisplayItem->roundedRectClips().append(roundedRect); |
| 47 else | 46 else |
| 48 m_graphicsContext->clipRoundedRect(roundedRect); | 47 m_graphicsContext->clipRoundedRect(roundedRect); |
| 49 } | 48 } |
| 50 | 49 |
| 51 ClipRecorder::~ClipRecorder() | 50 ClipRecorder::~ClipRecorder() |
| 52 { | 51 { |
| 53 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 52 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 54 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); | 53 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem(m_r
enderer)); |
| 55 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release
()); | 54 m_renderer->view()->viewDisplayList().add(endClip.release()); |
| 56 } else { | 55 } else { |
| 57 m_graphicsContext->restore(); | 56 m_graphicsContext->restore(); |
| 58 } | 57 } |
| 59 } | 58 } |
| 60 | 59 |
| 61 #ifndef NDEBUG | 60 #ifndef NDEBUG |
| 62 WTF::String ClipDisplayItem::asDebugString() const | 61 WTF::String ClipDisplayItem::asDebugString() const |
| 63 { | 62 { |
| 64 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}", | 63 return String::format("{%s, type: \"%s\", clipRect: [%d,%d,%d,%d]}", |
| 65 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), | 64 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), |
| 66 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
; | 65 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
; |
| 67 } | 66 } |
| 68 #endif | 67 #endif |
| 69 | 68 |
| 70 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |