Chromium Code Reviews| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 /* If there are any layers in the stack, this points to the top-most | 286 /* If there are any layers in the stack, this points to the top-most |
| 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 |
|
robertphillips
2016/07/12 15:34:32
// This is the current cumulative depth (aggregati
vjiaoblack
2016/07/12 16:03:33
Done.
| |
| 297 SkScalar fCurDrawDepth; | |
| 298 | |
| 297 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { | 299 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { |
| 298 fFilter = nullptr; | 300 fFilter = nullptr; |
| 299 fLayer = nullptr; | 301 fLayer = nullptr; |
| 300 fTopLayer = nullptr; | 302 fTopLayer = nullptr; |
| 301 fMatrix.reset(); | 303 fMatrix.reset(); |
| 302 fDeferredSaveCount = 0; | 304 fDeferredSaveCount = 0; |
| 305 fCurDrawDepth = 0; | |
| 303 | 306 |
| 304 // don't bother initializing fNext | 307 // don't bother initializing fNext |
| 305 inc_rec(); | 308 inc_rec(); |
| 306 } | 309 } |
| 307 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr ix) { | 310 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr ix), |
| 311 fCurDrawDepth(prev.fCurDrawDepth) { | |
| 308 fFilter = SkSafeRef(prev.fFilter); | 312 fFilter = SkSafeRef(prev.fFilter); |
| 309 fLayer = nullptr; | 313 fLayer = nullptr; |
| 310 fTopLayer = prev.fTopLayer; | 314 fTopLayer = prev.fTopLayer; |
| 311 fDeferredSaveCount = 0; | 315 fDeferredSaveCount = 0; |
| 312 | 316 |
| 313 // don't bother initializing fNext | 317 // don't bother initializing fNext |
| 314 inc_rec(); | 318 inc_rec(); |
| 315 } | 319 } |
| 316 ~MCRec() { | 320 ~MCRec() { |
| 317 SkSafeUnref(fFilter); | 321 SkSafeUnref(fFilter); |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1514 void SkCanvas::setMatrix(const SkMatrix& matrix) { | 1518 void SkCanvas::setMatrix(const SkMatrix& matrix) { |
| 1515 this->checkForDeferredSave(); | 1519 this->checkForDeferredSave(); |
| 1516 this->internalSetMatrix(matrix); | 1520 this->internalSetMatrix(matrix); |
| 1517 this->didSetMatrix(matrix); | 1521 this->didSetMatrix(matrix); |
| 1518 } | 1522 } |
| 1519 | 1523 |
| 1520 void SkCanvas::resetMatrix() { | 1524 void SkCanvas::resetMatrix() { |
| 1521 this->setMatrix(SkMatrix::I()); | 1525 this->setMatrix(SkMatrix::I()); |
| 1522 } | 1526 } |
| 1523 | 1527 |
| 1528 void SkCanvas::translateZ(SkScalar z) { | |
| 1529 this->checkForDeferredSave(); | |
| 1530 this->fMCRec->fCurDrawDepth += z; | |
| 1531 this->didTranslateZ(z); | |
| 1532 } | |
| 1533 | |
| 1534 SkScalar SkCanvas::getZ() const { | |
| 1535 return this->fMCRec->fCurDrawDepth; | |
| 1536 } | |
| 1537 | |
| 1524 ////////////////////////////////////////////////////////////////////////////// | 1538 ////////////////////////////////////////////////////////////////////////////// |
| 1525 | 1539 |
| 1526 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1540 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
| 1527 if (!fAllowSoftClip) { | 1541 if (!fAllowSoftClip) { |
| 1528 doAA = false; | 1542 doAA = false; |
| 1529 } | 1543 } |
| 1530 | 1544 |
| 1531 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1545 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
| 1532 // Check if we can quick-accept the clip call (and do nothing) | 1546 // Check if we can quick-accept the clip call (and do nothing) |
| 1533 // | 1547 // |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3094 | 3108 |
| 3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3109 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3096 fCanvas->restoreToCount(fSaveCount); | 3110 fCanvas->restoreToCount(fSaveCount); |
| 3097 } | 3111 } |
| 3098 | 3112 |
| 3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3113 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
| 3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { | 3114 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { |
| 3101 return this->makeSurface(info, props).release(); | 3115 return this->makeSurface(info, props).release(); |
| 3102 } | 3116 } |
| 3103 #endif | 3117 #endif |
| OLD | NEW |