Chromium Code Reviews| 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); |
| 25 virtual ~SkPictureShader(); | 25 virtual ~SkPictureShader(); |
| 26 | 26 |
| 27 virtual bool validContext(const SkBitmap&, const SkPaint&, | 27 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE; |
|
scroggo
2014/05/01 18:49:38
Do you want to remove this default param?
reed1
2014/05/01 18:57:41
Done.
| |
| 28 const SkMatrix&, SkMatrix* totalInverse = NULL) co nst SK_OVERRIDE; | 28 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c onst SK_OVERRIDE; |
| 29 virtual SkShader::Context* createContext(const SkBitmap& device, const SkPai nt& paint, | |
| 30 const SkMatrix& matrix, void* stora ge) const | |
| 31 SK_OVERRIDE; | |
| 32 virtual size_t contextSize() const SK_OVERRIDE; | 29 virtual size_t contextSize() const SK_OVERRIDE; |
| 33 | 30 |
| 34 class PictureShaderContext : public SkShader::Context { | 31 class PictureShaderContext : public SkShader::Context { |
| 35 public: | 32 public: |
| 36 PictureShaderContext(const SkPictureShader& shader, const SkBitmap& devi ce, | 33 PictureShaderContext(const SkPictureShader&, const ContextRec&, SkShader * bitmapShader); |
| 37 const SkPaint& paint, const SkMatrix& matrix, | |
| 38 SkShader* bitmapShader); | |
| 39 virtual ~PictureShaderContext(); | 34 virtual ~PictureShaderContext(); |
| 40 | 35 |
| 41 virtual uint32_t getFlags() const SK_OVERRIDE; | 36 virtual uint32_t getFlags() const SK_OVERRIDE; |
| 42 | 37 |
| 43 virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; | 38 virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; |
| 44 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE; | 39 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE RRIDE; |
| 45 virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OV ERRIDE; | 40 virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OV ERRIDE; |
| 46 | 41 |
| 47 private: | 42 private: |
| 48 SkAutoTUnref<SkShader> fBitmapShader; | 43 SkAutoTUnref<SkShader> fBitmapShader; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 59 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; | 54 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
| 60 #endif | 55 #endif |
| 61 | 56 |
| 62 protected: | 57 protected: |
| 63 SkPictureShader(SkReadBuffer&); | 58 SkPictureShader(SkReadBuffer&); |
| 64 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 59 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 65 | 60 |
| 66 private: | 61 private: |
| 67 SkPictureShader(SkPicture*, TileMode, TileMode); | 62 SkPictureShader(SkPicture*, TileMode, TileMode); |
| 68 | 63 |
| 69 SkShader* validInternal(const SkBitmap& device, const SkPaint& paint, | 64 SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const; |
| 70 const SkMatrix& matrix, SkMatrix* totalInverse) cons t; | |
| 71 | |
| 72 SkShader* refBitmapShader(const SkMatrix&) const; | 65 SkShader* refBitmapShader(const SkMatrix&) const; |
| 73 | 66 |
| 74 SkPicture* fPicture; | 67 SkPicture* fPicture; |
| 75 TileMode fTmx, fTmy; | 68 TileMode fTmx, fTmy; |
| 76 | 69 |
| 77 mutable SkMutex fCachedBitmapShaderMutex; | 70 mutable SkMutex fCachedBitmapShaderMutex; |
| 78 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; | 71 mutable SkAutoTUnref<SkShader> fCachedBitmapShader; |
| 79 mutable SkSize fCachedTileScale; | 72 mutable SkSize fCachedTileScale; |
| 80 mutable SkMatrix fCachedLocalMatrix; | 73 mutable SkMatrix fCachedLocalMatrix; |
| 81 | 74 |
| 82 typedef SkShader INHERITED; | 75 typedef SkShader INHERITED; |
| 83 }; | 76 }; |
| 84 | 77 |
| 85 #endif // SkPictureShader_DEFINED | 78 #endif // SkPictureShader_DEFINED |
| OLD | NEW |