OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
11 #include "SkRasterClip.h" | 11 #include "SkRasterClip.h" |
12 #include "SkShader.h" | 12 #include "SkShader.h" |
13 | 13 |
14 SK_DEFINE_INST_COUNT(SkBitmapDevice) | 14 SK_DEFINE_INST_COUNT(SkBitmapDevice) |
15 | 15 |
16 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \ | 16 #define CHECK_FOR_ANNOTATION(paint) \ |
17 do { if (paint.isNoDrawAnnotation()) { return; } } while (0) | 17 do { if (paint.getAnnotation()) { return; } } while (0) |
18 | 18 |
19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) | 19 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) |
20 : fBitmap(bitmap) { | 20 : fBitmap(bitmap) { |
21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); | 21 SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); |
22 } | 22 } |
23 | 23 |
24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties&
deviceProperties) | 24 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties&
deviceProperties) |
25 : SkBaseDevice(deviceProperties) | 25 : SkBaseDevice(deviceProperties) |
26 , fBitmap(bitmap) { | 26 , fBitmap(bitmap) { |
27 } | 27 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 /////////////////////////////////////////////////////////////////////////////// | 205 /////////////////////////////////////////////////////////////////////////////// |
206 | 206 |
207 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 207 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
208 draw.drawPaint(paint); | 208 draw.drawPaint(paint); |
209 } | 209 } |
210 | 210 |
211 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, | 211 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, |
212 const SkPoint pts[], const SkPaint& paint) { | 212 const SkPoint pts[], const SkPaint& paint) { |
213 CHECK_FOR_NODRAW_ANNOTATION(paint); | 213 CHECK_FOR_ANNOTATION(paint); |
214 draw.drawPoints(mode, count, pts, paint); | 214 draw.drawPoints(mode, count, pts, paint); |
215 } | 215 } |
216 | 216 |
217 void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint
& paint) { | 217 void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint
& paint) { |
218 CHECK_FOR_NODRAW_ANNOTATION(paint); | 218 CHECK_FOR_ANNOTATION(paint); |
219 draw.drawRect(r, paint); | 219 draw.drawRect(r, paint); |
220 } | 220 } |
221 | 221 |
222 void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPa
int& paint) { | 222 void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPa
int& paint) { |
223 CHECK_FOR_NODRAW_ANNOTATION(paint); | 223 CHECK_FOR_ANNOTATION(paint); |
224 | 224 |
225 SkPath path; | 225 SkPath path; |
226 path.addOval(oval); | 226 path.addOval(oval); |
227 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't | 227 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
228 // required to override drawOval. | 228 // required to override drawOval. |
229 this->drawPath(draw, path, paint, NULL, true); | 229 this->drawPath(draw, path, paint, NULL, true); |
230 } | 230 } |
231 | 231 |
232 void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const S
kPaint& paint) { | 232 void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const S
kPaint& paint) { |
233 CHECK_FOR_NODRAW_ANNOTATION(paint); | 233 CHECK_FOR_ANNOTATION(paint); |
234 | 234 |
235 SkPath path; | 235 SkPath path; |
236 path.addRRect(rrect); | 236 path.addRRect(rrect); |
237 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't | 237 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
238 // required to override drawRRect. | 238 // required to override drawRRect. |
239 this->drawPath(draw, path, paint, NULL, true); | 239 this->drawPath(draw, path, paint, NULL, true); |
240 } | 240 } |
241 | 241 |
242 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, | 242 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, |
243 const SkPaint& paint, const SkMatrix* prePathMatri
x, | 243 const SkPaint& paint, const SkMatrix* prePathMatri
x, |
244 bool pathIsMutable) { | 244 bool pathIsMutable) { |
245 CHECK_FOR_NODRAW_ANNOTATION(paint); | 245 CHECK_FOR_ANNOTATION(paint); |
246 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); | 246 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); |
247 } | 247 } |
248 | 248 |
249 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, | 249 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
250 const SkMatrix& matrix, const SkPaint& paint) { | 250 const SkMatrix& matrix, const SkPaint& paint) { |
251 draw.drawBitmap(bitmap, matrix, paint); | 251 draw.drawBitmap(bitmap, matrix, paint); |
252 } | 252 } |
253 | 253 |
254 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 254 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
255 const SkRect* src, const SkRect& dst, | 255 const SkRect* src, const SkRect& dst, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 paint.getStyle() != SkPaint::kFill_Style || | 400 paint.getStyle() != SkPaint::kFill_Style || |
401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { | 401 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { |
402 // turn off lcd | 402 // turn off lcd |
403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; | 403 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; |
404 flags->fHinting = paint.getHinting(); | 404 flags->fHinting = paint.getHinting(); |
405 return true; | 405 return true; |
406 } | 406 } |
407 // we're cool with the paint as is | 407 // we're cool with the paint as is |
408 return false; | 408 return false; |
409 } | 409 } |
OLD | NEW |