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