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

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: more dummies so we can land 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
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkCanvasPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkCanvasPriv.h"
10 #include "SkBitmapDevice.h" 11 #include "SkBitmapDevice.h"
11 #include "SkDeviceImageFilterProxy.h" 12 #include "SkDeviceImageFilterProxy.h"
12 #include "SkDraw.h" 13 #include "SkDraw.h"
13 #include "SkDrawFilter.h" 14 #include "SkDrawFilter.h"
14 #include "SkDrawLooper.h" 15 #include "SkDrawLooper.h"
15 #include "SkMetaData.h" 16 #include "SkMetaData.h"
16 #include "SkPathOps.h" 17 #include "SkPathOps.h"
17 #include "SkPicture.h" 18 #include "SkPicture.h"
18 #include "SkRasterClip.h" 19 #include "SkRasterClip.h"
19 #include "SkRRect.h" 20 #include "SkRRect.h"
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 /////////////////////////////////////////////////////////////////////////////// 2391 ///////////////////////////////////////////////////////////////////////////////
2391 void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) { 2392 void SkCanvas::EXPERIMENTAL_optimize(const SkPicture* picture) {
2392 SkBaseDevice* device = this->getDevice(); 2393 SkBaseDevice* device = this->getDevice();
2393 if (NULL != device) { 2394 if (NULL != device) {
2394 device->EXPERIMENTAL_optimize(picture); 2395 device->EXPERIMENTAL_optimize(picture);
2395 } 2396 }
2396 } 2397 }
2397 2398
2398 void SkCanvas::drawPicture(const SkPicture* picture) { 2399 void SkCanvas::drawPicture(const SkPicture* picture) {
2399 if (NULL != picture) { 2400 if (NULL != picture) {
2400 this->onDrawPicture(picture); 2401 this->onDrawPicture(picture, NULL, NULL);
2401 } 2402 }
2402 } 2403 }
2403 2404
2404 void SkCanvas::onDrawPicture(const SkPicture* picture) { 2405 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) {
2405 SkASSERT(NULL != picture); 2406 if (NULL != picture) {
2407 if (matrix && matrix->isIdentity()) {
2408 matrix = NULL;
2409 }
2410 this->onDrawPicture(picture, matrix, paint);
2411 }
2412 }
2406 2413
2414 void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
2415 const SkPaint* paint) {
2407 SkBaseDevice* device = this->getTopDevice(); 2416 SkBaseDevice* device = this->getTopDevice();
2408 if (NULL != device) { 2417 if (NULL != device) {
2409 // Canvas has to first give the device the opportunity to render 2418 // Canvas has to first give the device the opportunity to render
2410 // the picture itself. 2419 // the picture itself.
2411 if (device->EXPERIMENTAL_drawPicture(this, picture)) { 2420 if (device->EXPERIMENTAL_drawPicture(this, picture, matrix, paint)) {
2412 return; // the device has rendered the entire picture 2421 return; // the device has rendered the entire picture
2413 } 2422 }
2414 } 2423 }
2415 2424
2425 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->width(), picture- >height());
2426
2416 picture->draw(this); 2427 picture->draw(this);
2417 } 2428 }
2418 2429
2419 /////////////////////////////////////////////////////////////////////////////// 2430 ///////////////////////////////////////////////////////////////////////////////
2420 /////////////////////////////////////////////////////////////////////////////// 2431 ///////////////////////////////////////////////////////////////////////////////
2421 2432
2422 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { 2433 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) {
2423 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small ); 2434 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small );
2424 2435
2425 SkASSERT(canvas); 2436 SkASSERT(canvas);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 if (!supported_for_raster_canvas(info)) { 2515 if (!supported_for_raster_canvas(info)) {
2505 return NULL; 2516 return NULL;
2506 } 2517 }
2507 2518
2508 SkBitmap bitmap; 2519 SkBitmap bitmap;
2509 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2520 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2510 return NULL; 2521 return NULL;
2511 } 2522 }
2512 return SkNEW_ARGS(SkCanvas, (bitmap)); 2523 return SkNEW_ARGS(SkCanvas, (bitmap));
2513 } 2524 }
2525
2526 ///////////////////////////////////////////////////////////////////////////////
2527
2528 SkAutoCanvasMatrixPaint::SkAutoCanvasMatrixPaint(SkCanvas* canvas, const SkMatri x* matrix,
2529 const SkPaint* paint, int width , int height)
2530 : fCanvas(canvas)
2531 , fSaveCount(canvas->getSaveCount())
2532 {
2533 if (NULL != paint) {
2534 SkRect bounds = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh t));
2535 if (matrix) {
2536 matrix->mapRect(&bounds);
2537 }
2538 canvas->saveLayer(&bounds, paint);
2539 } else if (NULL != matrix) {
2540 canvas->save();
2541 }
2542
2543 if (NULL != matrix) {
2544 canvas->concat(*matrix);
2545 }
2546 }
2547
2548 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2549 fCanvas->restoreToCount(fSaveCount);
2550 }
OLDNEW
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkCanvasPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698