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

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

Issue 1148793007: change SkDraw and all Blitters to use pixmap instead of bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 6 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
« no previous file with comments | « src/core/SkBlitMask_D32.cpp ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkBlitter_DEFINED 8 #ifndef SkBlitter_DEFINED
9 #define SkBlitter_DEFINED 9 #define SkBlitter_DEFINED
10 10
11 #include "SkBitmap.h"
12 #include "SkBitmapProcShader.h" 11 #include "SkBitmapProcShader.h"
13 #include "SkMask.h" 12 #include "SkMask.h"
14 #include "SkMatrix.h" 13 #include "SkMatrix.h"
15 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkPixmap.h"
16 #include "SkRefCnt.h" 16 #include "SkRefCnt.h"
17 #include "SkRegion.h" 17 #include "SkRegion.h"
18 #include "SkShader.h" 18 #include "SkShader.h"
19 #include "SkSmallAllocator.h" 19 #include "SkSmallAllocator.h"
20 20
21 /** SkBlitter and its subclasses are responsible for actually writing pixels 21 /** SkBlitter and its subclasses are responsible for actually writing pixels
22 into memory. Besides efficiency, they handle clipping and antialiasing. 22 into memory. Besides efficiency, they handle clipping and antialiasing.
23 */ 23 */
24 class SkBlitter { 24 class SkBlitter {
25 public: 25 public:
(...skipping 18 matching lines...) Expand all
44 virtual void blitAntiRect(int x, int y, int width, int height, 44 virtual void blitAntiRect(int x, int y, int width, int height,
45 SkAlpha leftAlpha, SkAlpha rightAlpha); 45 SkAlpha leftAlpha, SkAlpha rightAlpha);
46 /// Blit a pattern of pixels defined by a rectangle-clipped mask; 46 /// Blit a pattern of pixels defined by a rectangle-clipped mask;
47 /// typically used for text. 47 /// typically used for text.
48 virtual void blitMask(const SkMask&, const SkIRect& clip); 48 virtual void blitMask(const SkMask&, const SkIRect& clip);
49 49
50 /** If the blitter just sets a single value for each pixel, return the 50 /** If the blitter just sets a single value for each pixel, return the
51 bitmap it draws into, and assign value. If not, return NULL and ignore 51 bitmap it draws into, and assign value. If not, return NULL and ignore
52 the value parameter. 52 the value parameter.
53 */ 53 */
54 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value); 54 virtual const SkPixmap* justAnOpaqueColor(uint32_t* value);
55 55
56 // (x, y), (x + 1, y) 56 // (x, y), (x + 1, y)
57 virtual void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { 57 virtual void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
58 int16_t runs[3]; 58 int16_t runs[3];
59 uint8_t aa[2]; 59 uint8_t aa[2];
60 60
61 runs[0] = 1; 61 runs[0] = 1;
62 runs[1] = 1; 62 runs[1] = 1;
63 runs[2] = 0; 63 runs[2] = 0;
64 aa[0] = SkToU8(a0); 64 aa[0] = SkToU8(a0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 ///@name non-virtual helpers 116 ///@name non-virtual helpers
117 void blitMaskRegion(const SkMask& mask, const SkRegion& clip); 117 void blitMaskRegion(const SkMask& mask, const SkRegion& clip);
118 void blitRectRegion(const SkIRect& rect, const SkRegion& clip); 118 void blitRectRegion(const SkIRect& rect, const SkRegion& clip);
119 void blitRegion(const SkRegion& clip); 119 void blitRegion(const SkRegion& clip);
120 ///@} 120 ///@}
121 121
122 /** @name Factories 122 /** @name Factories
123 Return the correct blitter to use given the specified context. 123 Return the correct blitter to use given the specified context.
124 */ 124 */
125 static SkBlitter* Choose(const SkBitmap& device, 125 static SkBlitter* Choose(const SkPixmap& dst,
126 const SkMatrix& matrix, 126 const SkMatrix& matrix,
127 const SkPaint& paint, 127 const SkPaint& paint,
128 SkTBlitterAllocator*, 128 SkTBlitterAllocator*,
129 bool drawCoverage = false); 129 bool drawCoverage = false);
130 130
131 static SkBlitter* ChooseSprite(const SkPixmap& dst, 131 static SkBlitter* ChooseSprite(const SkPixmap& dst,
132 const SkPaint&, 132 const SkPaint&,
133 const SkPixmap& src, 133 const SkPixmap& src,
134 int left, int top, 134 int left, int top,
135 SkTBlitterAllocator*); 135 SkTBlitterAllocator*);
136 ///@} 136 ///@}
137 137
138 protected: 138 protected:
139 139
140 SkAutoMalloc fBlitMemory; 140 SkAutoMalloc fBlitMemory;
141 141
142 private: 142 private:
143 }; 143 };
144 144
145 /** This blitter silently never draws anything. 145 /** This blitter silently never draws anything.
146 */ 146 */
147 class SkNullBlitter : public SkBlitter { 147 class SkNullBlitter : public SkBlitter {
148 public: 148 public:
149 void blitH(int x, int y, int width) override; 149 void blitH(int x, int y, int width) override;
150 virtual void blitAntiH(int x, int y, const SkAlpha[], 150 virtual void blitAntiH(int x, int y, const SkAlpha[],
151 const int16_t runs[]) override; 151 const int16_t runs[]) override;
152 void blitV(int x, int y, int height, SkAlpha alpha) override; 152 void blitV(int x, int y, int height, SkAlpha alpha) override;
153 void blitRect(int x, int y, int width, int height) override; 153 void blitRect(int x, int y, int width, int height) override;
154 void blitMask(const SkMask&, const SkIRect& clip) override; 154 void blitMask(const SkMask&, const SkIRect& clip) override;
155 const SkBitmap* justAnOpaqueColor(uint32_t* value) override; 155 const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
156 bool isNullBlitter() const override; 156 bool isNullBlitter() const override;
157 }; 157 };
158 158
159 /** Wraps another (real) blitter, and ensures that the real blitter is only 159 /** Wraps another (real) blitter, and ensures that the real blitter is only
160 called with coordinates that have been clipped by the specified clipRect. 160 called with coordinates that have been clipped by the specified clipRect.
161 This means the caller need not perform the clipping ahead of time. 161 This means the caller need not perform the clipping ahead of time.
162 */ 162 */
163 class SkRectClipBlitter : public SkBlitter { 163 class SkRectClipBlitter : public SkBlitter {
164 public: 164 public:
165 void init(SkBlitter* blitter, const SkIRect& clipRect) { 165 void init(SkBlitter* blitter, const SkIRect& clipRect) {
166 SkASSERT(!clipRect.isEmpty()); 166 SkASSERT(!clipRect.isEmpty());
167 fBlitter = blitter; 167 fBlitter = blitter;
168 fClipRect = clipRect; 168 fClipRect = clipRect;
169 } 169 }
170 170
171 void blitH(int x, int y, int width) override; 171 void blitH(int x, int y, int width) override;
172 virtual void blitAntiH(int x, int y, const SkAlpha[], 172 virtual void blitAntiH(int x, int y, const SkAlpha[],
173 const int16_t runs[]) override; 173 const int16_t runs[]) override;
174 void blitV(int x, int y, int height, SkAlpha alpha) override; 174 void blitV(int x, int y, int height, SkAlpha alpha) override;
175 void blitRect(int x, int y, int width, int height) override; 175 void blitRect(int x, int y, int width, int height) override;
176 virtual void blitAntiRect(int x, int y, int width, int height, 176 virtual void blitAntiRect(int x, int y, int width, int height,
177 SkAlpha leftAlpha, SkAlpha rightAlpha) override; 177 SkAlpha leftAlpha, SkAlpha rightAlpha) override;
178 void blitMask(const SkMask&, const SkIRect& clip) override; 178 void blitMask(const SkMask&, const SkIRect& clip) override;
179 const SkBitmap* justAnOpaqueColor(uint32_t* value) override; 179 const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
180 180
181 int requestRowsPreserved() const override { 181 int requestRowsPreserved() const override {
182 return fBlitter->requestRowsPreserved(); 182 return fBlitter->requestRowsPreserved();
183 } 183 }
184 184
185 void* allocBlitMemory(size_t sz) override { 185 void* allocBlitMemory(size_t sz) override {
186 return fBlitter->allocBlitMemory(sz); 186 return fBlitter->allocBlitMemory(sz);
187 } 187 }
188 188
189 private: 189 private:
(...skipping 14 matching lines...) Expand all
204 } 204 }
205 205
206 void blitH(int x, int y, int width) override; 206 void blitH(int x, int y, int width) override;
207 virtual void blitAntiH(int x, int y, const SkAlpha[], 207 virtual void blitAntiH(int x, int y, const SkAlpha[],
208 const int16_t runs[]) override; 208 const int16_t runs[]) override;
209 void blitV(int x, int y, int height, SkAlpha alpha) override; 209 void blitV(int x, int y, int height, SkAlpha alpha) override;
210 void blitRect(int x, int y, int width, int height) override; 210 void blitRect(int x, int y, int width, int height) override;
211 virtual void blitAntiRect(int x, int y, int width, int height, 211 virtual void blitAntiRect(int x, int y, int width, int height,
212 SkAlpha leftAlpha, SkAlpha rightAlpha) override; 212 SkAlpha leftAlpha, SkAlpha rightAlpha) override;
213 void blitMask(const SkMask&, const SkIRect& clip) override; 213 void blitMask(const SkMask&, const SkIRect& clip) override;
214 const SkBitmap* justAnOpaqueColor(uint32_t* value) override; 214 const SkPixmap* justAnOpaqueColor(uint32_t* value) override;
215 215
216 int requestRowsPreserved() const override { 216 int requestRowsPreserved() const override {
217 return fBlitter->requestRowsPreserved(); 217 return fBlitter->requestRowsPreserved();
218 } 218 }
219 219
220 void* allocBlitMemory(size_t sz) override { 220 void* allocBlitMemory(size_t sz) override {
221 return fBlitter->allocBlitMemory(sz); 221 return fBlitter->allocBlitMemory(sz);
222 } 222 }
223 223
224 private: 224 private:
(...skipping 10 matching lines...) Expand all
235 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, 235 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip,
236 const SkIRect* bounds = NULL); 236 const SkIRect* bounds = NULL);
237 237
238 private: 238 private:
239 SkNullBlitter fNullBlitter; 239 SkNullBlitter fNullBlitter;
240 SkRectClipBlitter fRectBlitter; 240 SkRectClipBlitter fRectBlitter;
241 SkRgnClipBlitter fRgnBlitter; 241 SkRgnClipBlitter fRgnBlitter;
242 }; 242 };
243 243
244 #endif 244 #endif
OLDNEW
« no previous file with comments | « src/core/SkBlitMask_D32.cpp ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698