| 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 "SkMallocPixelRef.h" | 11 #include "SkMallocPixelRef.h" |
| 12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
| 13 #include "SkPaint.h" | 13 #include "SkPaint.h" |
| 14 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkPixelRef.h" | 15 #include "SkPixelRef.h" |
| 16 #include "SkPixmap.h" | 16 #include "SkPixmap.h" |
| 17 #include "SkShader.h" | 17 #include "SkShader.h" |
| 18 #include "SkSurface.h" | 18 #include "SkSurface.h" |
| 19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
| 20 | 20 |
| 21 class SkColorTable; | 21 class SkColorTable; |
| 22 | 22 |
| 23 #define CHECK_FOR_ANNOTATION(paint) \ | |
| 24 do { if (paint.getAnnotation()) { return; } } while (0) | |
| 25 | |
| 26 static bool valid_for_bitmap_device(const SkImageInfo& info, | 23 static bool valid_for_bitmap_device(const SkImageInfo& info, |
| 27 SkAlphaType* newAlphaType) { | 24 SkAlphaType* newAlphaType) { |
| 28 if (info.width() < 0 || info.height() < 0) { | 25 if (info.width() < 0 || info.height() < 0) { |
| 29 return false; | 26 return false; |
| 30 } | 27 } |
| 31 | 28 |
| 32 // TODO: can we stop supporting kUnknown in SkBitmkapDevice? | 29 // TODO: can we stop supporting kUnknown in SkBitmkapDevice? |
| 33 if (kUnknown_SkColorType == info.colorType()) { | 30 if (kUnknown_SkColorType == info.colorType()) { |
| 34 if (newAlphaType) { | 31 if (newAlphaType) { |
| 35 *newAlphaType = kUnknown_SkAlphaType; | 32 *newAlphaType = kUnknown_SkAlphaType; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 194 } |
| 198 | 195 |
| 199 /////////////////////////////////////////////////////////////////////////////// | 196 /////////////////////////////////////////////////////////////////////////////// |
| 200 | 197 |
| 201 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 198 void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
| 202 draw.drawPaint(paint); | 199 draw.drawPaint(paint); |
| 203 } | 200 } |
| 204 | 201 |
| 205 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, | 202 void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, si
ze_t count, |
| 206 const SkPoint pts[], const SkPaint& paint) { | 203 const SkPoint pts[], const SkPaint& paint) { |
| 207 CHECK_FOR_ANNOTATION(paint); | |
| 208 draw.drawPoints(mode, count, pts, paint); | 204 draw.drawPoints(mode, count, pts, paint); |
| 209 } | 205 } |
| 210 | 206 |
| 211 void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint
& paint) { | 207 void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint
& paint) { |
| 212 CHECK_FOR_ANNOTATION(paint); | |
| 213 draw.drawRect(r, paint); | 208 draw.drawRect(r, paint); |
| 214 } | 209 } |
| 215 | 210 |
| 216 void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPa
int& paint) { | 211 void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPa
int& paint) { |
| 217 CHECK_FOR_ANNOTATION(paint); | |
| 218 | |
| 219 SkPath path; | 212 SkPath path; |
| 220 path.addOval(oval); | 213 path.addOval(oval); |
| 221 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't | 214 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
| 222 // required to override drawOval. | 215 // required to override drawOval. |
| 223 this->drawPath(draw, path, paint, nullptr, true); | 216 this->drawPath(draw, path, paint, nullptr, true); |
| 224 } | 217 } |
| 225 | 218 |
| 226 void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const S
kPaint& paint) { | 219 void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const S
kPaint& paint) { |
| 227 CHECK_FOR_ANNOTATION(paint); | |
| 228 | |
| 229 #ifdef SK_IGNORE_BLURRED_RRECT_OPT | 220 #ifdef SK_IGNORE_BLURRED_RRECT_OPT |
| 230 SkPath path; | 221 SkPath path; |
| 231 | 222 |
| 232 path.addRRect(rrect); | 223 path.addRRect(rrect); |
| 233 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't | 224 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't |
| 234 // required to override drawRRect. | 225 // required to override drawRRect. |
| 235 this->drawPath(draw, path, paint, nullptr, true); | 226 this->drawPath(draw, path, paint, nullptr, true); |
| 236 #else | 227 #else |
| 237 draw.drawRRect(rrect, paint); | 228 draw.drawRRect(rrect, paint); |
| 238 #endif | 229 #endif |
| 239 } | 230 } |
| 240 | 231 |
| 241 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, | 232 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, |
| 242 const SkPaint& paint, const SkMatrix* prePathMatri
x, | 233 const SkPaint& paint, const SkMatrix* prePathMatri
x, |
| 243 bool pathIsMutable) { | 234 bool pathIsMutable) { |
| 244 CHECK_FOR_ANNOTATION(paint); | |
| 245 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); | 235 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); |
| 246 } | 236 } |
| 247 | 237 |
| 248 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, | 238 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
| 249 const SkMatrix& matrix, const SkPaint& paint) { | 239 const SkMatrix& matrix, const SkPaint& paint) { |
| 250 draw.drawBitmap(bitmap, matrix, nullptr, paint); | 240 draw.drawBitmap(bitmap, matrix, nullptr, paint); |
| 251 } | 241 } |
| 252 | 242 |
| 253 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 243 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
| 254 const SkRect* src, const SkRect& dst, | 244 const SkRect* src, const SkRect& dst, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 paint.getRasterizer() || | 379 paint.getRasterizer() || |
| 390 paint.getPathEffect() || | 380 paint.getPathEffect() || |
| 391 paint.isFakeBoldText() || | 381 paint.isFakeBoldText() || |
| 392 paint.getStyle() != SkPaint::kFill_Style || | 382 paint.getStyle() != SkPaint::kFill_Style || |
| 393 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 383 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
| 394 { | 384 { |
| 395 return true; | 385 return true; |
| 396 } | 386 } |
| 397 return false; | 387 return false; |
| 398 } | 388 } |
| OLD | NEW |