Chromium Code Reviews| 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 "wtf/PassRefPtr.h" | |
| 10 | |
| 11 class SkImageFilter; | |
| 12 class SkMatrix; | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class FloatRect; | |
| 17 | |
| 18 // A reflection, as created by -webkit-box-reflect. Consists of: | |
| 19 // * a direction (either vertical or horizontal) | |
| 20 // * an offset to be applied to the reflection after flipping about the | |
| 21 // x- or y-axis, according to the direction | |
| 22 class PLATFORM_EXPORT BoxReflection { | |
|
Stephen White
2016/04/13 15:35:51
<bikeshed> Could this be BoxReflectParams (my pref
jbroman
2016/04/13 17:59:15
It could. I'd be OK with BoxReflectParams, though
Stephen White
2016/04/13 18:07:35
OK, I buy that comparison.
| |
| 23 public: | |
| 24 enum ReflectionDirection { | |
| 25 // Vertically flipped (to appear above or below). | |
| 26 VerticalReflection, | |
| 27 // Horizontally flipped (to appear to the left or right). | |
| 28 HorizontalReflection, | |
| 29 }; | |
| 30 | |
| 31 BoxReflection(ReflectionDirection direction, float offset) | |
| 32 : m_direction(direction), m_offset(offset) {} | |
| 33 | |
| 34 ReflectionDirection direction() const { return m_direction; } | |
| 35 float offset() const { return m_offset; } | |
| 36 | |
| 37 // Returns a matrix which maps points between the original content and its | |
| 38 // reflection. Reflections are self-inverse, so this matrix can be used to | |
| 39 // map in either direction. | |
| 40 SkMatrix reflectionMatrix() const; | |
| 41 | |
| 42 // Maps a source rectangle to the destination rectangle it can affect, | |
| 43 // including this reflection. Due to the symmetry of reflections, this can | |
| 44 // also be used to map from a destination rectangle to the source rectangle | |
| 45 // which contributes to it. | |
| 46 FloatRect mapRect(const FloatRect&) const; | |
| 47 | |
| 48 // Creates a Skia image filter which reflects content according to the | |
| 49 // parameters of this reflection. | |
| 50 PassRefPtr<SkImageFilter> createImageFilter(PassRefPtr<SkImageFilter> input) const; | |
|
Stephen White
2016/04/13 15:35:51
For dependencies and symmetry, could we keep the c
jbroman
2016/04/13 17:59:15
I don't know what you mean by "for dependencies";
Stephen White
2016/04/13 18:07:35
True, but everything SkImageFilter-related lives i
jbroman
2016/04/13 22:24:52
Done.
| |
| 51 | |
| 52 private: | |
| 53 ReflectionDirection m_direction; | |
| 54 float m_offset; | |
| 55 }; | |
| 56 | |
| 57 inline bool operator==(const BoxReflection& a, const BoxReflection& b) | |
| 58 { | |
| 59 return a.direction() == b.direction() && a.offset() == b.offset(); | |
| 60 } | |
| 61 | |
| 62 inline bool operator!=(const BoxReflection& a, const BoxReflection& b) | |
| 63 { | |
| 64 return !(a == b); | |
| 65 } | |
| 66 | |
| 67 } // namespace blink | |
| 68 | |
| 69 #endif // BoxReflection_h | |
| OLD | NEW |