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

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

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

Powered by Google App Engine
This is Rietveld 408576698