| 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" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, | 239 void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, |
| 240 const SkPaint& paint, const SkMatrix* prePathMatri
x, | 240 const SkPaint& paint, const SkMatrix* prePathMatri
x, |
| 241 bool pathIsMutable) { | 241 bool pathIsMutable) { |
| 242 CHECK_FOR_ANNOTATION(paint); | 242 CHECK_FOR_ANNOTATION(paint); |
| 243 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); | 243 draw.drawPath(path, paint, prePathMatrix, pathIsMutable); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, | 246 void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
| 247 const SkMatrix& matrix, const SkPaint& paint) { | 247 const SkMatrix& matrix, const SkPaint& paint) { |
| 248 logDrawScaleFactor(SkMatrix::Concat(*draw.fMatrix, matrix), paint.getFilterQ
uality()); |
| 248 draw.drawBitmap(bitmap, matrix, nullptr, paint); | 249 draw.drawBitmap(bitmap, matrix, nullptr, paint); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 252 void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
| 252 const SkRect* src, const SkRect& dst, | 253 const SkRect* src, const SkRect& dst, |
| 253 const SkPaint& paint, SkCanvas::SrcRectConst
raint constraint) { | 254 const SkPaint& paint, SkCanvas::SrcRectConst
raint constraint) { |
| 254 SkMatrix matrix; | 255 SkMatrix matrix; |
| 255 SkRect bitmapBounds, tmpSrc, tmpDst; | 256 SkRect bitmapBounds, tmpSrc, tmpDst; |
| 256 SkBitmap tmpBitmap; | 257 SkBitmap tmpBitmap; |
| 257 | 258 |
| 258 bitmapBounds.isetWH(bitmap.width(), bitmap.height()); | 259 bitmapBounds.isetWH(bitmap.width(), bitmap.height()); |
| 259 | 260 |
| 260 // Compute matrix from the two rectangles | 261 // Compute matrix from the two rectangles |
| 261 if (src) { | 262 if (src) { |
| 262 tmpSrc = *src; | 263 tmpSrc = *src; |
| 263 } else { | 264 } else { |
| 264 tmpSrc = bitmapBounds; | 265 tmpSrc = bitmapBounds; |
| 265 } | 266 } |
| 266 matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit); | 267 matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit); |
| 267 | 268 |
| 269 logDrawScaleFactor(SkMatrix::Concat(*draw.fMatrix, matrix), paint.getFilterQ
uality()); |
| 270 |
| 268 const SkRect* dstPtr = &dst; | 271 const SkRect* dstPtr = &dst; |
| 269 const SkBitmap* bitmapPtr = &bitmap; | 272 const SkBitmap* bitmapPtr = &bitmap; |
| 270 | 273 |
| 271 // clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if | 274 // clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if |
| 272 // needed (if the src was clipped). No check needed if src==null. | 275 // needed (if the src was clipped). No check needed if src==null. |
| 273 if (src) { | 276 if (src) { |
| 274 if (!bitmapBounds.contains(*src)) { | 277 if (!bitmapBounds.contains(*src)) { |
| 275 if (!tmpSrc.intersect(bitmapBounds)) { | 278 if (!tmpSrc.intersect(bitmapBounds)) { |
| 276 return; // nothing to draw | 279 return; // nothing to draw |
| 277 } | 280 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 paint.getRasterizer() || | 390 paint.getRasterizer() || |
| 388 paint.getPathEffect() || | 391 paint.getPathEffect() || |
| 389 paint.isFakeBoldText() || | 392 paint.isFakeBoldText() || |
| 390 paint.getStyle() != SkPaint::kFill_Style || | 393 paint.getStyle() != SkPaint::kFill_Style || |
| 391 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 394 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
| 392 { | 395 { |
| 393 return true; | 396 return true; |
| 394 } | 397 } |
| 395 return false; | 398 return false; |
| 396 } | 399 } |
| OLD | NEW |