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

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

Issue 803913005: Remove SkCanvas::isDrawingToLayer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: init fix Created 6 years 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/utils/SkDeferredCanvas.h ('k') | src/core/SkPictureRecord.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 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasDrawable.h" 9 #include "SkCanvasDrawable.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 //////////////////////////////////////////////////////////////////////////// 409 ////////////////////////////////////////////////////////////////////////////
410 410
411 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { 411 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
412 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; 412 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ;
413 fCachedLocalClipBounds.setEmpty(); 413 fCachedLocalClipBounds.setEmpty();
414 fCachedLocalClipBoundsDirty = true; 414 fCachedLocalClipBoundsDirty = true;
415 fAllowSoftClip = true; 415 fAllowSoftClip = true;
416 fAllowSimplifyClip = false; 416 fAllowSimplifyClip = false;
417 fDeviceCMDirty = true; 417 fDeviceCMDirty = true;
418 fSaveCount = 1; 418 fSaveCount = 1;
419 fSaveLayerCount = 0;
420 fMetaData = NULL; 419 fMetaData = NULL;
421 420
422 fMCRec = (MCRec*)fMCStack.push_back(); 421 fMCRec = (MCRec*)fMCStack.push_back();
423 new (fMCRec) MCRec(fConservativeRasterClip); 422 new (fMCRec) MCRec(fConservativeRasterClip);
424 423
425 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip)); 424 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL, fConservative RasterClip));
426 fMCRec->fTopLayer = fMCRec->fLayer; 425 fMCRec->fTopLayer = fMCRec->fLayer;
427 426
428 fSurfaceBase = NULL; 427 fSurfaceBase = NULL;
429 428
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 { 519 {
521 inc_canvas(); 520 inc_canvas();
522 521
523 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); 522 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
524 this->init(device, kDefault_InitFlags); 523 this->init(device, kDefault_InitFlags);
525 } 524 }
526 525
527 SkCanvas::~SkCanvas() { 526 SkCanvas::~SkCanvas() {
528 // free up the contents of our deque 527 // free up the contents of our deque
529 this->restoreToCount(1); // restore everything but the last 528 this->restoreToCount(1); // restore everything but the last
530 SkASSERT(0 == fSaveLayerCount);
531 529
532 this->internalRestore(); // restore the last, since we're going away 530 this->internalRestore(); // restore the last, since we're going away
533 531
534 SkDELETE(fMetaData); 532 SkDELETE(fMetaData);
535 533
536 dec_canvas(); 534 dec_canvas();
537 } 535 }
538 536
539 SkDrawFilter* SkCanvas::getDrawFilter() const { 537 SkDrawFilter* SkCanvas::getDrawFilter() const {
540 return fMCRec->fFilter; 538 return fMCRec->fFilter;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 } 981 }
984 982
985 device->setOrigin(ir.fLeft, ir.fTop); 983 device->setOrigin(ir.fLeft, ir.fTop);
986 DeviceCM* layer = SkNEW_ARGS(DeviceCM, 984 DeviceCM* layer = SkNEW_ARGS(DeviceCM,
987 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip)); 985 (device, ir.fLeft, ir.fTop, paint, this, fConse rvativeRasterClip));
988 device->unref(); 986 device->unref();
989 987
990 layer->fNext = fMCRec->fTopLayer; 988 layer->fNext = fMCRec->fTopLayer;
991 fMCRec->fLayer = layer; 989 fMCRec->fLayer = layer;
992 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer 990 fMCRec->fTopLayer = layer; // this field is NOT an owner of layer
993
994 fSaveLayerCount += 1;
995 } 991 }
996 992
997 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) { 993 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) {
998 return this->saveLayerAlpha(bounds, alpha, kARGB_ClipLayer_SaveFlag); 994 return this->saveLayerAlpha(bounds, alpha, kARGB_ClipLayer_SaveFlag);
999 } 995 }
1000 996
1001 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha, 997 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
1002 SaveFlags flags) { 998 SaveFlags flags) {
1003 if (0xFF == alpha) { 999 if (0xFF == alpha) {
1004 return this->saveLayer(bounds, NULL, flags); 1000 return this->saveLayer(bounds, NULL, flags);
(...skipping 26 matching lines...) Expand all
1031 since if we're being recorded, we don't want to record this (the 1027 since if we're being recorded, we don't want to record this (the
1032 recorder will have already recorded the restore). 1028 recorder will have already recorded the restore).
1033 */ 1029 */
1034 if (layer) { 1030 if (layer) {
1035 if (layer->fNext) { 1031 if (layer->fNext) {
1036 const SkIPoint& origin = layer->fDevice->getOrigin(); 1032 const SkIPoint& origin = layer->fDevice->getOrigin();
1037 this->internalDrawDevice(layer->fDevice, origin.x(), origin.y(), 1033 this->internalDrawDevice(layer->fDevice, origin.x(), origin.y(),
1038 layer->fPaint); 1034 layer->fPaint);
1039 // reset this, since internalDrawDevice will have set it to true 1035 // reset this, since internalDrawDevice will have set it to true
1040 fDeviceCMDirty = true; 1036 fDeviceCMDirty = true;
1041
1042 SkASSERT(fSaveLayerCount > 0);
1043 fSaveLayerCount -= 1;
1044 } 1037 }
1045 SkDELETE(layer); 1038 SkDELETE(layer);
1046 } 1039 }
1047 } 1040 }
1048 1041
1049 bool SkCanvas::isDrawingToLayer() const {
1050 return fSaveLayerCount > 0;
1051 }
1052
1053 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 1042 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
1054 if (NULL == props) { 1043 if (NULL == props) {
1055 props = &fProps; 1044 props = &fProps;
1056 } 1045 }
1057 return this->onNewSurface(info, *props); 1046 return this->onNewSurface(info, *props);
1058 } 1047 }
1059 1048
1060 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) { 1049 SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
1061 SkBaseDevice* dev = this->getDevice(); 1050 SkBaseDevice* dev = this->getDevice();
1062 return dev ? dev->newSurface(info, props) : NULL; 1051 return dev ? dev->newSurface(info, props) : NULL;
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 } 2491 }
2503 2492
2504 if (matrix) { 2493 if (matrix) {
2505 canvas->concat(*matrix); 2494 canvas->concat(*matrix);
2506 } 2495 }
2507 } 2496 }
2508 2497
2509 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2498 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2510 fCanvas->restoreToCount(fSaveCount); 2499 fCanvas->restoreToCount(fSaveCount);
2511 } 2500 }
OLDNEW
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698