From 0a98d870448f66ea0df7c37a47b38cf2d3b734e5 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 19 May 2014 15:15:24 +0000 Subject: Don't clobber initial transform with SetMatrix. BUG=skia:2378 R=reed@google.com, mtklein@google.com, robertphillips@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/290883004 git-svn-id: http://skia.googlecode.com/svn/trunk@14778 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/record/SkRecordDraw.cpp | 8 +++++++- src/record/SkRecordDraw.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/record') diff --git a/src/record/SkRecordDraw.cpp b/src/record/SkRecordDraw.cpp index 324946e5d7..5df1650a5e 100644 --- a/src/record/SkRecordDraw.cpp +++ b/src/record/SkRecordDraw.cpp @@ -38,7 +38,13 @@ DRAW(PopCull, popCull()); DRAW(PushCull, pushCull(r.rect)); DRAW(Clear, clear(r.color)); DRAW(Concat, concat(r.matrix)); -DRAW(SetMatrix, setMatrix(r.matrix)); + +// We can't clobber the canvas' initial CTM when calling setMatrix. +template <> void Draw::draw(const SetMatrix& r) { + SkMatrix ctm; + ctm.setConcat(fInitialCTM, r.matrix); + fCanvas->setMatrix(ctm); +} DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA)); diff --git a/src/record/SkRecordDraw.h b/src/record/SkRecordDraw.h index 4ec6e68e92..359679a6d7 100644 --- a/src/record/SkRecordDraw.h +++ b/src/record/SkRecordDraw.h @@ -19,7 +19,8 @@ namespace SkRecords { // This is an SkRecord visitor that will draw that SkRecord to an SkCanvas. class Draw : SkNoncopyable { public: - explicit Draw(SkCanvas* canvas) : fCanvas(canvas), fIndex(0) {} + explicit Draw(SkCanvas* canvas) + : fInitialCTM(canvas->getTotalMatrix()), fCanvas(canvas), fIndex(0) {} unsigned index() const { return fIndex; } void next() { ++fIndex; } @@ -44,6 +45,7 @@ private: bool skip(const PairedPushCull&); bool skip(const BoundedDrawPosTextH&); + const SkMatrix fInitialCTM; SkCanvas* fCanvas; unsigned fIndex; }; -- cgit v1.2.3