Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/BoxReflection.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/BoxReflection.h b/third_party/WebKit/Source/platform/graphics/BoxReflection.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b3d33b38b55c86ef8d3358f4e469a3089e63cf73 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/BoxReflection.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BoxReflection_h |
| +#define BoxReflection_h |
| + |
| +#include "platform/PlatformExport.h" |
| +#include "wtf/PassRefPtr.h" |
| + |
| +class SkImageFilter; |
| +class SkMatrix; |
| + |
| +namespace blink { |
| + |
| +class FloatRect; |
| + |
| +// A reflection, as created by -webkit-box-reflect. Consists of: |
| +// * a direction (either vertical or horizontal) |
| +// * an offset to be applied to the reflection after flipping about the |
| +// x- or y-axis, according to the direction |
| +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.
|
| +public: |
| + enum ReflectionDirection { |
| + // Vertically flipped (to appear above or below). |
| + VerticalReflection, |
| + // Horizontally flipped (to appear to the left or right). |
| + HorizontalReflection, |
| + }; |
| + |
| + BoxReflection(ReflectionDirection direction, float offset) |
| + : m_direction(direction), m_offset(offset) {} |
| + |
| + ReflectionDirection direction() const { return m_direction; } |
| + float offset() const { return m_offset; } |
| + |
| + // Returns a matrix which maps points between the original content and its |
| + // reflection. Reflections are self-inverse, so this matrix can be used to |
| + // map in either direction. |
| + SkMatrix reflectionMatrix() const; |
| + |
| + // Maps a source rectangle to the destination rectangle it can affect, |
| + // including this reflection. Due to the symmetry of reflections, this can |
| + // also be used to map from a destination rectangle to the source rectangle |
| + // which contributes to it. |
| + FloatRect mapRect(const FloatRect&) const; |
| + |
| + // Creates a Skia image filter which reflects content according to the |
| + // parameters of this reflection. |
| + 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.
|
| + |
| +private: |
| + ReflectionDirection m_direction; |
| + float m_offset; |
| +}; |
| + |
| +inline bool operator==(const BoxReflection& a, const BoxReflection& b) |
| +{ |
| + return a.direction() == b.direction() && a.offset() == b.offset(); |
| +} |
| + |
| +inline bool operator!=(const BoxReflection& a, const BoxReflection& b) |
| +{ |
| + return !(a == b); |
| +} |
| + |
| +} // namespace blink |
| + |
| +#endif // BoxReflection_h |