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 SkPixmap& device) : fDevice(device) {} |
20 | 20 |
21 protected: | 21 protected: |
22 const SkBitmap& fDevice; | 22 const SkPixmap 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 /** | 30 /** |
31 * The storage for shaderContext is owned by the caller, but the object it
self is not. | 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 | 32 * The blitter only ensures that the storage always holds a live object, b
ut it may |
33 * exchange that object. | 33 * exchange that object. |
34 */ | 34 */ |
35 SkShaderBlitter(const SkBitmap& device, const SkPaint& paint, | 35 SkShaderBlitter(const SkPixmap& device, const SkPaint& paint, |
36 SkShader::Context* shaderContext); | 36 SkShader::Context* shaderContext); |
37 virtual ~SkShaderBlitter(); | 37 virtual ~SkShaderBlitter(); |
38 | 38 |
39 /** | 39 /** |
40 * Create a new shader context and uses it instead of the old one if succe
ssful. | 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 | 41 * Will create the context at the same location as the old one (this is sa
fe |
42 * because the shader itself is unchanged). | 42 * because the shader itself is unchanged). |
43 */ | 43 */ |
44 bool resetShaderContext(const SkShader::ContextRec&) override; | 44 bool resetShaderContext(const SkShader::ContextRec&) override; |
45 | 45 |
46 SkShader::Context* getShaderContext() const override { return fShaderContext
; } | 46 SkShader::Context* getShaderContext() const override { return fShaderContext
; } |
47 | 47 |
48 protected: | 48 protected: |
49 uint32_t fShaderFlags; | 49 uint32_t fShaderFlags; |
50 const SkShader* fShader; | 50 const SkShader* fShader; |
51 SkShader::Context* fShaderContext; | 51 SkShader::Context* fShaderContext; |
52 | 52 |
53 private: | 53 private: |
54 // illegal | 54 // illegal |
55 SkShaderBlitter& operator=(const SkShaderBlitter&); | 55 SkShaderBlitter& operator=(const SkShaderBlitter&); |
56 | 56 |
57 typedef SkRasterBlitter INHERITED; | 57 typedef SkRasterBlitter INHERITED; |
58 }; | 58 }; |
59 | 59 |
60 /////////////////////////////////////////////////////////////////////////////// | 60 /////////////////////////////////////////////////////////////////////////////// |
61 | 61 |
62 class SkA8_Coverage_Blitter : public SkRasterBlitter { | 62 class SkA8_Coverage_Blitter : public SkRasterBlitter { |
63 public: | 63 public: |
64 SkA8_Coverage_Blitter(const SkBitmap& device, const SkPaint& paint); | 64 SkA8_Coverage_Blitter(const SkPixmap& device, const SkPaint& paint); |
65 void blitH(int x, int y, int width) override; | 65 void blitH(int x, int y, int width) override; |
66 void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]
) override; | 66 void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]
) override; |
67 void blitV(int x, int y, int height, SkAlpha alpha) override; | 67 void blitV(int x, int y, int height, SkAlpha alpha) override; |
68 void blitRect(int x, int y, int width, int height) override; | 68 void blitRect(int x, int y, int width, int height) override; |
69 void blitMask(const SkMask&, const SkIRect&) override; | 69 void blitMask(const SkMask&, const SkIRect&) override; |
70 const SkBitmap* justAnOpaqueColor(uint32_t*) override; | 70 const SkPixmap* justAnOpaqueColor(uint32_t*) override; |
71 }; | 71 }; |
72 | 72 |
73 class SkA8_Blitter : public SkRasterBlitter { | 73 class SkA8_Blitter : public SkRasterBlitter { |
74 public: | 74 public: |
75 SkA8_Blitter(const SkBitmap& device, const SkPaint& paint); | 75 SkA8_Blitter(const SkPixmap& device, const SkPaint& paint); |
76 virtual void blitH(int x, int y, int width); | 76 virtual void blitH(int x, int y, int width); |
77 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_
t runs[]); | 77 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_
t runs[]); |
78 virtual void blitV(int x, int y, int height, SkAlpha alpha); | 78 virtual void blitV(int x, int y, int height, SkAlpha alpha); |
79 virtual void blitRect(int x, int y, int width, int height); | 79 virtual void blitRect(int x, int y, int width, int height); |
80 virtual void blitMask(const SkMask&, const SkIRect&); | 80 virtual void blitMask(const SkMask&, const SkIRect&); |
81 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); | 81 virtual const SkPixmap* justAnOpaqueColor(uint32_t*); |
82 | 82 |
83 private: | 83 private: |
84 unsigned fSrcA; | 84 unsigned fSrcA; |
85 | 85 |
86 // illegal | 86 // illegal |
87 SkA8_Blitter& operator=(const SkA8_Blitter&); | 87 SkA8_Blitter& operator=(const SkA8_Blitter&); |
88 | 88 |
89 typedef SkRasterBlitter INHERITED; | 89 typedef SkRasterBlitter INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 class SkA8_Shader_Blitter : public SkShaderBlitter { | 92 class SkA8_Shader_Blitter : public SkShaderBlitter { |
93 public: | 93 public: |
94 SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint, | 94 SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint, |
95 SkShader::Context* shaderContext); | 95 SkShader::Context* shaderContext); |
96 virtual ~SkA8_Shader_Blitter(); | 96 virtual ~SkA8_Shader_Blitter(); |
97 virtual void blitH(int x, int y, int width); | 97 virtual void blitH(int x, int y, int width); |
98 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[]); |
99 virtual void blitMask(const SkMask&, const SkIRect&); | 99 virtual void blitMask(const SkMask&, const SkIRect&); |
100 | 100 |
101 private: | 101 private: |
102 SkXfermode* fXfermode; | 102 SkXfermode* fXfermode; |
103 SkPMColor* fBuffer; | 103 SkPMColor* fBuffer; |
104 uint8_t* fAAExpand; | 104 uint8_t* fAAExpand; |
105 | 105 |
106 // illegal | 106 // illegal |
107 SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&); | 107 SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&); |
108 | 108 |
109 typedef SkShaderBlitter INHERITED; | 109 typedef SkShaderBlitter INHERITED; |
110 }; | 110 }; |
111 | 111 |
112 //////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////// |
113 | 113 |
114 class SkARGB32_Blitter : public SkRasterBlitter { | 114 class SkARGB32_Blitter : public SkRasterBlitter { |
115 public: | 115 public: |
116 SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint); | 116 SkARGB32_Blitter(const SkPixmap& device, const SkPaint& paint); |
117 virtual void blitH(int x, int y, int width); | 117 virtual void blitH(int x, int y, int width); |
118 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_
t runs[]); | 118 virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_
t runs[]); |
119 virtual void blitV(int x, int y, int height, SkAlpha alpha); | 119 virtual void blitV(int x, int y, int height, SkAlpha alpha); |
120 virtual void blitRect(int x, int y, int width, int height); | 120 virtual void blitRect(int x, int y, int width, int height); |
121 virtual void blitMask(const SkMask&, const SkIRect&); | 121 virtual void blitMask(const SkMask&, const SkIRect&); |
122 virtual const SkBitmap* justAnOpaqueColor(uint32_t*); | 122 virtual const SkPixmap* justAnOpaqueColor(uint32_t*); |
123 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; | 123 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; |
124 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; | 124 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; |
125 | 125 |
126 protected: | 126 protected: |
127 SkColor fColor; | 127 SkColor fColor; |
128 SkPMColor fPMColor; | 128 SkPMColor fPMColor; |
129 | 129 |
130 private: | 130 private: |
131 unsigned fSrcA, fSrcR, fSrcG, fSrcB; | 131 unsigned fSrcA, fSrcR, fSrcG, fSrcB; |
132 | 132 |
133 // illegal | 133 // illegal |
134 SkARGB32_Blitter& operator=(const SkARGB32_Blitter&); | 134 SkARGB32_Blitter& operator=(const SkARGB32_Blitter&); |
135 | 135 |
136 typedef SkRasterBlitter INHERITED; | 136 typedef SkRasterBlitter INHERITED; |
137 }; | 137 }; |
138 | 138 |
139 class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter { | 139 class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter { |
140 public: | 140 public: |
141 SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint) | 141 SkARGB32_Opaque_Blitter(const SkPixmap& device, const SkPaint& paint) |
142 : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); } | 142 : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); } |
143 virtual void blitMask(const SkMask&, const SkIRect&); | 143 virtual void blitMask(const SkMask&, const SkIRect&); |
144 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; | 144 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; |
145 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; | 145 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; |
146 | 146 |
147 private: | 147 private: |
148 typedef SkARGB32_Blitter INHERITED; | 148 typedef SkARGB32_Blitter INHERITED; |
149 }; | 149 }; |
150 | 150 |
151 class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter { | 151 class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter { |
152 public: | 152 public: |
153 SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint) | 153 SkARGB32_Black_Blitter(const SkPixmap& device, const SkPaint& paint) |
154 : INHERITED(device, paint) {} | 154 : INHERITED(device, paint) {} |
155 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[]); |
156 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; | 156 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override; |
157 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; | 157 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override; |
158 | 158 |
159 private: | 159 private: |
160 typedef SkARGB32_Opaque_Blitter INHERITED; | 160 typedef SkARGB32_Opaque_Blitter INHERITED; |
161 }; | 161 }; |
162 | 162 |
163 class SkARGB32_Shader_Blitter : public SkShaderBlitter { | 163 class SkARGB32_Shader_Blitter : public SkShaderBlitter { |
164 public: | 164 public: |
165 SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint, | 165 SkARGB32_Shader_Blitter(const SkPixmap& device, const SkPaint& paint, |
166 SkShader::Context* shaderContext); | 166 SkShader::Context* shaderContext); |
167 virtual ~SkARGB32_Shader_Blitter(); | 167 virtual ~SkARGB32_Shader_Blitter(); |
168 void blitH(int x, int y, int width) override; | 168 void blitH(int x, int y, int width) override; |
169 void blitV(int x, int y, int height, SkAlpha alpha) override; | 169 void blitV(int x, int y, int height, SkAlpha alpha) override; |
170 void blitRect(int x, int y, int width, int height) override; | 170 void blitRect(int x, int y, int width, int height) override; |
171 void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) override; | 171 void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) override; |
172 void blitMask(const SkMask&, const SkIRect&) override; | 172 void blitMask(const SkMask&, const SkIRect&) override; |
173 | 173 |
174 private: | 174 private: |
175 SkXfermode* fXfermode; | 175 SkXfermode* fXfermode; |
(...skipping 17 matching lines...) Expand all Loading... |
193 paint: | 193 paint: |
194 | 194 |
195 1. If there is an xfermode, there will also be a shader | 195 1. If there is an xfermode, there will also be a shader |
196 2. If there is a colorfilter, there will be a shader that itself handles | 196 2. If there is a colorfilter, there will be a shader that itself handles |
197 calling the filter, so the blitter can always ignore the colorfilter obj | 197 calling the filter, so the blitter can always ignore the colorfilter obj |
198 | 198 |
199 These pre-conditions must be handled by the caller, in our case | 199 These pre-conditions must be handled by the caller, in our case |
200 SkBlitter::Choose(...) | 200 SkBlitter::Choose(...) |
201 */ | 201 */ |
202 | 202 |
203 SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device, const SkPaint& paint, | 203 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, |
204 SkShader::Context* shaderContext, | 204 SkShader::Context* shaderContext, |
205 SkTBlitterAllocator* allocator); | 205 SkTBlitterAllocator* allocator); |
206 | 206 |
207 #endif | 207 #endif |
OLD | NEW |