OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 2239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 iter.fDevice->drawImage(iter, image, x, y, pnt); | 2250 iter.fDevice->drawImage(iter, image, x, y, pnt); |
2251 } | 2251 } |
2252 } | 2252 } |
2253 | 2253 |
2254 LOOPER_END | 2254 LOOPER_END |
2255 } | 2255 } |
2256 | 2256 |
2257 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, | 2257 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, |
2258 const SkPaint* paint, SrcRectConstraint constrain
t) { | 2258 const SkPaint* paint, SrcRectConstraint constrain
t) { |
2259 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); | 2259 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); |
2260 SkRect storage; | |
2261 const SkRect* bounds = &dst; | |
2262 if (nullptr == paint || paint->canComputeFastBounds()) { | 2260 if (nullptr == paint || paint->canComputeFastBounds()) { |
2263 storage = dst; | 2261 SkRect storage = dst; |
2264 if (paint) { | 2262 if (paint) { |
2265 paint->computeFastBounds(dst, &storage); | 2263 paint->computeFastBounds(dst, &storage); |
2266 } | 2264 } |
2267 if (this->quickReject(storage)) { | 2265 if (this->quickReject(storage)) { |
2268 return; | 2266 return; |
2269 } | 2267 } |
2270 } | 2268 } |
2271 SkLazyPaint lazy; | 2269 SkLazyPaint lazy; |
2272 if (nullptr == paint) { | 2270 if (nullptr == paint) { |
2273 paint = lazy.init(); | 2271 paint = lazy.init(); |
2274 } | 2272 } |
2275 | 2273 |
2276 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, bo
unds, | 2274 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &d
st, |
2277 image->isOpaque()) | 2275 image->isOpaque()) |
2278 | 2276 |
2279 while (iter.next()) { | 2277 while (iter.next()) { |
2280 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const
raint); | 2278 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const
raint); |
2281 } | 2279 } |
2282 | 2280 |
2283 LOOPER_END | 2281 LOOPER_END |
2284 } | 2282 } |
2285 | 2283 |
2286 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { | 2284 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 } | 2329 } |
2332 | 2330 |
2333 // this one is non-virtual, so it can be called safely by other canvas apis | 2331 // this one is non-virtual, so it can be called safely by other canvas apis |
2334 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 2332 void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
2335 const SkRect& dst, const SkPaint* paint, | 2333 const SkRect& dst, const SkPaint* paint, |
2336 SrcRectConstraint constraint) { | 2334 SrcRectConstraint constraint) { |
2337 if (bitmap.drawsNothing() || dst.isEmpty()) { | 2335 if (bitmap.drawsNothing() || dst.isEmpty()) { |
2338 return; | 2336 return; |
2339 } | 2337 } |
2340 | 2338 |
2341 SkRect storage; | |
2342 const SkRect* bounds = &dst; | |
2343 if (nullptr == paint || paint->canComputeFastBounds()) { | 2339 if (nullptr == paint || paint->canComputeFastBounds()) { |
| 2340 SkRect storage; |
2344 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { | 2341 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
2345 return; | 2342 return; |
2346 } | 2343 } |
2347 } | 2344 } |
2348 | 2345 |
2349 SkLazyPaint lazy; | 2346 SkLazyPaint lazy; |
2350 if (nullptr == paint) { | 2347 if (nullptr == paint) { |
2351 paint = lazy.init(); | 2348 paint = lazy.init(); |
2352 } | 2349 } |
2353 | 2350 |
2354 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, bo
unds, | 2351 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &d
st, |
2355 bitmap.isOpaque()) | 2352 bitmap.isOpaque()) |
2356 | 2353 |
2357 while (iter.next()) { | 2354 while (iter.next()) { |
2358 iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(), con
straint); | 2355 iter.fDevice->drawBitmapRect(iter, bitmap, src, dst, looper.paint(), con
straint); |
2359 } | 2356 } |
2360 | 2357 |
2361 LOOPER_END | 2358 LOOPER_END |
2362 } | 2359 } |
2363 | 2360 |
2364 void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const
SkRect& dst, | 2361 void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const
SkRect& dst, |
2365 const SkPaint* paint, SrcRectConstraint constrai
nt) { | 2362 const SkPaint* paint, SrcRectConstraint constrai
nt) { |
2366 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()")
; | 2363 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()")
; |
2367 SkDEBUGCODE(bitmap.validate();) | 2364 SkDEBUGCODE(bitmap.validate();) |
2368 this->internalDrawBitmapRect(bitmap, src, dst, paint, constraint); | 2365 this->internalDrawBitmapRect(bitmap, src, dst, paint, constraint); |
2369 } | 2366 } |
2370 | 2367 |
2371 void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons
t SkRect& dst, | 2368 void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons
t SkRect& dst, |
2372 const SkPaint* paint) { | 2369 const SkPaint* paint) { |
2373 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageNine()"); | 2370 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageNine()"); |
2374 | 2371 |
2375 SkRect storage; | |
2376 const SkRect* bounds = &dst; | |
2377 if (nullptr == paint || paint->canComputeFastBounds()) { | 2372 if (nullptr == paint || paint->canComputeFastBounds()) { |
| 2373 SkRect storage; |
2378 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { | 2374 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
2379 return; | 2375 return; |
2380 } | 2376 } |
2381 } | 2377 } |
2382 | 2378 |
2383 SkLazyPaint lazy; | 2379 SkLazyPaint lazy; |
2384 if (nullptr == paint) { | 2380 if (nullptr == paint) { |
2385 paint = lazy.init(); | 2381 paint = lazy.init(); |
2386 } | 2382 } |
2387 | 2383 |
2388 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds) | 2384 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
2389 | 2385 |
2390 while (iter.next()) { | 2386 while (iter.next()) { |
2391 iter.fDevice->drawImageNine(iter, image, center, dst, looper.paint()); | 2387 iter.fDevice->drawImageNine(iter, image, center, dst, looper.paint()); |
2392 } | 2388 } |
2393 | 2389 |
2394 LOOPER_END | 2390 LOOPER_END |
2395 } | 2391 } |
2396 | 2392 |
2397 void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, c
onst SkRect& dst, | 2393 void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, c
onst SkRect& dst, |
2398 const SkPaint* paint) { | 2394 const SkPaint* paint) { |
2399 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapNine()"); | 2395 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapNine()"); |
2400 SkDEBUGCODE(bitmap.validate();) | 2396 SkDEBUGCODE(bitmap.validate();) |
2401 | 2397 |
2402 SkRect storage; | |
2403 const SkRect* bounds = &dst; | |
2404 if (nullptr == paint || paint->canComputeFastBounds()) { | 2398 if (nullptr == paint || paint->canComputeFastBounds()) { |
| 2399 SkRect storage; |
2405 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { | 2400 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
2406 return; | 2401 return; |
2407 } | 2402 } |
2408 } | 2403 } |
2409 | 2404 |
2410 SkLazyPaint lazy; | 2405 SkLazyPaint lazy; |
2411 if (nullptr == paint) { | 2406 if (nullptr == paint) { |
2412 paint = lazy.init(); | 2407 paint = lazy.init(); |
2413 } | 2408 } |
2414 | 2409 |
2415 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds) | 2410 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
2416 | 2411 |
2417 while (iter.next()) { | 2412 while (iter.next()) { |
2418 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); | 2413 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); |
2419 } | 2414 } |
2420 | 2415 |
2421 LOOPER_END | 2416 LOOPER_END |
2422 } | 2417 } |
2423 | 2418 |
2424 class SkDeviceFilteredPaint { | 2419 class SkDeviceFilteredPaint { |
2425 public: | 2420 public: |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 } | 2998 } |
3004 | 2999 |
3005 if (matrix) { | 3000 if (matrix) { |
3006 canvas->concat(*matrix); | 3001 canvas->concat(*matrix); |
3007 } | 3002 } |
3008 } | 3003 } |
3009 | 3004 |
3010 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3005 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3011 fCanvas->restoreToCount(fSaveCount); | 3006 fCanvas->restoreToCount(fSaveCount); |
3012 } | 3007 } |
OLD | NEW |