commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkPictureShader_DEFINED |
| 9 | #define SkPictureShader_DEFINED |
| 10 | |
| 11 | #include "SkShader.h" |
| 12 | |
| 13 | class SkBitmap; |
| 14 | class SkPicture; |
| 15 | |
| 16 | /* |
| 17 | * An SkPictureShader can be used to draw SkPicture-based patterns. |
| 18 | * |
| 19 | * The SkPicture is first rendered into a tile, which is then used to shade the area according |
| 20 | * to specified tiling rules. |
| 21 | */ |
| 22 | class SkPictureShader : public SkShader { |
| 23 | public: |
| 24 | static SkPictureShader* Create(SkPicture*, TileMode, TileMode); |
| 25 | virtual ~SkPictureShader(); |
| 26 | |
commit-bot@chromium.org | 6e5671d | 2014-04-23 16:16:55 +0000 | [diff] [blame^] | 27 | virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE; |
| 28 | virtual void endContext() SK_OVERRIDE; |
| 29 | virtual uint32_t getFlags() SK_OVERRIDE; |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 30 | |
commit-bot@chromium.org | 6e5671d | 2014-04-23 16:16:55 +0000 | [diff] [blame^] | 31 | virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; |
| 32 | virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; |
| 33 | virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE; |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 34 | |
| 35 | SK_TO_STRING_OVERRIDE() |
| 36 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader) |
| 37 | |
| 38 | #if SK_SUPPORT_GPU |
| 39 | GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
| 40 | #endif |
| 41 | |
| 42 | protected: |
| 43 | SkPictureShader(SkReadBuffer&); |
| 44 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 45 | |
| 46 | private: |
| 47 | SkPictureShader(SkPicture*, TileMode, TileMode); |
| 48 | |
commit-bot@chromium.org | 6e5671d | 2014-04-23 16:16:55 +0000 | [diff] [blame^] | 49 | bool buildBitmapShader(const SkMatrix&) const; |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 50 | |
| 51 | SkPicture* fPicture; |
| 52 | TileMode fTmx, fTmy; |
| 53 | |
commit-bot@chromium.org | 6e5671d | 2014-04-23 16:16:55 +0000 | [diff] [blame^] | 54 | mutable SkAutoTUnref<SkShader> fCachedShader; |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 55 | mutable SkSize fCachedTileScale; |
commit-bot@chromium.org | c5d9bb0 | 2014-04-08 15:19:34 +0000 | [diff] [blame] | 56 | |
| 57 | typedef SkShader INHERITED; |
| 58 | }; |
| 59 | |
| 60 | #endif // SkPictureShader_DEFINED |