| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ClipPathClipper_h | 5 #ifndef ClipPathClipper_h |
| 6 #define ClipPathClipper_h | 6 #define ClipPathClipper_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/ClipPathRecorder.h" | 8 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 9 #include "platform/graphics/paint/CompositingRecorder.h" |
| 9 #include "wtf/Optional.h" | 10 #include "wtf/Optional.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 class ClipPathOperation; | 14 class ClipPathOperation; |
| 14 class FloatPoint; | 15 class FloatPoint; |
| 15 class FloatRect; | 16 class FloatRect; |
| 16 class GraphicsContext; | 17 class GraphicsContext; |
| 17 class LayoutSVGResourceClipper; | 18 class LayoutSVGResourceClipper; |
| 18 class LayoutObject; | 19 class LayoutObject; |
| 19 | 20 |
| 20 enum class ClipperState { NotApplied, AppliedPath, AppliedMask }; | 21 enum class ClipperState { NotApplied, AppliedPath, AppliedMask }; |
| 21 | 22 |
| 22 class ClipPathClipper { | 23 class ClipPathClipper { |
| 23 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 ClipPathClipper(GraphicsContext&, | 27 ClipPathClipper(GraphicsContext&, |
| 27 ClipPathOperation&, | 28 ClipPathOperation&, |
| 28 const LayoutObject&, | 29 const LayoutObject&, |
| 29 const FloatRect& referenceBox, | 30 const FloatRect& referenceBox, |
| 30 const FloatPoint& origin); | 31 const FloatPoint& origin); |
| 31 ~ClipPathClipper(); | 32 ~ClipPathClipper(); |
| 32 | 33 |
| 33 bool usingMask() const { return m_clipperState == ClipperState::AppliedMask; } | 34 bool usingMask() const { return m_clipperState == ClipperState::AppliedMask; } |
| 34 | 35 |
| 35 private: | 36 private: |
| 37 // Returns false if there is a problem drawing the mask. |
| 38 bool prepareEffect(const FloatRect& targetBoundingBox, |
| 39 const FloatRect& visualRect, |
| 40 const FloatPoint& layerPositionOffset); |
| 41 bool drawClipAsMask(const FloatRect& targetBoundingBox, |
| 42 const FloatRect& targetVisualRect, |
| 43 const AffineTransform&, |
| 44 const FloatPoint&); |
| 45 void finishEffect(); |
| 46 |
| 36 LayoutSVGResourceClipper* m_resourceClipper; | 47 LayoutSVGResourceClipper* m_resourceClipper; |
| 37 Optional<ClipPathRecorder> m_clipPathRecorder; | |
| 38 ClipperState m_clipperState; | 48 ClipperState m_clipperState; |
| 39 const LayoutObject& m_layoutObject; | 49 const LayoutObject& m_layoutObject; |
| 40 GraphicsContext& m_context; | 50 GraphicsContext& m_context; |
| 51 |
| 52 // TODO(pdr): This pattern should be cleaned up so that the recorders are just |
| 53 // on the stack. |
| 54 Optional<ClipPathRecorder> m_clipPathRecorder; |
| 55 Optional<CompositingRecorder> m_maskClipRecorder; |
| 56 Optional<CompositingRecorder> m_maskContentRecorder; |
| 41 }; | 57 }; |
| 42 | 58 |
| 43 } // namespace blink | 59 } // namespace blink |
| 44 | 60 |
| 45 #endif // ClipPathClipper_h | 61 #endif // ClipPathClipper_h |
| OLD | NEW |