| 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 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 ~DeviceCM() { | 130 ~DeviceCM() { |
| 131 if (fDevice) { | 131 if (fDevice) { |
| 132 fDevice->onDetachFromCanvas(); | 132 fDevice->onDetachFromCanvas(); |
| 133 fDevice->unref(); | 133 fDevice->unref(); |
| 134 } | 134 } |
| 135 SkDELETE(fPaint); | 135 SkDELETE(fPaint); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void reset(const SkIRect& bounds) { | |
| 139 SkASSERT(!fPaint); | |
| 140 SkASSERT(!fNext); | |
| 141 SkASSERT(fDevice); | |
| 142 fClip.setRect(bounds); | |
| 143 } | |
| 144 | |
| 145 void updateMC(const SkMatrix& totalMatrix, const SkRasterClip& totalClip, | 138 void updateMC(const SkMatrix& totalMatrix, const SkRasterClip& totalClip, |
| 146 const SkClipStack& clipStack, SkRasterClip* updateClip) { | 139 const SkClipStack& clipStack, SkRasterClip* updateClip) { |
| 147 int x = fDevice->getOrigin().x(); | 140 int x = fDevice->getOrigin().x(); |
| 148 int y = fDevice->getOrigin().y(); | 141 int y = fDevice->getOrigin().y(); |
| 149 int width = fDevice->width(); | 142 int width = fDevice->width(); |
| 150 int height = fDevice->height(); | 143 int height = fDevice->height(); |
| 151 | 144 |
| 152 if ((x | y) == 0) { | 145 if ((x | y) == 0) { |
| 153 fMatrix = &totalMatrix; | 146 fMatrix = &totalMatrix; |
| 154 fClip = totalClip; | 147 fClip = totalClip; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 fDeferredSaveCount = 0; | 217 fDeferredSaveCount = 0; |
| 225 | 218 |
| 226 // don't bother initializing fNext | 219 // don't bother initializing fNext |
| 227 inc_rec(); | 220 inc_rec(); |
| 228 } | 221 } |
| 229 ~MCRec() { | 222 ~MCRec() { |
| 230 SkSafeUnref(fFilter); | 223 SkSafeUnref(fFilter); |
| 231 SkDELETE(fLayer); | 224 SkDELETE(fLayer); |
| 232 dec_rec(); | 225 dec_rec(); |
| 233 } | 226 } |
| 234 | |
| 235 void reset(const SkIRect& bounds) { | |
| 236 SkASSERT(fLayer); | |
| 237 SkASSERT(fDeferredSaveCount == 0); | |
| 238 | |
| 239 fMatrix.reset(); | |
| 240 fRasterClip.setRect(bounds); | |
| 241 fLayer->reset(bounds); | |
| 242 } | |
| 243 }; | 227 }; |
| 244 | 228 |
| 245 class SkDrawIter : public SkDraw { | 229 class SkDrawIter : public SkDraw { |
| 246 public: | 230 public: |
| 247 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { | 231 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { |
| 248 canvas = canvas->canvasForDrawIter(); | 232 canvas = canvas->canvasForDrawIter(); |
| 249 fCanvas = canvas; | 233 fCanvas = canvas; |
| 250 canvas->updateDeviceCMCache(); | 234 canvas->updateDeviceCMCache(); |
| 251 | 235 |
| 252 fClipStack = canvas->fClipStack; | 236 fClipStack = canvas->fClipStack; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 #define LOOPER_BEGIN(paint, type, bounds) \ | 418 #define LOOPER_BEGIN(paint, type, bounds) \ |
| 435 this->predrawNotify(); \ | 419 this->predrawNotify(); \ |
| 436 AutoDrawLooper looper(this, fProps, paint, false, bounds); \ | 420 AutoDrawLooper looper(this, fProps, paint, false, bounds); \ |
| 437 while (looper.next(type)) { \ | 421 while (looper.next(type)) { \ |
| 438 SkDrawIter iter(this); | 422 SkDrawIter iter(this); |
| 439 | 423 |
| 440 #define LOOPER_END } | 424 #define LOOPER_END } |
| 441 | 425 |
| 442 //////////////////////////////////////////////////////////////////////////// | 426 //////////////////////////////////////////////////////////////////////////// |
| 443 | 427 |
| 444 void SkCanvas::resetForNextPicture(const SkIRect& bounds) { | |
| 445 this->restoreToCount(1); | |
| 446 fCachedLocalClipBounds.setEmpty(); | |
| 447 fCachedLocalClipBoundsDirty = true; | |
| 448 fClipStack->reset(); | |
| 449 fMCRec->reset(bounds); | |
| 450 | |
| 451 // We're peering through a lot of structs here. Only at this scope do we | |
| 452 // know that the device is an SkBitmapDevice (really an SkNoPixelsBitmapDevi
ce). | |
| 453 static_cast<SkBitmapDevice*>(fMCRec->fLayer->fDevice)->setNewSize(bounds.siz
e()); | |
| 454 } | |
| 455 | |
| 456 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { | 428 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
| 457 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag)
; | 429 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag)
; |
| 458 fCachedLocalClipBounds.setEmpty(); | 430 fCachedLocalClipBounds.setEmpty(); |
| 459 fCachedLocalClipBoundsDirty = true; | 431 fCachedLocalClipBoundsDirty = true; |
| 460 fAllowSoftClip = true; | 432 fAllowSoftClip = true; |
| 461 fAllowSimplifyClip = false; | 433 fAllowSimplifyClip = false; |
| 462 fDeviceCMDirty = true; | 434 fDeviceCMDirty = true; |
| 463 fSaveCount = 1; | 435 fSaveCount = 1; |
| 464 fMetaData = NULL; | 436 fMetaData = NULL; |
| 465 | 437 |
| (...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 } | 2519 } |
| 2548 | 2520 |
| 2549 if (matrix) { | 2521 if (matrix) { |
| 2550 canvas->concat(*matrix); | 2522 canvas->concat(*matrix); |
| 2551 } | 2523 } |
| 2552 } | 2524 } |
| 2553 | 2525 |
| 2554 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2526 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2555 fCanvas->restoreToCount(fSaveCount); | 2527 fCanvas->restoreToCount(fSaveCount); |
| 2556 } | 2528 } |
| OLD | NEW |