Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/BoxReflection.h

Issue 2889653002: Remove cullRect() from PaintOpBuffer. (Closed)
Patch Set: movecullrect2 rebase-once-and-for-all Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 BoxReflection_h 5 #ifndef BoxReflection_h
6 #define BoxReflection_h 6 #define BoxReflection_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/geometry/FloatRect.h"
9 #include "platform/graphics/paint/PaintRecord.h" 10 #include "platform/graphics/paint/PaintRecord.h"
10 #include "third_party/skia/include/core/SkRefCnt.h" 11 #include "third_party/skia/include/core/SkRefCnt.h"
11 12
12 class SkMatrix; 13 class SkMatrix;
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class FloatRect;
17
18 // A reflection, as created by -webkit-box-reflect. Consists of: 17 // A reflection, as created by -webkit-box-reflect. Consists of:
19 // * a direction (either vertical or horizontal) 18 // * a direction (either vertical or horizontal)
20 // * an offset to be applied to the reflection after flipping about the 19 // * an offset to be applied to the reflection after flipping about the
21 // x- or y-axis, according to the direction 20 // x- or y-axis, according to the direction
22 // * a mask image, which will be applied to the reflection before the 21 // * a mask image, which will be applied to the reflection before the
23 // reflection matrix is applied 22 // reflection matrix is applied
24 class PLATFORM_EXPORT BoxReflection { 23 class PLATFORM_EXPORT BoxReflection {
25 public: 24 public:
26 enum ReflectionDirection { 25 enum ReflectionDirection {
27 // Vertically flipped (to appear above or below). 26 // Vertically flipped (to appear above or below).
28 kVerticalReflection, 27 kVerticalReflection,
29 // Horizontally flipped (to appear to the left or right). 28 // Horizontally flipped (to appear to the left or right).
30 kHorizontalReflection, 29 kHorizontalReflection,
31 }; 30 };
32 31
32 BoxReflection(ReflectionDirection direction, float offset)
33 : BoxReflection(direction, offset, nullptr, FloatRect()) {}
34
33 BoxReflection(ReflectionDirection direction, 35 BoxReflection(ReflectionDirection direction,
34 float offset, 36 float offset,
35 sk_sp<PaintRecord> mask = nullptr) 37 sk_sp<PaintRecord> mask,
36 : direction_(direction), offset_(offset), mask_(std::move(mask)) {} 38 const FloatRect& mask_bounds)
39 : direction_(direction),
40 offset_(offset),
41 mask_(std::move(mask)),
42 mask_bounds_(mask_bounds) {}
37 43
38 ReflectionDirection Direction() const { return direction_; } 44 ReflectionDirection Direction() const { return direction_; }
39 float Offset() const { return offset_; } 45 float Offset() const { return offset_; }
40 const sk_sp<PaintRecord>& Mask() const { return mask_; } 46 const sk_sp<PaintRecord>& Mask() const { return mask_; }
47 const FloatRect& MaskBounds() const { return mask_bounds_; }
41 48
42 // Returns a matrix which maps points between the original content and its 49 // Returns a matrix which maps points between the original content and its
43 // reflection. Reflections are self-inverse, so this matrix can be used to 50 // reflection. Reflections are self-inverse, so this matrix can be used to
44 // map in either direction. 51 // map in either direction.
45 SkMatrix ReflectionMatrix() const; 52 SkMatrix ReflectionMatrix() const;
46 53
47 // Maps a source rectangle to the destination rectangle it can affect, 54 // Maps a source rectangle to the destination rectangle it can affect,
48 // including this reflection. Due to the symmetry of reflections, this can 55 // including this reflection. Due to the symmetry of reflections, this can
49 // also be used to map from a destination rectangle to the source rectangle 56 // also be used to map from a destination rectangle to the source rectangle
50 // which contributes to it. 57 // which contributes to it.
51 FloatRect MapRect(const FloatRect&) const; 58 FloatRect MapRect(const FloatRect&) const;
52 59
53 private: 60 private:
54 ReflectionDirection direction_; 61 ReflectionDirection direction_;
55 float offset_; 62 float offset_;
56 sk_sp<PaintRecord> mask_; 63 sk_sp<PaintRecord> mask_;
64 FloatRect mask_bounds_;
57 }; 65 };
58 66
59 inline bool operator==(const BoxReflection& a, const BoxReflection& b) { 67 inline bool operator==(const BoxReflection& a, const BoxReflection& b) {
60 return a.Direction() == b.Direction() && a.Offset() == b.Offset() && 68 return a.Direction() == b.Direction() && a.Offset() == b.Offset() &&
61 a.Mask() == b.Mask(); 69 a.Mask() == b.Mask() && a.MaskBounds() == b.MaskBounds();
62 } 70 }
63 71
64 inline bool operator!=(const BoxReflection& a, const BoxReflection& b) { 72 inline bool operator!=(const BoxReflection& a, const BoxReflection& b) {
65 return !(a == b); 73 return !(a == b);
66 } 74 }
67 75
68 } // namespace blink 76 } // namespace blink
69 77
70 #endif // BoxReflection_h 78 #endif // BoxReflection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698