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

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: rebase & cleanup 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 // TODO(dominikg): Should this class have its own SkSmallAllocator for stori ng the
scroggo 2014/04/03 15:35:54 Didn't you determine that this wouldn't work witho
Dominik Grewe 2014/04/04 10:59:41 Yes, you're right. I'll remove this.
31 // shader context? Would avoid weird ownership issues (see b elow).
32 /**
33 * The storage for shaderContext is owned by the caller, but the object it self is not.
34 * The blitter only ensures that the storage always holds a live object.
35 */
36 SkShaderBlitter(const SkBitmap& device, const SkPaint& paint,
37 SkShader::Context* shaderContext);
31 virtual ~SkShaderBlitter(); 38 virtual ~SkShaderBlitter();
32 39
40 /**
41 * Create a new shader context and uses it instead of the old one if succe ssful.
42 * Will create the context at the same location as the old one (this is sa fe
43 * because the shader itself is unchanged).
44 */
45 virtual bool resetShaderContext(const SkBitmap& device, const SkPaint& paint ,
46 const SkMatrix& matrix) SK_OVERRIDE;
47
48 virtual SkShader::Context* getShaderContext() const SK_OVERRIDE { return fSh aderContext; }
49
33 protected: 50 protected:
34 uint32_t fShaderFlags; 51 uint32_t fShaderFlags;
35 SkShader* fShader; 52 const SkShader* fShader;
53 SkShader::Context* fShaderContext;
36 54
37 private: 55 private:
38 // illegal 56 // illegal
39 SkShaderBlitter& operator=(const SkShaderBlitter&); 57 SkShaderBlitter& operator=(const SkShaderBlitter&);
40 58
41 typedef SkRasterBlitter INHERITED; 59 typedef SkRasterBlitter INHERITED;
42 }; 60 };
43 61
44 /////////////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////////////
45 63
(...skipping 22 matching lines...) Expand all
68 unsigned fSrcA; 86 unsigned fSrcA;
69 87
70 // illegal 88 // illegal
71 SkA8_Blitter& operator=(const SkA8_Blitter&); 89 SkA8_Blitter& operator=(const SkA8_Blitter&);
72 90
73 typedef SkRasterBlitter INHERITED; 91 typedef SkRasterBlitter INHERITED;
74 }; 92 };
75 93
76 class SkA8_Shader_Blitter : public SkShaderBlitter { 94 class SkA8_Shader_Blitter : public SkShaderBlitter {
77 public: 95 public:
78 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 96 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
97 SkShader::Context* shaderContext);
79 virtual ~SkA8_Shader_Blitter(); 98 virtual ~SkA8_Shader_Blitter();
80 virtual void blitH(int x, int y, int width); 99 virtual void blitH(int x, int y, int width);
81 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]); 100 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]);
82 virtual void blitMask(const SkMask&, const SkIRect&); 101 virtual void blitMask(const SkMask&, const SkIRect&);
83 102
84 private: 103 private:
85 SkXfermode* fXfermode; 104 SkXfermode* fXfermode;
86 SkPMColor* fBuffer; 105 SkPMColor* fBuffer;
87 uint8_t* fAAExpand; 106 uint8_t* fAAExpand;
88 107
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) 153 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
135 : INHERITED(device, paint) {} 154 : INHERITED(device, paint) {}
136 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]); 155 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_ t runs[]);
137 156
138 private: 157 private:
139 typedef SkARGB32_Opaque_Blitter INHERITED; 158 typedef SkARGB32_Opaque_Blitter INHERITED;
140 }; 159 };
141 160
142 class SkARGB32_Shader_Blitter : public SkShaderBlitter { 161 class SkARGB32_Shader_Blitter : public SkShaderBlitter {
143 public: 162 public:
144 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint); 163 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint,
164 SkShader::Context* shaderContext);
145 virtual ~SkARGB32_Shader_Blitter(); 165 virtual ~SkARGB32_Shader_Blitter();
146 virtual void blitH(int x, int y, int width) SK_OVERRIDE; 166 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; 167 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; 168 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; 169 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; 170 virtual void blitMask(const SkMask&, const SkIRect&) SK_OVERRIDE;
151 171
152 private: 172 private:
153 SkXfermode* fXfermode; 173 SkXfermode* fXfermode;
154 SkPMColor* fBuffer; 174 SkPMColor* fBuffer;
(...skipping 17 matching lines...) Expand all
172 192
173 1. If there is an xfermode, there will also be a shader 193 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 194 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 195 calling the filter, so the blitter can always ignore the colorfilter obj
176 196
177 These pre-conditions must be handled by the caller, in our case 197 These pre-conditions must be handled by the caller, in our case
178 SkBlitter::Choose(...) 198 SkBlitter::Choose(...)
179 */ 199 */
180 200
181 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint, 201 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint,
202 SkShader::Context* shaderContext,
182 SkTBlitterAllocator* allocator); 203 SkTBlitterAllocator* allocator);
183 204
184 #endif 205 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698