| 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 const SkMatrix* fMatrix; | 200 const SkMatrix* fMatrix; |
| 201 SkMatrix fMatrixStorage; | 201 SkMatrix fMatrixStorage; |
| 202 SkMatrix fStashedMatrix; // original CTM; used by imagefilter in
saveLayer | 202 SkMatrix fStashedMatrix; // original CTM; used by imagefilter in
saveLayer |
| 203 | 203 |
| 204 DeviceCM(SkBaseDevice* device, const SkPaint* paint, SkCanvas* canvas, | 204 DeviceCM(SkBaseDevice* device, const SkPaint* paint, SkCanvas* canvas, |
| 205 bool conservativeRasterClip, const SkMatrix& stashed) | 205 bool conservativeRasterClip, const SkMatrix& stashed) |
| 206 : fNext(nullptr) | 206 : fNext(nullptr) |
| 207 , fClip(conservativeRasterClip) | 207 , fClip(conservativeRasterClip) |
| 208 , fStashedMatrix(stashed) | 208 , fStashedMatrix(stashed) |
| 209 { | 209 { |
| 210 if (nullptr != device) { | 210 SkSafeRef(device); |
| 211 device->ref(); | |
| 212 device->onAttachToCanvas(canvas); | |
| 213 } | |
| 214 fDevice = device; | 211 fDevice = device; |
| 215 fPaint = paint ? new SkPaint(*paint) : nullptr; | 212 fPaint = paint ? new SkPaint(*paint) : nullptr; |
| 216 } | 213 } |
| 217 | 214 |
| 218 ~DeviceCM() { | 215 ~DeviceCM() { |
| 219 if (fDevice) { | 216 SkSafeUnref(fDevice); |
| 220 fDevice->onDetachFromCanvas(); | |
| 221 fDevice->unref(); | |
| 222 } | |
| 223 delete fPaint; | 217 delete fPaint; |
| 224 } | 218 } |
| 225 | 219 |
| 226 void reset(const SkIRect& bounds) { | 220 void reset(const SkIRect& bounds) { |
| 227 SkASSERT(!fPaint); | 221 SkASSERT(!fPaint); |
| 228 SkASSERT(!fNext); | 222 SkASSERT(!fNext); |
| 229 SkASSERT(fDevice); | 223 SkASSERT(fDevice); |
| 230 fClip.setRect(bounds); | 224 fClip.setRect(bounds); |
| 231 } | 225 } |
| 232 | 226 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 new (fDeviceCMStorage) DeviceCM(nullptr, nullptr, nullptr, fConservativeRast
erClip, | 671 new (fDeviceCMStorage) DeviceCM(nullptr, nullptr, nullptr, fConservativeRast
erClip, |
| 678 fMCRec->fMatrix); | 672 fMCRec->fMatrix); |
| 679 | 673 |
| 680 fMCRec->fTopLayer = fMCRec->fLayer; | 674 fMCRec->fTopLayer = fMCRec->fLayer; |
| 681 | 675 |
| 682 fSurfaceBase = nullptr; | 676 fSurfaceBase = nullptr; |
| 683 | 677 |
| 684 if (device) { | 678 if (device) { |
| 685 // The root device and the canvas should always have the same pixel geom
etry | 679 // The root device and the canvas should always have the same pixel geom
etry |
| 686 SkASSERT(fProps.pixelGeometry() == device->surfaceProps().pixelGeometry(
)); | 680 SkASSERT(fProps.pixelGeometry() == device->surfaceProps().pixelGeometry(
)); |
| 687 device->onAttachToCanvas(this); | |
| 688 fMCRec->fLayer->fDevice = SkRef(device); | 681 fMCRec->fLayer->fDevice = SkRef(device); |
| 689 fMCRec->fRasterClip.setRect(device->getGlobalBounds()); | 682 fMCRec->fRasterClip.setRect(device->getGlobalBounds()); |
| 690 } | 683 } |
| 691 return device; | 684 return device; |
| 692 } | 685 } |
| 693 | 686 |
| 694 SkCanvas::SkCanvas() | 687 SkCanvas::SkCanvas() |
| 695 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) | 688 : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) |
| 696 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) | 689 , fProps(SkSurfaceProps::kLegacyFontHost_InitType) |
| 697 , fConservativeRasterClip(false) | 690 , fConservativeRasterClip(false) |
| (...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3134 | 3127 |
| 3135 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3128 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3136 fCanvas->restoreToCount(fSaveCount); | 3129 fCanvas->restoreToCount(fSaveCount); |
| 3137 } | 3130 } |
| 3138 | 3131 |
| 3139 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3132 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
| 3140 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3133 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
| 3141 return this->makeSurface(info, props).release(); | 3134 return this->makeSurface(info, props).release(); |
| 3142 } | 3135 } |
| 3143 #endif | 3136 #endif |
| OLD | NEW |