Record concat as Concat.
This seems to cause very slight diffs on GMs.
https://gold.skia.org/search2?issue=1462983002&unt=true&query=source_type%3Dgm&master=false
I'm not sure I understand why.
The diffs to at least pictureshader look like improvements.
BUG=skia:4584
Review URL: https://codereview.chromium.org/1462983002
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index 610d29f..b856647 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -36,6 +36,7 @@
M(Save) \
M(SaveLayer) \
M(SetMatrix) \
+ M(Concat) \
M(ClipPath) \
M(ClipRRect) \
M(ClipRect) \
@@ -201,6 +202,8 @@
RECORD(SetMatrix, 0,
TypedMatrix matrix);
+RECORD(Concat, 0,
+ TypedMatrix matrix);
struct RegionOpAndAA {
RegionOpAndAA() {}
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index ab0cb71..4847273 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -80,6 +80,7 @@
DRAW(Save, save());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
+DRAW(Concat, concat(r.matrix));
DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa));
DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa));
@@ -154,7 +155,7 @@
: fNumRecords(record.count())
, fCullRect(cullRect)
, fBounds(bounds) {
- fCTM = &SkMatrix::I();
+ fCTM = SkMatrix::I();
fCurrentClipBounds = fCullRect;
}
@@ -184,7 +185,7 @@
typedef SkRect Bounds;
int currentOp() const { return fCurrentOp; }
- const SkMatrix& ctm() const { return *fCTM; }
+ const SkMatrix& ctm() const { return fCTM; }
const Bounds& getBounds(int index) const { return fBounds[index]; }
// Adjust rect for all paints that may affect its geometry, then map it to identity space.
@@ -205,7 +206,7 @@
}
// Map the rect back to identity space.
- fCTM->mapRect(&rect);
+ fCTM.mapRect(&rect);
// Nothing can draw outside the current clip.
if (!rect.intersect(fCurrentClipBounds)) {
@@ -222,10 +223,11 @@
const SkPaint* paint; // Unowned. If set, adjusts the bounds of all ops in this block.
};
- // Only Restore and SetMatrix change the CTM.
+ // Only Restore, SetMatrix, and Concat change the CTM.
template <typename T> void updateCTM(const T&) {}
- void updateCTM(const Restore& op) { fCTM = &op.matrix; }
- void updateCTM(const SetMatrix& op) { fCTM = &op.matrix; }
+ void updateCTM(const Restore& op) { fCTM = op.matrix; }
+ void updateCTM(const SetMatrix& op) { fCTM = op.matrix; }
+ void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); }
// Most ops don't change the clip.
template <typename T> void updateClipBounds(const T&) {}
@@ -278,6 +280,7 @@
void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); }
void trackBounds(const SetMatrix&) { this->pushControl(); }
+ void trackBounds(const Concat&) { this->pushControl(); }
void trackBounds(const ClipRect&) { this->pushControl(); }
void trackBounds(const ClipRRect&) { this->pushControl(); }
void trackBounds(const ClipPath&) { this->pushControl(); }
@@ -579,7 +582,7 @@
// and updateClipBounds() to maintain the exact CTM (fCTM) and conservative
// identity-space bounds of the current clip (fCurrentClipBounds).
int fCurrentOp;
- const SkMatrix* fCTM;
+ SkMatrix fCTM;
Bounds fCurrentClipBounds;
// Used to track the bounds of Save/Restore blocks and the control ops inside them.
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index a3c9513..d90b2c0 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -352,15 +352,10 @@
}
void SkRecorder::didConcat(const SkMatrix& matrix) {
- this->didSetMatrix(this->getTotalMatrix());
+ APPEND(Concat, matrix);
}
void SkRecorder::didSetMatrix(const SkMatrix& matrix) {
- SkDEVCODE(if (matrix != this->getTotalMatrix()) {
- matrix.dump();
- this->getTotalMatrix().dump();
- SkASSERT(matrix == this->getTotalMatrix());
- })
APPEND(SetMatrix, matrix);
}
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 5aab91d..8dfdc97 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -46,7 +46,7 @@
assert_type<SkRecords::DrawPaint>(r, record, 0);
assert_type<SkRecords::Save> (r, record, 1);
- assert_type<SkRecords::SetMatrix>(r, record, 2);
+ assert_type<SkRecords::Concat> (r, record, 2);
assert_type<SkRecords::Restore> (r, record, 3);
recorder.save();