OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 The Android Open Source Project | 3 * Copyright 2011 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkDrawLooper_DEFINED | 10 #ifndef SkDrawLooper_DEFINED |
11 #define SkDrawLooper_DEFINED | 11 #define SkDrawLooper_DEFINED |
12 | 12 |
| 13 #include "SkBlurTypes.h" |
13 #include "SkFlattenable.h" | 14 #include "SkFlattenable.h" |
| 15 #include "SkPoint.h" |
| 16 #include "SkColor.h" |
14 | 17 |
15 class SkCanvas; | 18 class SkCanvas; |
16 class SkPaint; | 19 class SkPaint; |
17 struct SkRect; | 20 struct SkRect; |
18 class SkString; | 21 class SkString; |
19 | 22 |
20 /** \class SkDrawLooper | 23 /** \class SkDrawLooper |
21 Subclasses of SkDrawLooper can be attached to a SkPaint. Where they are, | 24 Subclasses of SkDrawLooper can be attached to a SkPaint. Where they are, |
22 and something is drawn to a canvas with that paint, the looper subclass will | 25 and something is drawn to a canvas with that paint, the looper subclass will |
23 be called, allowing it to modify the canvas and/or paint for that draw call. | 26 be called, allowing it to modify the canvas and/or paint for that draw call. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 * returns false then computeFastBounds behavior is undefined otherwise it | 84 * returns false then computeFastBounds behavior is undefined otherwise it |
82 * is expected to have the following behavior. Given the parent paint and | 85 * is expected to have the following behavior. Given the parent paint and |
83 * the parent's bounding rect the subclass must fill in and return the | 86 * the parent's bounding rect the subclass must fill in and return the |
84 * storage rect, where the storage rect is with the union of the src rect | 87 * storage rect, where the storage rect is with the union of the src rect |
85 * and the looper's bounding rect. | 88 * and the looper's bounding rect. |
86 */ | 89 */ |
87 virtual bool canComputeFastBounds(const SkPaint& paint) const; | 90 virtual bool canComputeFastBounds(const SkPaint& paint) const; |
88 virtual void computeFastBounds(const SkPaint& paint, | 91 virtual void computeFastBounds(const SkPaint& paint, |
89 const SkRect& src, SkRect* dst) const; | 92 const SkRect& src, SkRect* dst) const; |
90 | 93 |
| 94 struct BlurShadowRec { |
| 95 SkScalar fSigma; |
| 96 SkVector fOffset; |
| 97 SkColor fColor; |
| 98 SkBlurStyle fStyle; |
| 99 SkBlurQuality fQuality; |
| 100 }; |
| 101 /** |
| 102 * If this looper can be interpreted as having two layers, such that |
| 103 * 1. The first layer (bottom most) just has a blur and translate |
| 104 * 2. The second layer has no modifications to either paint or canvas |
| 105 * 3. No other layers. |
| 106 * then return true, and if not null, fill out the BlurShadowRec). |
| 107 * |
| 108 * If any of the above are not met, return false and ignore the BlurShadowR
ec parameter. |
| 109 */ |
| 110 virtual bool asABlurShadow(BlurShadowRec*) const; |
| 111 |
91 SK_TO_STRING_PUREVIRT() | 112 SK_TO_STRING_PUREVIRT() |
92 SK_DEFINE_FLATTENABLE_TYPE(SkDrawLooper) | 113 SK_DEFINE_FLATTENABLE_TYPE(SkDrawLooper) |
93 | 114 |
94 protected: | 115 protected: |
95 SkDrawLooper() {} | 116 SkDrawLooper() {} |
96 SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {} | 117 SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {} |
97 | 118 |
98 private: | 119 private: |
99 typedef SkFlattenable INHERITED; | 120 typedef SkFlattenable INHERITED; |
100 }; | 121 }; |
101 | 122 |
102 #endif | 123 #endif |
OLD | NEW |