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