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

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

Issue 1118693003: add heuristic to pour small pictures into recordings, rather than ref'ing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move check into SkCanvas non-virtual Created 5 years, 7 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 | « include/core/SkCanvas.h ('k') | tests/PictureTest.cpp » ('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 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasPriv.h" 9 #include "SkCanvasPriv.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 const SkPath& path, SkScalar hOffset, 2501 const SkPath& path, SkScalar hOffset,
2502 SkScalar vOffset, const SkPaint& paint) { 2502 SkScalar vOffset, const SkPaint& paint) {
2503 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextOnPathHV()"); 2503 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextOnPathHV()");
2504 SkMatrix matrix; 2504 SkMatrix matrix;
2505 2505
2506 matrix.setTranslate(hOffset, vOffset); 2506 matrix.setTranslate(hOffset, vOffset);
2507 this->drawTextOnPath(text, byteLength, path, &matrix, paint); 2507 this->drawTextOnPath(text, byteLength, path, &matrix, paint);
2508 } 2508 }
2509 2509
2510 /////////////////////////////////////////////////////////////////////////////// 2510 ///////////////////////////////////////////////////////////////////////////////
2511 void SkCanvas::drawPicture(const SkPicture* picture) { 2511
2512 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()"); 2512 /**
2513 if (picture) { 2513 * This constant is trying to balance the speed of ref'ing a subpicture into a parent picture,
2514 this->onDrawPicture(picture, NULL, NULL); 2514 * against the playback cost of recursing into the subpicture to get at its act ual ops.
2515 } 2515 *
2516 } 2516 * For now we pick a conservatively small value, though measurement (and other heuristics like
2517 * the type of ops contained) may justify changing this value.
2518 */
2519 #define kMaxPictureOpsToUnrollInsteadOfRef 1
2517 2520
2518 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) { 2521 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) {
2519 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture(SkMatrix, Sk Paint)"); 2522 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()");
2520 if (picture) { 2523 if (picture) {
2521 if (matrix && matrix->isIdentity()) { 2524 if (matrix && matrix->isIdentity()) {
2522 matrix = NULL; 2525 matrix = NULL;
2523 } 2526 }
2524 this->onDrawPicture(picture, matrix, paint); 2527 if (picture->approximateOpCount() <= kMaxPictureOpsToUnrollInsteadOfRef) {
2528 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect( ));
2529 picture->playback(this);
2530 } else {
2531 this->onDrawPicture(picture, matrix, paint);
2532 }
2525 } 2533 }
2526 } 2534 }
2527 2535
2528 void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, 2536 void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
2529 const SkPaint* paint) { 2537 const SkPaint* paint) {
2530 SkBaseDevice* device = this->getTopDevice(); 2538 SkBaseDevice* device = this->getTopDevice();
2531 if (device) { 2539 if (device) {
2532 // Canvas has to first give the device the opportunity to render 2540 // Canvas has to first give the device the opportunity to render
2533 // the picture itself. 2541 // the picture itself.
2534 if (device->EXPERIMENTAL_drawPicture(this, picture, matrix, paint)) { 2542 if (device->EXPERIMENTAL_drawPicture(this, picture, matrix, paint)) {
2535 return; // the device has rendered the entire picture 2543 return; // the device has rendered the entire picture
2536 } 2544 }
2537 } 2545 }
2538 2546
2539 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); 2547 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect());
2540
2541 picture->playback(this); 2548 picture->playback(this);
2542 } 2549 }
2543 2550
2544 /////////////////////////////////////////////////////////////////////////////// 2551 ///////////////////////////////////////////////////////////////////////////////
2545 /////////////////////////////////////////////////////////////////////////////// 2552 ///////////////////////////////////////////////////////////////////////////////
2546 2553
2547 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { 2554 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) {
2548 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small ); 2555 SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small );
2549 2556
2550 SkASSERT(canvas); 2557 SkASSERT(canvas);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 } 2645 }
2639 2646
2640 if (matrix) { 2647 if (matrix) {
2641 canvas->concat(*matrix); 2648 canvas->concat(*matrix);
2642 } 2649 }
2643 } 2650 }
2644 2651
2645 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2652 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2646 fCanvas->restoreToCount(fSaveCount); 2653 fCanvas->restoreToCount(fSaveCount);
2647 } 2654 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698