| 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 #ifndef ClipRecorder_h | 5 #ifndef ClipRecorder_h |
| 6 #define ClipRecorder_h | 6 #define ClipRecorder_h |
| 7 | 7 |
| 8 #include "core/paint/ViewDisplayList.h" | 8 #include "core/paint/ViewDisplayList.h" |
| 9 #include "core/rendering/LayerPaintingInfo.h" |
| 10 #include "core/rendering/PaintPhase.h" |
| 9 #include "core/rendering/RenderLayerModelObject.h" | 11 #include "core/rendering/RenderLayerModelObject.h" |
| 10 #include "platform/geometry/LayoutRect.h" | |
| 11 #include "platform/geometry/RoundedRect.h" | 12 #include "platform/geometry/RoundedRect.h" |
| 13 #include "wtf/Vector.h" |
| 12 | 14 |
| 13 namespace blink { | 15 namespace blink { |
| 14 | 16 |
| 15 class RenderLayerModelObject; | 17 class ClipRect; |
| 16 struct PaintInfo; | 18 class GraphicsContext; |
| 17 | 19 |
| 18 class ClipDisplayItem : public DisplayItem { | 20 class ClipDisplayItem : public DisplayItem { |
| 19 public: | 21 public: |
| 20 ClipDisplayItem(const RenderLayerModelObject* renderer, Type type, IntRect c
lipRect) | 22 ClipDisplayItem(const RenderLayerModelObject* renderer, Type type, IntRect c
lipRect) |
| 21 : DisplayItem(renderer, type), m_clipRect(clipRect) { } | 23 : DisplayItem(renderer, type), m_clipRect(clipRect) { } |
| 22 | 24 |
| 23 Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; } | 25 Vector<RoundedRect>& roundedRectClips() { return m_roundedRectClips; } |
| 24 virtual void replay(GraphicsContext*) override; | 26 virtual void replay(GraphicsContext*) override; |
| 25 | 27 |
| 26 IntRect m_clipRect; | 28 IntRect m_clipRect; |
| 27 Vector<RoundedRect> m_roundedRectClips; | 29 Vector<RoundedRect> m_roundedRectClips; |
| 28 #ifndef NDEBUG | 30 #ifndef NDEBUG |
| 29 virtual WTF::String asDebugString() const override; | 31 virtual WTF::String asDebugString() const override; |
| 30 #endif | 32 #endif |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 class EndClipDisplayItem : public DisplayItem { | 35 class EndClipDisplayItem : public DisplayItem { |
| 34 public: | 36 public: |
| 35 EndClipDisplayItem(const RenderLayerModelObject* renderer) : DisplayItem(ren
derer, EndClip) { } | 37 EndClipDisplayItem(const RenderLayerModelObject* renderer) : DisplayItem(ren
derer, EndClip) { } |
| 36 | 38 |
| 37 virtual void replay(GraphicsContext*) override; | 39 virtual void replay(GraphicsContext*) override; |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 class ClipRecorder { | 42 class ClipRecorder { |
| 41 public: | 43 public: |
| 42 ClipRecorder(RenderLayerModelObject&, const PaintInfo&, const LayoutRect& cl
ipRect); | 44 |
| 45 enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelf
ForBorderRadius }; |
| 46 |
| 47 // Set rounded clip rectangles defined by border radii all the way from the
LayerPaintingInfo |
| 48 // "root" layer down to the specified layer (or the parent of said layer, in
case |
| 49 // BorderRadiusClippingRule says to skip self). fragmentOffset is used for m
ulticol, to specify |
| 50 // the translation required to get from flow thread coordinates to visual co
ordinates for a |
| 51 // certain column. |
| 52 // FIXME: The BorderRadiusClippingRule parameter is really useless now. If w
e want to skip self, |
| 53 // why not just supply the parent layer as the first parameter instead? |
| 54 // FIXME: The ClipRect passed is in visual coordinates (not flow thread coor
dinates), but at the |
| 55 // same time we pass a fragmentOffset, so that we can translate from flow th
read coordinates to |
| 56 // visual coordinates. This may look rather confusing/redundant, but it is n
eeded for rounded |
| 57 // border clipping. Would be nice to clean up this. |
| 58 explicit ClipRecorder(const RenderLayerModelObject*, GraphicsContext*, Displ
ayItem::Type, const ClipRect&, const LayerPaintingInfo* localPaintingInfo, const
LayoutPoint& fragmentOffset, PaintLayerFlags, BorderRadiusClippingRule = Includ
eSelfForBorderRadius); |
| 59 |
| 43 ~ClipRecorder(); | 60 ~ClipRecorder(); |
| 44 | 61 |
| 45 static DisplayItem::Type paintPhaseToClipType(PaintPhase); | |
| 46 private: | 62 private: |
| 47 LayoutRect m_clipRect; | 63 |
| 48 const PaintInfo& m_paintInfo; | 64 void collectRoundedRectClips(RenderLayer&, const LayerPaintingInfo& localPai
ntingInfo, GraphicsContext*, const LayoutPoint& fragmentOffset, PaintLayerFlags, |
| 49 RenderLayerModelObject& m_canvas; | 65 BorderRadiusClippingRule, Vector<RoundedRect>& roundedRectClips); |
| 66 |
| 67 GraphicsContext* m_graphicsContext; |
| 68 const RenderLayerModelObject* m_renderer; |
| 50 }; | 69 }; |
| 51 | 70 |
| 52 } // namespace blink | 71 } // namespace blink |
| 53 | 72 |
| 54 #endif // ClipRecorder_h | 73 #endif // ViewDisplayList_h |
| OLD | NEW |