| 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); | 24 static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatri
x* = NULL); |
| 25 virtual ~SkPictureShader(); | 25 virtual ~SkPictureShader(); |
| 26 | 26 |
| 27 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const S
K_OVERRIDE; | 27 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const S
K_OVERRIDE; |
| 28 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c
onst SK_OVERRIDE; | 28 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c
onst SK_OVERRIDE; |
| 29 virtual size_t contextSize() const SK_OVERRIDE; | 29 virtual size_t contextSize() const SK_OVERRIDE; |
| 30 | 30 |
| 31 class PictureShaderContext : public SkShader::Context { | 31 class PictureShaderContext : public SkShader::Context { |
| 32 public: | 32 public: |
| 33 PictureShaderContext(const SkPictureShader&, const ContextRec&, SkShader
* bitmapShader); | 33 PictureShaderContext(const SkPictureShader&, const ContextRec&, SkShader
* bitmapShader); |
| 34 virtual ~PictureShaderContext(); | 34 virtual ~PictureShaderContext(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 #if SK_SUPPORT_GPU | 53 #if SK_SUPPORT_GPU |
| 54 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; | 54 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 SkPictureShader(SkReadBuffer&); | 58 SkPictureShader(SkReadBuffer&); |
| 59 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 59 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 SkPictureShader(SkPicture*, TileMode, TileMode); | 62 SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL); |
| 63 | 63 |
| 64 SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const; | 64 SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const; |
| 65 SkShader* refBitmapShader(const SkMatrix&) const; | 65 SkShader* refBitmapShader(const SkMatrix&) const; |
| 66 | 66 |
| 67 SkPicture* fPicture; | 67 SkPicture* fPicture; |
| 68 TileMode fTmx, fTmy; | 68 TileMode fTmx, fTmy; |
| 69 | 69 |
| 70 mutable SkMutex fCachedBitmapShaderMutex; | 70 mutable SkMutex fCachedBitmapShaderMutex; |
| 71 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; | 71 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; |
| 72 mutable SkSize fCachedTileScale; | 72 mutable SkSize fCachedTileScale; |
| 73 mutable SkMatrix fCachedLocalMatrix; | 73 mutable SkMatrix fCachedLocalMatrix; |
| 74 | 74 |
| 75 typedef SkShader INHERITED; | 75 typedef SkShader INHERITED; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // SkPictureShader_DEFINED | 78 #endif // SkPictureShader_DEFINED |
| OLD | NEW |