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 |
138 void updateMC(const SkMatrix& totalMatrix, const SkRasterClip& totalClip, | 145 void updateMC(const SkMatrix& totalMatrix, const SkRasterClip& totalClip, |
139 const SkClipStack& clipStack, SkRasterClip* updateClip) { | 146 const SkClipStack& clipStack, SkRasterClip* updateClip) { |
140 int x = fDevice->getOrigin().x(); | 147 int x = fDevice->getOrigin().x(); |
141 int y = fDevice->getOrigin().y(); | 148 int y = fDevice->getOrigin().y(); |
142 int width = fDevice->width(); | 149 int width = fDevice->width(); |
143 int height = fDevice->height(); | 150 int height = fDevice->height(); |
144 | 151 |
145 if ((x | y) == 0) { | 152 if ((x | y) == 0) { |
146 fMatrix = &totalMatrix; | 153 fMatrix = &totalMatrix; |
147 fClip = totalClip; | 154 fClip = totalClip; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 fDeferredSaveCount = 0; | 224 fDeferredSaveCount = 0; |
218 | 225 |
219 // don't bother initializing fNext | 226 // don't bother initializing fNext |
220 inc_rec(); | 227 inc_rec(); |
221 } | 228 } |
222 ~MCRec() { | 229 ~MCRec() { |
223 SkSafeUnref(fFilter); | 230 SkSafeUnref(fFilter); |
224 SkDELETE(fLayer); | 231 SkDELETE(fLayer); |
225 dec_rec(); | 232 dec_rec(); |
226 } | 233 } |
| 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 } |
227 }; | 243 }; |
228 | 244 |
229 class SkDrawIter : public SkDraw { | 245 class SkDrawIter : public SkDraw { |
230 public: | 246 public: |
231 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { | 247 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { |
232 canvas = canvas->canvasForDrawIter(); | 248 canvas = canvas->canvasForDrawIter(); |
233 fCanvas = canvas; | 249 fCanvas = canvas; |
234 canvas->updateDeviceCMCache(); | 250 canvas->updateDeviceCMCache(); |
235 | 251 |
236 fClipStack = canvas->fClipStack; | 252 fClipStack = canvas->fClipStack; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 #define LOOPER_BEGIN(paint, type, bounds) \ | 434 #define LOOPER_BEGIN(paint, type, bounds) \ |
419 this->predrawNotify(); \ | 435 this->predrawNotify(); \ |
420 AutoDrawLooper looper(this, fProps, paint, false, bounds); \ | 436 AutoDrawLooper looper(this, fProps, paint, false, bounds); \ |
421 while (looper.next(type)) { \ | 437 while (looper.next(type)) { \ |
422 SkDrawIter iter(this); | 438 SkDrawIter iter(this); |
423 | 439 |
424 #define LOOPER_END } | 440 #define LOOPER_END } |
425 | 441 |
426 //////////////////////////////////////////////////////////////////////////// | 442 //////////////////////////////////////////////////////////////////////////// |
427 | 443 |
| 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 |
428 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { | 456 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
429 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag)
; | 457 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag)
; |
430 fCachedLocalClipBounds.setEmpty(); | 458 fCachedLocalClipBounds.setEmpty(); |
431 fCachedLocalClipBoundsDirty = true; | 459 fCachedLocalClipBoundsDirty = true; |
432 fAllowSoftClip = true; | 460 fAllowSoftClip = true; |
433 fAllowSimplifyClip = false; | 461 fAllowSimplifyClip = false; |
434 fDeviceCMDirty = true; | 462 fDeviceCMDirty = true; |
435 fSaveCount = 1; | 463 fSaveCount = 1; |
436 fMetaData = NULL; | 464 fMetaData = NULL; |
437 | 465 |
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 } | 2547 } |
2520 | 2548 |
2521 if (matrix) { | 2549 if (matrix) { |
2522 canvas->concat(*matrix); | 2550 canvas->concat(*matrix); |
2523 } | 2551 } |
2524 } | 2552 } |
2525 | 2553 |
2526 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2554 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2527 fCanvas->restoreToCount(fSaveCount); | 2555 fCanvas->restoreToCount(fSaveCount); |
2528 } | 2556 } |
OLD | NEW |