From f6d70a8e3fc2ee983e82723490e44f0362afb136 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 10 Jan 2020 15:56:32 -0500 Subject: [PATCH] Revert "Revert "forward concat44 in nway canvas"" This reverts commit 3723fb7e85bb5faacb93dc0d5416699b2ed31eb0. Fix: don't call the inherited methods on canvas bug: skia: 9768 Change-Id: Ifb913bd30452ba8389399f709d40c7b58d6157d8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263776 Reviewed-by: Brian Osman Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- include/utils/SkNWayCanvas.h | 2 ++ samplecode/SampleClip.cpp | 6 ++---- src/utils/SkNWayCanvas.cpp | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h index 72bed680bf..4f46a006ca 100644 --- a/include/utils/SkNWayCanvas.h +++ b/include/utils/SkNWayCanvas.h @@ -30,7 +30,9 @@ protected: bool onDoSaveBehind(const SkRect*) override; void willRestore() override; + void didConcat44(const SkScalar[16]) override; void didConcat(const SkMatrix&) override; + void didTranslate(SkScalar x, SkScalar y) override; void didSetMatrix(const SkMatrix&) override; void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp index b5d6a78c14..a25bd549a7 100644 --- a/samplecode/SampleClip.cpp +++ b/samplecode/SampleClip.cpp @@ -547,7 +547,7 @@ class HalfPlaneView3 : public SampleCameraView { } void onDrawContent(SkCanvas* canvas) override { - SkMatrix mx = this->get44({0, 0, 400, 400}); + SkMatrix44 mx = this->get44({0, 0, 400, 400}); SkPaint paint; paint.setColor({0.75, 0.75, 0.75, 1}); @@ -612,12 +612,10 @@ class HalfPlaneCoons : public SampleCameraView { } void onDrawContent(SkCanvas* canvas) override { - SkMatrix mx = this->get44({0, 0, 300, 300}); - SkPaint paint; canvas->save(); - canvas->concat(mx); + canvas->concat(this->get44({0, 0, 300, 300})); const SkPoint* tex = nullptr; const SkColor* col = nullptr; diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index 1ce6318e5c..d338eac41a 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -92,12 +92,25 @@ void SkNWayCanvas::willRestore() { this->INHERITED::willRestore(); } +void SkNWayCanvas::didConcat44(const SkScalar m[16]) { + Iter iter(fList); + while (iter.next()) { + iter->concat44(m); + } +} + void SkNWayCanvas::didConcat(const SkMatrix& matrix) { Iter iter(fList); while (iter.next()) { iter->concat(matrix); } - this->INHERITED::didConcat(matrix); +} + +void SkNWayCanvas::didTranslate(SkScalar x, SkScalar y) { + Iter iter(fList); + while (iter.next()) { + iter->translate(x, y); + } } void SkNWayCanvas::didSetMatrix(const SkMatrix& matrix) { @@ -105,7 +118,6 @@ void SkNWayCanvas::didSetMatrix(const SkMatrix& matrix) { while (iter.next()) { iter->setMatrix(matrix); } - this->INHERITED::didSetMatrix(matrix); } void SkNWayCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {