OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRectShaderImageFilter_DEFINED | 8 #ifndef SkRectShaderImageFilter_DEFINED |
9 #define SkRectShaderImageFilter_DEFINED | 9 #define SkRectShaderImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 | 13 |
14 class SkShader; | 14 class SkShader; |
15 | 15 |
16 class SK_API SkRectShaderImageFilter : public SkImageFilter { | 16 class SK_API SkRectShaderImageFilter : public SkImageFilter { |
17 public: | 17 public: |
18 /** Create a new image filter which fills the given rectangle with pixels | 18 /** Create a new image filter which fills the given rectangle with pixels |
19 * produced by the given SkShader. If no rectangle is specified, an output | 19 * produced by the given SkShader. If no rectangle is specified, an output |
20 * is produced with the same bounds as the input primitive (even though | 20 * is produced with the same bounds as the input primitive (even though |
21 * the input primitive's pixels are not used for processing). | 21 * the input primitive's pixels are not used for processing). |
22 * @param s Shader to call for processing. Cannot be NULL. Will be | 22 * @param s Shader to call for processing. Cannot be NULL. Will be |
23 * ref'ed by the new image filter. | 23 * ref'ed by the new image filter. |
24 * @param rect Rectangle of output pixels in which to apply the shader. | 24 * @param rect Rectangle of output pixels in which to apply the shader. |
25 * If NULL or a given crop edge is not specified, the source | 25 * If NULL or a given crop edge is not specified, the source |
26 * primitive's bounds are used instead. | 26 * primitive's bounds are used instead. |
27 */ | 27 */ |
28 SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)") | 28 SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)") |
29 static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect); | 29 static SkImageFilter* Create(SkShader* s, const SkRect& rect); |
| 30 static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL); |
30 | 31 |
31 static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = N
ULL); | |
32 virtual ~SkRectShaderImageFilter(); | |
33 bool affectsTransparentBlack() const override; | 32 bool affectsTransparentBlack() const override; |
34 | 33 |
35 SK_TO_STRING_OVERRIDE() | 34 SK_TO_STRING_OVERRIDE() |
36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) | 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) |
37 | 36 |
38 protected: | 37 protected: |
| 38 virtual ~SkRectShaderImageFilter(); |
| 39 |
39 void flatten(SkWriteBuffer&) const override; | 40 void flatten(SkWriteBuffer&) const override; |
40 | 41 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* re
sult, |
41 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 42 SkIPoint* loc) const override; |
42 SkBitmap* result, SkIPoint* loc) const override; | |
43 | 43 |
44 private: | 44 private: |
45 SkRectShaderImageFilter(SkShader* s, const CropRect* rect); | 45 SkRectShaderImageFilter(SkShader* s, const CropRect* rect); |
| 46 |
46 SkShader* fShader; | 47 SkShader* fShader; |
47 | 48 |
48 typedef SkImageFilter INHERITED; | 49 typedef SkImageFilter INHERITED; |
49 }; | 50 }; |
50 | 51 |
51 #endif | 52 #endif |
OLD | NEW |