aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/private/SkRecords.h3
-rw-r--r--src/core/SkRecordDraw.cpp17
-rw-r--r--src/core/SkRecorder.cpp7
-rw-r--r--tests/RecordDrawTest.cpp2
4 files changed, 15 insertions, 14 deletions
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index 610d29fb0c..b856647aee 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -36,6 +36,7 @@ namespace SkRecords {
M(Save) \
M(SaveLayer) \
M(SetMatrix) \
+ M(Concat) \
M(ClipPath) \
M(ClipRRect) \
M(ClipRect) \
@@ -201,6 +202,8 @@ RECORD(SaveLayer, 0,
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 ab0cb71407..4847273f52 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -80,6 +80,7 @@ DRAW(Restore, restore());
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 @@ public:
: fNumRecords(record.count())
, fCullRect(cullRect)
, fBounds(bounds) {
- fCTM = &SkMatrix::I();
+ fCTM = SkMatrix::I();
fCurrentClipBounds = fCullRect;
}
@@ -184,7 +185,7 @@ public:
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 @@ public:
}
// 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 @@ private:
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 @@ private:
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 @@ private:
// 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 a3c9513168..d90b2c025a 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -352,15 +352,10 @@ void SkRecorder::didRestore() {
}
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 5aab91d444..8dfdc976f5 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -46,7 +46,7 @@ DEF_TEST(RecordDraw_LazySaves, r) {
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();