| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BoxReflection_h |
| 6 #define BoxReflection_h |
| 7 |
| 8 #include "platform/PlatformExport.h" |
| 9 #include "third_party/skia/include/core/SkPicture.h" |
| 10 #include "wtf/PassRefPtr.h" |
| 11 #include "wtf/RefPtr.h" |
| 12 |
| 13 class SkImageFilter; |
| 14 class SkMatrix; |
| 15 class SkPicture; |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 class FloatRect; |
| 20 |
| 21 // A reflection, as created by -webkit-box-reflect. Consists of: |
| 22 // * a direction (either vertical or horizontal) |
| 23 // * an offset to be applied to the reflection after flipping about the |
| 24 // x- or y-axis, according to the direction |
| 25 // * a mask image, which will be applied to the reflection before the |
| 26 // reflection matrix is applied |
| 27 class PLATFORM_EXPORT BoxReflection { |
| 28 public: |
| 29 enum ReflectionDirection { |
| 30 // Vertically flipped (to appear above or below). |
| 31 VerticalReflection, |
| 32 // Horizontally flipped (to appear to the left or right). |
| 33 HorizontalReflection, |
| 34 }; |
| 35 |
| 36 BoxReflection(ReflectionDirection direction, float offset, PassRefPtr<SkPict
ure> mask = nullptr) |
| 37 : m_direction(direction), m_offset(offset), m_mask(mask) {} |
| 38 |
| 39 ReflectionDirection direction() const { return m_direction; } |
| 40 float offset() const { return m_offset; } |
| 41 SkPicture* mask() const { return m_mask.get(); } |
| 42 |
| 43 // Returns a matrix which maps points between the original content and its |
| 44 // reflection. Reflections are self-inverse, so this matrix can be used to |
| 45 // map in either direction. |
| 46 SkMatrix reflectionMatrix() const; |
| 47 |
| 48 // Maps a source rectangle to the destination rectangle it can affect, |
| 49 // including this reflection. Due to the symmetry of reflections, this can |
| 50 // also be used to map from a destination rectangle to the source rectangle |
| 51 // which contributes to it. |
| 52 FloatRect mapRect(const FloatRect&) const; |
| 53 |
| 54 private: |
| 55 ReflectionDirection m_direction; |
| 56 float m_offset; |
| 57 RefPtr<SkPicture> m_mask; |
| 58 }; |
| 59 |
| 60 inline bool operator==(const BoxReflection& a, const BoxReflection& b) |
| 61 { |
| 62 return a.direction() == b.direction() |
| 63 && a.offset() == b.offset() |
| 64 && a.mask() == b.mask(); |
| 65 } |
| 66 |
| 67 inline bool operator!=(const BoxReflection& a, const BoxReflection& b) |
| 68 { |
| 69 return !(a == b); |
| 70 } |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 #endif // BoxReflection_h |
| OLD | NEW |