Revert of Fast path translate() in SkCanvas and SkLiteDL. (patchset #5 id:80001 of https://codereview.chromium.org/2255283002/ )

Reason for revert:
speculative

Original issue's description:
> Fast path translate() in SkCanvas and SkLiteDL.
>
> This adds didTranslate() so that SkLiteDL (and other canvas recorders)
> can record the translate rather than the full concat.
>
> It also adds a case to SkMatrix::preTranslate() to fast path
> translate x translate -> translate (i.e. +=).
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255283002
>
> Committed: https://skia.googlesource.com/skia/+/5fa47f4fd13b3158de4599414c86d17649c2dd1c

TBR=herb@google.com,reed@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/2264433002
This commit is contained in:
mtklein 2016-08-18 17:43:59 -07:00 committed by Commit bot
parent 4a16717bc7
commit 954df2fe9f
7 changed files with 10 additions and 35 deletions

View File

@ -1352,9 +1352,6 @@ protected:
virtual void didRestore() {}
virtual void didConcat(const SkMatrix&) {}
virtual void didSetMatrix(const SkMatrix&) {}
virtual void didTranslate(SkScalar dx, SkScalar dy) {
this->didConcat(SkMatrix::MakeTrans(dx, dy));
}
#ifdef SK_EXPERIMENTAL_SHADOWING
virtual void didTranslateZ(SkScalar) {}

View File

@ -1444,14 +1444,9 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, const SkPa
/////////////////////////////////////////////////////////////////////////////
void SkCanvas::translate(SkScalar dx, SkScalar dy) {
this->checkForDeferredSave();
fDeviceCMDirty = true;
fMCRec->fMatrix.preTranslate(dx,dy);
// Translate shouldn't affect the is-scale-translateness of the matrix.
SkASSERT(fIsScaleTranslate == fMCRec->fMatrix.isScaleTranslate());
this->didTranslate(dx,dy);
SkMatrix m;
m.setTranslate(dx, dy);
this->concat(m);
}
void SkCanvas::scale(SkScalar sx, SkScalar sy) {

View File

@ -52,7 +52,7 @@ static void make_threadsafe(SkPath* path, SkMatrix* matrix) {
namespace {
#define TYPES(M) \
M(Save) M(Restore) M(SaveLayer) \
M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
M(Concat) M(SetMatrix) M(TranslateZ) \
M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawRRect) M(DrawDRRect) \
M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) M(DrawShadowedPicture) \
@ -115,14 +115,6 @@ namespace {
}
void makeThreadsafe() { make_threadsafe(nullptr, &matrix); }
};
struct Translate final : Op {
static const auto kType = Type::Translate;
Translate(SkScalar dx, SkScalar dy) : dx(dx), dy(dy) {}
SkScalar dx,dy;
void draw(SkCanvas* c, const SkMatrix&) {
c->translate(dx, dy);
}
};
struct TranslateZ final : Op {
static const auto kType = Type::TranslateZ;
TranslateZ(SkScalar dz) : dz(dz) {}
@ -547,9 +539,8 @@ void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
this->push<SaveLayer>(0, bounds, paint, backdrop, flags);
}
void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matrix); }
void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matrix); }
void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx, dy); }
void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matrix); }
void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matrix); }
void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); }
void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) {

View File

@ -29,7 +29,6 @@ public:
void concat (const SkMatrix&);
void setMatrix (const SkMatrix&);
void translate(SkScalar, SkScalar);
void translateZ(SkScalar);
void clipPath (const SkPath&, SkRegion::Op, bool aa);

View File

@ -29,9 +29,8 @@ SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayer
}
void SkLiteRecorder::willRestore() { fDL->restore(); }
void SkLiteRecorder::didConcat (const SkMatrix& matrix) { fDL-> concat(matrix); }
void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
void SkLiteRecorder::didTranslate(SkScalar dx, SkScalar dy) { fDL->translate(dx, dy); }
void SkLiteRecorder::didConcat (const SkMatrix& matrix) { fDL-> concat(matrix); }
void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
void SkLiteRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle style) {
fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);

View File

@ -25,7 +25,6 @@ public:
void didConcat(const SkMatrix&) override;
void didSetMatrix(const SkMatrix&) override;
void didTranslate(SkScalar, SkScalar) override;
void onClipRect (const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
void onClipRRect (const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;

View File

@ -290,12 +290,7 @@ void SkMatrix::preTranslate(SkScalar dx, SkScalar dy) {
return;
}
if (fTypeMask <= kTranslate_Mask) {
fMat[kMTransX] += dx;
fMat[kMTransY] += dy;
this->setTypeMask((fMat[kMTransX] != 0 || fMat[kMTransY] != 0) ? kTranslate_Mask
: kIdentity_Mask);
} else if (this->hasPerspective()) {
if (this->hasPerspective()) {
SkMatrix m;
m.setTranslate(dx, dy);
this->preConcat(m);
@ -1105,7 +1100,7 @@ void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
SkASSERT(dst);
SkASSERT(this->isScaleTranslate());
SkScalar sx = fMat[kMScaleX];
SkScalar sy = fMat[kMScaleY];
SkScalar tx = fMat[kMTransX];