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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 one that is at or below this level in the stack (so we know what | 287 one that is at or below this level in the stack (so we know what |
288 bitmap/device to draw into from this level. This value is NOT | 288 bitmap/device to draw into from this level. This value is NOT |
289 reference counted, since the real owner is either our fLayer field, | 289 reference counted, since the real owner is either our fLayer field, |
290 or a previous one in a lower level.) | 290 or a previous one in a lower level.) |
291 */ | 291 */ |
292 DeviceCM* fTopLayer; | 292 DeviceCM* fTopLayer; |
293 SkRasterClip fRasterClip; | 293 SkRasterClip fRasterClip; |
294 SkMatrix fMatrix; | 294 SkMatrix fMatrix; |
295 int fDeferredSaveCount; | 295 int fDeferredSaveCount; |
296 | 296 |
297 // This is the current cumulative depth (aggregate of all done translateZ ca
lls) | |
298 SkScalar fCurDrawDepth; | |
299 | |
300 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { | 297 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { |
301 fFilter = nullptr; | 298 fFilter = nullptr; |
302 fLayer = nullptr; | 299 fLayer = nullptr; |
303 fTopLayer = nullptr; | 300 fTopLayer = nullptr; |
304 fMatrix.reset(); | 301 fMatrix.reset(); |
305 fDeferredSaveCount = 0; | 302 fDeferredSaveCount = 0; |
306 fCurDrawDepth = 0; | |
307 | 303 |
308 // don't bother initializing fNext | 304 // don't bother initializing fNext |
309 inc_rec(); | 305 inc_rec(); |
310 } | 306 } |
311 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr
ix), | 307 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr
ix) { |
312 fCurDrawDepth(prev.fCurDrawDepth) { | |
313 fFilter = SkSafeRef(prev.fFilter); | 308 fFilter = SkSafeRef(prev.fFilter); |
314 fLayer = nullptr; | 309 fLayer = nullptr; |
315 fTopLayer = prev.fTopLayer; | 310 fTopLayer = prev.fTopLayer; |
316 fDeferredSaveCount = 0; | 311 fDeferredSaveCount = 0; |
317 | 312 |
318 // don't bother initializing fNext | 313 // don't bother initializing fNext |
319 inc_rec(); | 314 inc_rec(); |
320 } | 315 } |
321 ~MCRec() { | 316 ~MCRec() { |
322 SkSafeUnref(fFilter); | 317 SkSafeUnref(fFilter); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 void SkCanvas::setMatrix(const SkMatrix& matrix) { | 1532 void SkCanvas::setMatrix(const SkMatrix& matrix) { |
1538 this->checkForDeferredSave(); | 1533 this->checkForDeferredSave(); |
1539 this->internalSetMatrix(matrix); | 1534 this->internalSetMatrix(matrix); |
1540 this->didSetMatrix(matrix); | 1535 this->didSetMatrix(matrix); |
1541 } | 1536 } |
1542 | 1537 |
1543 void SkCanvas::resetMatrix() { | 1538 void SkCanvas::resetMatrix() { |
1544 this->setMatrix(SkMatrix::I()); | 1539 this->setMatrix(SkMatrix::I()); |
1545 } | 1540 } |
1546 | 1541 |
1547 void SkCanvas::translateZ(SkScalar z) { | |
1548 this->checkForDeferredSave(); | |
1549 this->fMCRec->fCurDrawDepth += z; | |
1550 this->didTranslateZ(z); | |
1551 } | |
1552 | |
1553 SkScalar SkCanvas::getZ() const { | |
1554 return this->fMCRec->fCurDrawDepth; | |
1555 } | |
1556 | |
1557 ////////////////////////////////////////////////////////////////////////////// | 1542 ////////////////////////////////////////////////////////////////////////////// |
1558 | 1543 |
1559 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1544 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1560 if (!fAllowSoftClip) { | 1545 if (!fAllowSoftClip) { |
1561 doAA = false; | 1546 doAA = false; |
1562 } | 1547 } |
1563 | 1548 |
1564 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1549 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
1565 // Check if we can quick-accept the clip call (and do nothing) | 1550 // Check if we can quick-accept the clip call (and do nothing) |
1566 // | 1551 // |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3143 | 3128 |
3144 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3129 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3145 fCanvas->restoreToCount(fSaveCount); | 3130 fCanvas->restoreToCount(fSaveCount); |
3146 } | 3131 } |
3147 | 3132 |
3148 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3133 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3149 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3134 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3150 return this->makeSurface(info, props).release(); | 3135 return this->makeSurface(info, props).release(); |
3151 } | 3136 } |
3152 #endif | 3137 #endif |
OLD | NEW |