diff options
author | 2014-08-19 07:09:40 -0700 | |
---|---|---|
committer | 2014-08-19 07:09:40 -0700 | |
commit | 6332f1dd20d73a6d8b9564af7c27d09394eb6596 (patch) | |
tree | de5206d5c4a0a55129abb9f133ce1a474b3df658 /src | |
parent | 8a39a6b2b1d2c75b76e0fb75aab4d51792d240f6 (diff) |
Record concat as setMatrix.
Mainly this cuts out a type to have to think about in SkRecord world.
It also means all the CTMs are recorded directly in the SkRecord, so
we can track the current CTM by pointer rather than by copying.
BUG=skia:
R=reed@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/484673003
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkRecordDraw.cpp | 13 | ||||
-rw-r--r-- | src/core/SkRecorder.cpp | 7 | ||||
-rw-r--r-- | src/core/SkRecords.h | 2 |
3 files changed, 6 insertions, 16 deletions
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index fda848835f..e792d37143 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -64,7 +64,6 @@ DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); DRAW(PopCull, popCull()); DRAW(PushCull, pushCull(r.rect)); DRAW(Clear, clear(r.color)); -DRAW(Concat, concat(r.matrix)); DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); DRAW(ClipPath, clipPath(r.path, r.op, r.doAA)); @@ -120,7 +119,7 @@ public: // Calculate bounds for all ops. This won't go quite in order, so we'll need // to store the bounds separately then feed them in to the BBH later in order. const SkIRect largest = SkIRect::MakeLargest(); - fCTM.setIdentity(); + fCTM = &SkMatrix::I(); fCurrentClipBounds = largest; for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) { record.visit<void>(fCurrentOp, *this); @@ -161,9 +160,8 @@ private: }; template <typename T> void updateCTM(const T&) { /* most ops don't change the CTM */ } - 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); } + void updateCTM(const Restore& op) { fCTM = &op.matrix; } + void updateCTM(const SetMatrix& op) { fCTM = &op.matrix; } template <typename T> void updateClipBounds(const T&) { /* most ops don't change the clip */ } // Each of these devBounds fields is the state of the device bounds after the op. @@ -186,7 +184,6 @@ private: void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); } - void trackBounds(const Concat&) { this->pushControl(); } void trackBounds(const SetMatrix&) { this->pushControl(); } void trackBounds(const ClipRect&) { this->pushControl(); } void trackBounds(const ClipRRect&) { this->pushControl(); } @@ -359,7 +356,7 @@ private: } // Map the rect back to device space. - fCTM.mapRect(&rect); + fCTM->mapRect(&rect); SkIRect devRect; rect.roundOut(&devRect); @@ -376,7 +373,7 @@ private: // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative // device bounds of the current clip (fCurrentClipBounds). unsigned fCurrentOp; - SkMatrix fCTM; + const SkMatrix* fCTM; SkIRect 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 d49de20e68..1ee24fff56 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -218,20 +218,17 @@ void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], void SkRecorder::willSave() { APPEND(Save); - INHERITED(willSave); } SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlags flags) { APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); - INHERITED(willSaveLayer, bounds, paint, flags); return SkCanvas::kNoLayer_SaveLayerStrategy; } void SkRecorder::didRestore() { APPEND(Restore, this->devBounds(), this->getTotalMatrix()); - INHERITED(didRestore); } void SkRecorder::onPushCull(const SkRect& rect) { @@ -243,14 +240,12 @@ void SkRecorder::onPopCull() { } void SkRecorder::didConcat(const SkMatrix& matrix) { - APPEND(Concat, matrix); - INHERITED(didConcat, matrix); + this->didSetMatrix(this->getTotalMatrix()); } void SkRecorder::didSetMatrix(const SkMatrix& matrix) { SkASSERT(matrix == this->getTotalMatrix()); APPEND(SetMatrix, matrix); - INHERITED(didSetMatrix, matrix); } void SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h index bc768d9496..01cdbf7b9f 100644 --- a/src/core/SkRecords.h +++ b/src/core/SkRecords.h @@ -44,7 +44,6 @@ namespace SkRecords { M(SaveLayer) \ M(PushCull) \ M(PopCull) \ - M(Concat) \ M(SetMatrix) \ M(ClipPath) \ M(ClipRRect) \ @@ -204,7 +203,6 @@ RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas: RECORD1(PushCull, SkRect, rect); RECORD0(PopCull); -RECORD1(Concat, SkMatrix, matrix); RECORD1(SetMatrix, SkMatrix, matrix); RECORD4(ClipPath, SkIRect, devBounds, SkPath, path, SkRegion::Op, op, bool, doAA); |