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

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

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 6 years, 8 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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkCoreBlitters_DEFINED 8 #ifndef SkCoreBlitters_DEFINED
9 #define SkCoreBlitters_DEFINED 9 #define SkCoreBlitters_DEFINED
10 10
11 #include "SkBitmapProcShader.h" 11 #include "SkBitmapProcShader.h"
12 #include "SkBlitter.h" 12 #include "SkBlitter.h"
13 #include "SkBlitRow.h" 13 #include "SkBlitRow.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 #include "SkSmallAllocator.h" 15 #include "SkSmallAllocator.h"
16 16
17 class SkRasterBlitter : public SkBlitter { 17 class SkRasterBlitter : public SkBlitter {
18 public: 18 public:
19 SkRasterBlitter(const SkBitmap& device) : fDevice(device) {} 19 SkRasterBlitter(const SkBitmap& device) : fDevice(device) {}
20 20
21 protected: 21 protected:
22 const SkBitmap& fDevice; 22 const SkBitmap& fDevice;
23 23
24 private: 24 private:
25 typedef SkBlitter INHERITED; 25 typedef SkBlitter INHERITED;
26 }; 26 };
27 27
28 class SkShaderBlitter : public SkRasterBlitter { 28 class SkShaderBlitter : public SkRasterBlitter {
29 public: 29 public:
30 SkShaderBlitter(const SkBitmap& device, const SkPaint& paint); 30 /**
31 * The storage for shaderContext is owned by the caller, but the object it self is not.
32 * The blitter only ensures that the storage always holds a live object.
33 */
34 SkShaderBlitter(const SkBitmap& device, const SkPaint& paint,
35 SkShader::Context* shaderContext);
31 virtual ~SkShaderBlitter(); 36 virtual ~SkShaderBlitter();
32 37
38 /**
39 * Create a new shader context and uses it instead of the old one if succe ssful.
40 * Will create the context at the same location as the old one (this is sa fe
41 * because the shader itself is unchanged).
42 */
43 virtual bool resetShaderContext(const SkBitmap& device, const SkPaint& paint ,
44 const SkMatrix& matrix) SK_OVERRIDE;
45
46 virtual SkShader::Context* getShaderContext() const SK_OVERRIDE { return fSh aderContext; }
47
33 protected: 48 protected:
34 uint32_t fShaderFlags; 49 uint32_t fShaderFlags;
35 SkShader* fShader; 50 const SkShader* fShader;
51 SkShader::Context* fShaderContext;
36 52
37 private: 53 private:
38 // illegal 54 // illegal
39 SkShaderBlitter& operator=(const SkShaderBlitter&); 55 SkShaderBlitter& operator=(const SkShaderBlitter&);
40 56
41 typedef SkRasterBlitter INHERITED; 57 typedef SkRasterBlitter INHERITED;
42 }; 58 };
43 59
44 /////////////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////////////
45 61
(...skipping 22 matching lines...) Expand all
68 unsigned fSrcA; 84 unsigned fSrcA;
69 85
70 // illegal 86 // illegal
71 SkA8_Blitter& operator=(const SkA8_Blitter&); 87 SkA8_Blitter& operator=(const SkA8_Blitter&);
72 88
73 typedef SkRasterBlitter INHERITED; 89 typedef SkRasterBlitter INHERITED;
74 }; 90 };
75 91
76 class SkA8_Shader_Blitter : public SkShaderBlitter { 92 class SkA8_Shader_Blitter : public SkShaderBlitter {
77 public: 93 public:
78 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 94 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
95 SkShader::Context* shaderContext);
79 virtual ~SkA8_Shader_Blitter(); 96 virtual ~SkA8_Shader_Blitter();
80 virtual void blitH(int x, int y, int width); 97 virtual void blitH(int x, int y, int width);
81 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]); 98 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]);
82 virtual void blitMask(const SkMask&, const SkIRect&); 99 virtual void blitMask(const SkMask&, const SkIRect&);
83 100
84 private: 101 private:
85 SkXfermode* fXfermode; 102 SkXfermode* fXfermode;
86 SkPMColor* fBuffer; 103 SkPMColor* fBuffer;
87 uint8_t* fAAExpand; 104 uint8_t* fAAExpand;
88 105
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) 151 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
135 : INHERITED(device, paint) {} 152 : INHERITED(device, paint) {}
136 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]); 153 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]);
137 154
138 private: 155 private:
139 typedef SkARGB32_Opaque_Blitter INHERITED; 156 typedef SkARGB32_Opaque_Blitter INHERITED;
140 }; 157 };
141 158
142 class SkARGB32_Shader_Blitter : public SkShaderBlitter { 159 class SkARGB32_Shader_Blitter : public SkShaderBlitter {
143 public: 160 public:
144 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 161 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
162 SkShader::Context* shaderContext);
145 virtual ~SkARGB32_Shader_Blitter(); 163 virtual ~SkARGB32_Shader_Blitter();
146 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 164 virtual void blitH(int x, int y, int width) SK_OVERRIDE;
147 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; 165 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE;
148 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; 166 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
149 virtual void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) SK_OV ERRIDE; 167 virtual void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) SK_OV ERRIDE;
150 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE; 168 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE;
151 169
152 private: 170 private:
153 SkXfermode* fXfermode; 171 SkXfermode* fXfermode;
154 SkPMColor* fBuffer; 172 SkPMColor* fBuffer;
(...skipping 17 matching lines...) Expand all
172 190
173 1. If there is an xfermode, there will also be a shader 191 1. If there is an xfermode, there will also be a shader
174 2. If there is a colorfilter, there will be a shader that itself handles 192 2. If there is a colorfilter, there will be a shader that itself handles
175 calling the filter, so the blitter can always ignore the colorfilter obj 193 calling the filter, so the blitter can always ignore the colorfilter obj
176 194
177 These pre-conditions must be handled by the caller, in our case 195 These pre-conditions must be handled by the caller, in our case
178 SkBlitter::Choose(...) 196 SkBlitter::Choose(...)
179 */ 197 */
180 198
181 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint, 199 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint,
200 SkShader::Context* shaderContext,
182 SkTBlitterAllocator* allocator); 201 SkTBlitterAllocator* allocator);
183 202
184 #endif 203 #endif
OLDNEW
« include/core/SkShader.h ('K') | « src/core/SkComposeShader.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698