Added the framework for having canvas/recorder/picture record depth_set's.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2127233002
Committed: https://skia.googlesource.com/skia/+/6d3fb898d5f73a82e36f11c712a633c3921ed518
Committed: https://skia.googlesource.com/skia/+/1185d90c785f743364cc9113d7007a59af07470c
Review-Url: https://codereview.chromium.org/2127233002
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index f893a62..0bd3851 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -294,17 +294,22 @@
SkMatrix fMatrix;
int fDeferredSaveCount;
+ // This is the current cumulative depth (aggregate of all done translateZ calls)
+ SkScalar fCurDrawDepth;
+
MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) {
fFilter = nullptr;
fLayer = nullptr;
fTopLayer = nullptr;
fMatrix.reset();
fDeferredSaveCount = 0;
+ fCurDrawDepth = 0;
// don't bother initializing fNext
inc_rec();
}
- MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatrix) {
+ MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatrix),
+ fCurDrawDepth(prev.fCurDrawDepth) {
fFilter = SkSafeRef(prev.fFilter);
fLayer = nullptr;
fTopLayer = prev.fTopLayer;
@@ -1539,6 +1544,16 @@
this->setMatrix(SkMatrix::I());
}
+void SkCanvas::translateZ(SkScalar z) {
+ this->checkForDeferredSave();
+ this->fMCRec->fCurDrawDepth += z;
+ this->didTranslateZ(z);
+}
+
+SkScalar SkCanvas::getZ() const {
+ return this->fMCRec->fCurDrawDepth;
+}
+
//////////////////////////////////////////////////////////////////////////////
void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {