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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 void SkCanvas::setMatrix(const SkMatrix& matrix) { | 1514 void SkCanvas::setMatrix(const SkMatrix& matrix) { |
1520 this->checkForDeferredSave(); | 1515 this->checkForDeferredSave(); |
1521 this->internalSetMatrix(matrix); | 1516 this->internalSetMatrix(matrix); |
1522 this->didSetMatrix(matrix); | 1517 this->didSetMatrix(matrix); |
1523 } | 1518 } |
1524 | 1519 |
1525 void SkCanvas::resetMatrix() { | 1520 void SkCanvas::resetMatrix() { |
1526 this->setMatrix(SkMatrix::I()); | 1521 this->setMatrix(SkMatrix::I()); |
1527 } | 1522 } |
1528 | 1523 |
1529 void SkCanvas::translateZ(SkScalar z) { | |
1530 this->checkForDeferredSave(); | |
1531 this->fMCRec->fCurDrawDepth += z; | |
1532 this->didTranslateZ(z); | |
1533 } | |
1534 | |
1535 SkScalar SkCanvas::getZ() const { | |
1536 return this->fMCRec->fCurDrawDepth; | |
1537 } | |
1538 | |
1539 ////////////////////////////////////////////////////////////////////////////// | 1524 ////////////////////////////////////////////////////////////////////////////// |
1540 | 1525 |
1541 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1526 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1542 if (!fAllowSoftClip) { | 1527 if (!fAllowSoftClip) { |
1543 doAA = false; | 1528 doAA = false; |
1544 } | 1529 } |
1545 | 1530 |
1546 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1531 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
1547 // Check if we can quick-accept the clip call (and do nothing) | 1532 // Check if we can quick-accept the clip call (and do nothing) |
1548 // | 1533 // |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3109 | 3094 |
3110 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3111 fCanvas->restoreToCount(fSaveCount); | 3096 fCanvas->restoreToCount(fSaveCount); |
3112 } | 3097 } |
3113 | 3098 |
3114 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3115 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3116 return this->makeSurface(info, props).release(); | 3101 return this->makeSurface(info, props).release(); |
3117 } | 3102 } |
3118 #endif | 3103 #endif |
OLD | NEW |