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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (srcIR.fLeft > 0) { | 295 if (srcIR.fLeft > 0) { |
296 dx = SkIntToScalar(srcIR.fLeft); | 296 dx = SkIntToScalar(srcIR.fLeft); |
297 } | 297 } |
298 if (srcIR.fTop > 0) { | 298 if (srcIR.fTop > 0) { |
299 dy = SkIntToScalar(srcIR.fTop); | 299 dy = SkIntToScalar(srcIR.fTop); |
300 } | 300 } |
301 if (dx || dy) { | 301 if (dx || dy) { |
302 matrix.preTranslate(dx, dy); | 302 matrix.preTranslate(dx, dy); |
303 } | 303 } |
304 | 304 |
| 305 #ifdef SK_DRAWBITMAPRECT_FAST_OFFSET |
| 306 SkRect extractedBitmapBounds = SkRect::MakeXYWH(dx, dy, |
| 307 SkIntToScalar(bitmapPtr-
>width()), |
| 308 SkIntToScalar(bitmapPtr-
>height())); |
| 309 #else |
305 SkRect extractedBitmapBounds; | 310 SkRect extractedBitmapBounds; |
306 extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height()); | 311 extractedBitmapBounds.isetWH(bitmapPtr->width(), bitmapPtr->height()); |
| 312 #endif |
307 if (extractedBitmapBounds == tmpSrc) { | 313 if (extractedBitmapBounds == tmpSrc) { |
308 // no fractional part in src, we can just call drawBitmap | 314 // no fractional part in src, we can just call drawBitmap |
309 goto USE_DRAWBITMAP; | 315 goto USE_DRAWBITMAP; |
310 } | 316 } |
311 } else { | 317 } else { |
312 USE_DRAWBITMAP: | 318 USE_DRAWBITMAP: |
313 // We can go faster by just calling drawBitmap, which will concat the | 319 // We can go faster by just calling drawBitmap, which will concat the |
314 // matrix with the CTM, and try to call drawSprite if it can. If not, | 320 // matrix with the CTM, and try to call drawSprite if it can. If not, |
315 // it will make a shader and call drawRect, as we do below. | 321 // it will make a shader and call drawRect, as we do below. |
316 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); | 322 draw.drawBitmap(*bitmapPtr, matrix, dstPtr, paint); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 paint.getRasterizer() || | 387 paint.getRasterizer() || |
382 paint.getPathEffect() || | 388 paint.getPathEffect() || |
383 paint.isFakeBoldText() || | 389 paint.isFakeBoldText() || |
384 paint.getStyle() != SkPaint::kFill_Style || | 390 paint.getStyle() != SkPaint::kFill_Style || |
385 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 391 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
386 { | 392 { |
387 return true; | 393 return true; |
388 } | 394 } |
389 return false; | 395 return false; |
390 } | 396 } |
OLD | NEW |