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