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 | 8 |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2390 /////////////////////////////////////////////////////////////////////////////// | 2390 /////////////////////////////////////////////////////////////////////////////// |
2391 void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) { | 2391 void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) { |
2392 SkBaseDevice* device = this->getDevice(); | 2392 SkBaseDevice* device = this->getDevice(); |
2393 if (NULL != device) { | 2393 if (NULL != device) { |
2394 device->EXPERIMENTAL_optimize(picture); | 2394 device->EXPERIMENTAL_optimize(picture); |
2395 } | 2395 } |
2396 } | 2396 } |
2397 | 2397 |
2398 void SkCanvas::drawPicture(const SkPicture* picture) { | 2398 void SkCanvas::drawPicture(const SkPicture* picture) { |
2399 if (NULL != picture) { | 2399 if (NULL != picture) { |
2400 this->onDrawPicture(picture); | 2400 this->onDrawPicture(picture, NULL, NULL); |
2401 } | 2401 } |
2402 } | 2402 } |
2403 | 2403 |
2404 void SkCanvas::onDrawPicture(const SkPicture* picture) { | 2404 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) { |
2405 SkASSERT(NULL != picture); | 2405 if (NULL != picture) { |
2406 if (matrix && matrix->isIdentity()) { | |
bsalomon
2014/08/08 13:49:38
What is this saving? Don't most of our matrix meth
reed1
2014/08/08 13:57:29
save()/restore()
bsalomon
2014/08/08 13:59:42
Ah, that makes sense!
| |
2407 matrix = NULL; | |
2408 } | |
2409 this->onDrawPicture(picture, matrix, paint); | |
2410 } | |
2411 } | |
2412 | |
2413 void SkCanvas::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) { | |
2414 SkASSERT(NULL != pic); | |
robertphillips
2014/08/08 14:59:53
I think the save/saveLayer needs to be moved to af
| |
2415 | |
robertphillips
2014/08/08 14:59:53
Move bounds computation into "if (paint) {" block
| |
2416 SkRect bounds = SkRect::MakeWH(SkIntToScalar(pic->width()), SkIntToScalar(pi c->height())); | |
2417 if (matrix) { | |
2418 matrix->mapRect(&bounds); | |
2419 } | |
2420 | |
2421 SkAutoCanvasRestore acr(this, false); | |
2422 | |
2423 if (paint) { | |
2424 this->SkCanvas::saveLayer(&bounds, paint); | |
2425 } else if (matrix) { | |
2426 this->SkCanvas::save(); | |
2427 } | |
2428 | |
2429 if (matrix) { | |
2430 this->SkCanvas::concat(*matrix); | |
2431 } | |
2406 | 2432 |
2407 SkBaseDevice* device = this->getTopDevice(); | 2433 SkBaseDevice* device = this->getTopDevice(); |
2408 if (NULL != device) { | 2434 if (NULL != device) { |
2409 // Canvas has to first give the device the opportunity to render | 2435 // Canvas has to first give the device the opportunity to render |
2410 // the picture itself. | 2436 // the picture itself. |
robertphillips
2014/08/08 15:01:18
Can we add matrix & paint to this too?
| |
2411 if (device->EXPERIMENTAL_drawPicture(this, picture)) { | 2437 if (device->EXPERIMENTAL_drawPicture(this, pic)) { |
2412 return; // the device has rendered the entire picture | 2438 return; // the device has rendered the entire picture |
2413 } | 2439 } |
2414 } | 2440 } |
2415 | 2441 pic->draw(this); |
2416 picture->draw(this); | |
2417 } | 2442 } |
2418 | 2443 |
2419 /////////////////////////////////////////////////////////////////////////////// | 2444 /////////////////////////////////////////////////////////////////////////////// |
2420 /////////////////////////////////////////////////////////////////////////////// | 2445 /////////////////////////////////////////////////////////////////////////////// |
2421 | 2446 |
2422 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { | 2447 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { |
2423 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small ); | 2448 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small ); |
2424 | 2449 |
2425 SkASSERT(canvas); | 2450 SkASSERT(canvas); |
2426 | 2451 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2504 if (!supported_for_raster_canvas(info)) { | 2529 if (!supported_for_raster_canvas(info)) { |
2505 return NULL; | 2530 return NULL; |
2506 } | 2531 } |
2507 | 2532 |
2508 SkBitmap bitmap; | 2533 SkBitmap bitmap; |
2509 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2534 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
2510 return NULL; | 2535 return NULL; |
2511 } | 2536 } |
2512 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2537 return SkNEW_ARGS(SkCanvas, (bitmap)); |
2513 } | 2538 } |
OLD | NEW |