| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 SkPictureShader_DEFINED | 8 #ifndef SkPictureShader_DEFINED |
| 9 #define SkPictureShader_DEFINED | 9 #define SkPictureShader_DEFINED |
| 10 | 10 |
| 11 #include "SkShader.h" | 11 #include "SkShader.h" |
| 12 | 12 |
| 13 class SkBitmap; | 13 class SkBitmap; |
| 14 class SkPicture; | 14 class SkPicture; |
| 15 | 15 |
| 16 /* | 16 /* |
| 17 * An SkPictureShader can be used to draw SkPicture-based patterns. | 17 * An SkPictureShader can be used to draw SkPicture-based patterns. |
| 18 * | 18 * |
| 19 * The SkPicture is first rendered into a tile, which is then used to shade the
area according | 19 * The SkPicture is first rendered into a tile, which is then used to shade the
area according |
| 20 * to specified tiling rules. | 20 * to specified tiling rules. |
| 21 */ | 21 */ |
| 22 class SkPictureShader : public SkShader { | 22 class SkPictureShader : public SkShader { |
| 23 public: | 23 public: |
| 24 static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatri
x* = NULL); | 24 static SkPictureShader* Create(const SkPicture*, TileMode, TileMode, const S
kMatrix* = NULL); |
| 25 virtual ~SkPictureShader(); | 25 virtual ~SkPictureShader(); |
| 26 | 26 |
| 27 virtual size_t contextSize() const SK_OVERRIDE; | 27 virtual size_t contextSize() const SK_OVERRIDE; |
| 28 | 28 |
| 29 SK_TO_STRING_OVERRIDE() | 29 SK_TO_STRING_OVERRIDE() |
| 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) | 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) |
| 31 | 31 |
| 32 bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEf
fect**) | 32 bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEf
fect**) |
| 33 const SK_OVERRIDE; | 33 const SK_OVERRIDE; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 SkPictureShader(SkReadBuffer&); | 36 SkPictureShader(SkReadBuffer&); |
| 37 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 37 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 38 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; | 38 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL); | 41 SkPictureShader(const SkPicture*, TileMode, TileMode, const SkMatrix* = NULL
); |
| 42 | 42 |
| 43 SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix) cons
t; | 43 SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix) cons
t; |
| 44 | 44 |
| 45 SkPicture* fPicture; | 45 const SkPicture* fPicture; |
| 46 TileMode fTmx, fTmy; | 46 TileMode fTmx, fTmy; |
| 47 | 47 |
| 48 mutable SkMutex fCachedBitmapShaderMutex; | 48 mutable SkMutex fCachedBitmapShaderMutex; |
| 49 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; | 49 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; |
| 50 mutable SkSize fCachedTileScale; | 50 mutable SkSize fCachedTileScale; |
| 51 | 51 |
| 52 class PictureShaderContext : public SkShader::Context { | 52 class PictureShaderContext : public SkShader::Context { |
| 53 public: | 53 public: |
| 54 static Context* Create(void* storage, const SkPictureShader&, const Cont
extRec&, | 54 static Context* Create(void* storage, const SkPictureShader&, const Cont
extRec&, |
| 55 SkShader* bitmapShader); | 55 SkShader* bitmapShader); |
| 56 | 56 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 SkShader::Context* fBitmapShaderContext; | 69 SkShader::Context* fBitmapShaderContext; |
| 70 void* fBitmapShaderContextStorage; | 70 void* fBitmapShaderContextStorage; |
| 71 | 71 |
| 72 typedef SkShader::Context INHERITED; | 72 typedef SkShader::Context INHERITED; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 typedef SkShader INHERITED; | 75 typedef SkShader INHERITED; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // SkPictureShader_DEFINED | 78 #endif // SkPictureShader_DEFINED |
| OLD | NEW |