Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: src/core/SkPictureShader.h

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SkShader* Create(const SkPicture*, TileMode, TileMode, const SkMatrix *, 25 static sk_sp<SkShader> Make(const 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(const SkPicture*, TileMode, TileMode, const SkMatrix*, const SkRect*); 45 SkPictureShader(const SkPicture*, TileMode, TileMode, const SkMatrix*, const SkRect*);
46 46
47 SkShader* refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix, cons t int maxTextureSize = 0) const; 47 sk_sp<SkShader> refBitmapShader(const SkMatrix&, const SkMatrix* localMatrix ,
48 const int maxTextureSize = 0) const;
48 49
49 SkAutoTUnref<const SkPicture> fPicture; 50 SkAutoTUnref<const SkPicture> fPicture;
50 SkRect fTile; 51 SkRect fTile;
51 TileMode fTmx, fTmy; 52 TileMode fTmx, fTmy;
52 53
53 class PictureShaderContext : public SkShader::Context { 54 class PictureShaderContext : public SkShader::Context {
54 public: 55 public:
55 static Context* Create(void* storage, const SkPictureShader&, const Cont extRec&, 56 static Context* Create(void* storage, const SkPictureShader&, const Cont extRec&,
56 SkShader* bitmapShader); 57 sk_sp<SkShader> bitmapShader);
57 58
58 virtual ~PictureShaderContext(); 59 virtual ~PictureShaderContext();
59 60
60 uint32_t getFlags() const override; 61 uint32_t getFlags() const override;
61 62
62 ShadeProc asAShadeProc(void** ctx) override; 63 ShadeProc asAShadeProc(void** ctx) override;
63 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; 64 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
64 65
65 private: 66 private:
66 PictureShaderContext(const SkPictureShader&, const ContextRec&, SkShader * bitmapShader); 67 PictureShaderContext(const SkPictureShader&, const ContextRec&,
68 sk_sp<SkShader> bitmapShader);
67 69
68 SkAutoTUnref<SkShader> fBitmapShader; 70 sk_sp<SkShader> fBitmapShader;
69 SkShader::Context* fBitmapShaderContext; 71 SkShader::Context* fBitmapShaderContext;
70 void* fBitmapShaderContextStorage; 72 void* fBitmapShaderContextStorage;
71 73
72 typedef SkShader::Context INHERITED; 74 typedef SkShader::Context INHERITED;
73 }; 75 };
74 76
75 typedef SkShader INHERITED; 77 typedef SkShader INHERITED;
76 }; 78 };
77 79
78 #endif // SkPictureShader_DEFINED 80 #endif // SkPictureShader_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698