OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
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 #ifndef SkPictureShader_DEFINED | 9 #ifndef SkPictureShader_DEFINED |
10 #define SkPictureShader_DEFINED | 10 #define SkPictureShader_DEFINED |
11 | 11 |
12 #include "SkShader.h" | 12 #include "SkShader.h" |
13 | 13 |
14 class SkBitmap; | 14 class SkBitmap; |
15 class SkPicture; | 15 class SkPicture; |
16 | 16 |
17 /* | 17 /* |
18 * An SkPictureShader can be used to draw SkPicture-based patterns. | 18 * An SkPictureShader can be used to draw SkPicture-based patterns. |
19 * | 19 * |
20 * The SkPicture is first rendered into a tile, which is then used to shade the
area according | 20 * The SkPicture is first rendered into a tile, which is then used to shade the
area according |
21 * to specified tiling rules. | 21 * to specified tiling rules. |
22 */ | 22 */ |
23 class SkPictureShader : public SkShader { | 23 class SkPictureShader : public SkShader { |
24 public: | 24 public: |
25 static sk_sp<SkShader> Make(sk_sp<const SkPicture>, TileMode, TileMode, cons
t SkMatrix*, | 25 static sk_sp<SkShader> Make(sk_sp<SkPicture>, TileMode, TileMode, const SkMa
trix*, |
26 const SkRect*); | 26 const SkRect*); |
27 | 27 |
28 SK_TO_STRING_OVERRIDE() | 28 SK_TO_STRING_OVERRIDE() |
29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) | 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) |
30 | 30 |
31 #if SK_SUPPORT_GPU | 31 #if SK_SUPPORT_GPU |
32 const GrFragmentProcessor* asFragmentProcessor(GrContext*, | 32 const GrFragmentProcessor* asFragmentProcessor(GrContext*, |
33 const SkMatrix& viewM, | 33 const SkMatrix& viewM, |
34 const SkMatrix*, | 34 const SkMatrix*, |
35 SkFilterQuality) const overri
de; | 35 SkFilterQuality) const overri
de; |
36 #endif | 36 #endif |
37 | 37 |
38 protected: | 38 protected: |
39 SkPictureShader(SkReadBuffer&); | 39 SkPictureShader(SkReadBuffer&); |
40 void flatten(SkWriteBuffer&) const override; | 40 void flatten(SkWriteBuffer&) const override; |
41 size_t onContextSize(const ContextRec&) const override; | 41 size_t onContextSize(const ContextRec&) const override; |
42 Context* onCreateContext(const ContextRec&, void* storage) const override; | 42 Context* onCreateContext(const ContextRec&, void* storage) const override; |
43 | 43 |
44 private: | 44 private: |
45 SkPictureShader(sk_sp<const SkPicture>, TileMode, TileMode, const SkMatrix*,
const SkRect*); | 45 SkPictureShader(sk_sp<SkPicture>, TileMode, TileMode, const SkMatrix*, const
SkRect*); |
46 | 46 |
47 sk_sp<SkShader> refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix
, | 47 sk_sp<SkShader> refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix
, |
48 const int maxTextureSize = 0) const; | 48 const int maxTextureSize = 0) const; |
49 | 49 |
50 sk_sp<const SkPicture> fPicture; | 50 sk_sp<SkPicture> fPicture; |
51 SkRect fTile; | 51 SkRect fTile; |
52 TileMode fTmx, fTmy; | 52 TileMode fTmx, fTmy; |
53 | 53 |
54 class PictureShaderContext : public SkShader::Context { | 54 class PictureShaderContext : public SkShader::Context { |
55 public: | 55 public: |
56 static Context* Create(void* storage, const SkPictureShader&, const Cont
extRec&, | 56 static Context* Create(void* storage, const SkPictureShader&, const Cont
extRec&, |
57 sk_sp<SkShader> bitmapShader); | 57 sk_sp<SkShader> bitmapShader); |
58 | 58 |
59 virtual ~PictureShaderContext(); | 59 virtual ~PictureShaderContext(); |
60 | 60 |
61 uint32_t getFlags() const override; | 61 uint32_t getFlags() const override; |
62 | 62 |
63 ShadeProc asAShadeProc(void** ctx) override; | 63 ShadeProc asAShadeProc(void** ctx) override; |
64 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; | 64 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; |
65 | 65 |
66 private: | 66 private: |
67 PictureShaderContext(const SkPictureShader&, const ContextRec&, | 67 PictureShaderContext(const SkPictureShader&, const ContextRec&, |
68 sk_sp<SkShader> bitmapShader); | 68 sk_sp<SkShader> bitmapShader); |
69 | 69 |
70 sk_sp<SkShader> fBitmapShader; | 70 sk_sp<SkShader> fBitmapShader; |
71 SkShader::Context* fBitmapShaderContext; | 71 SkShader::Context* fBitmapShaderContext; |
72 void* fBitmapShaderContextStorage; | 72 void* fBitmapShaderContextStorage; |
73 | 73 |
74 typedef SkShader::Context INHERITED; | 74 typedef SkShader::Context INHERITED; |
75 }; | 75 }; |
76 | 76 |
77 typedef SkShader INHERITED; | 77 typedef SkShader INHERITED; |
78 }; | 78 }; |
79 | 79 |
80 #endif // SkPictureShader_DEFINED | 80 #endif // SkPictureShader_DEFINED |
OLD | NEW |