Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: src/core/SkCanvas.cpp

Issue 448793004: add drawPicture variant that takes a matrix and paint (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()) {
mtklein 2014/08/07 21:25:20 Sort of weird? Can't we just not do this?
reed1 2014/08/08 13:57:29 Possibly, though null saves us having to do a save
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);
2415
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.
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698