Revert "new virtuals for canvas ctm"
This reverts commit 2076b04d15
.
Reason for revert: speculative: breaking google3 flutter scuba?
Original change's description:
> new virtuals for canvas ctm
>
> 1. Feature: Clients need to override didConcat44() (new data)
> 2. Perf: Clients need to override didTranslate (and now didScale) so our
> default impls can be empty.
>
> Need SK_SUPPORT_LEGACY_CANVAS_MATRIX_VIRTUALS flag to stage this in
> clients (anyone who subclasses SkCanvas)
>
> Before (with flag)
> 120.87 canvas_matrix_4x4 8888
> 108.10 ? canvas_matrix_3x3 8888
> 108.13 ? canvas_matrix_2x3 8888
> 141.54 canvas_matrix_scale 8888
> 128.04 canvas_matrix_trans 8888
>
> After (without the flag)
> ...
> 90.79 canvas_matrix_scale 8888
> 94.51 canvas_matrix_trans 8888
>
> bug: skia:9768
>
> Change-Id: I6f500138dd6b2b24754dc065c650d0bd3c341540
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263349
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
TBR=fmalita@chromium.org,reed@google.com
Change-Id: I9c2e39ea0aa2b19d40eb6454c233258ab7f35829
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263564
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
2076b04d15
commit
a092028439
@ -13,7 +13,6 @@ flutter_defines = [
|
||||
"SK_DISABLE_AAA",
|
||||
|
||||
# API staging
|
||||
"SK_SUPPORT_LEGACY_CANVAS_MATRIX_VIRTUALS",
|
||||
|
||||
# Flutter doesn't deserialize anything.
|
||||
"SK_DISABLE_READBUFFER",
|
||||
|
@ -2554,24 +2554,13 @@ protected:
|
||||
virtual bool onDoSaveBehind(const SkRect*) { return true; }
|
||||
virtual void willRestore() {}
|
||||
virtual void didRestore() {}
|
||||
|
||||
// These are called when the canvas' matrix is modified. They are passed the new value(s)
|
||||
// that are being pre-concat with the CTM. Even though everything could be expressed with
|
||||
// just didConcat44(), we have 3 other specializations: translate, scale, concat (3x3),
|
||||
// to save the SkCanvas from having to construct the 4x4 matrix each time.
|
||||
//
|
||||
virtual void didConcat44(const SkScalar[16]) {} // column major
|
||||
virtual void didConcat(const SkMatrix&) {}
|
||||
virtual void didSetMatrix(const SkMatrix&) {}
|
||||
#ifdef SK_SUPPORT_LEGACY_CANVAS_MATRIX_VIRTUALS
|
||||
virtual void didConcat(const SkMatrix& ) {}
|
||||
virtual void didSetMatrix(const SkMatrix& ) {}
|
||||
virtual void didTranslate(SkScalar dx, SkScalar dy) {
|
||||
this->didConcat(SkMatrix::MakeTrans(dx, dy));
|
||||
}
|
||||
#else
|
||||
virtual void didTranslate(SkScalar, SkScalar) {}
|
||||
#endif
|
||||
// is only called if SK_SUPPORT_LEGACY_CANVAS_MATRIX_VIRTUALS is not set
|
||||
virtual void didScale(SkScalar, SkScalar) {}
|
||||
// just pass an array for now, until we decide on the "public" form for the matrix
|
||||
virtual void didConcat44(const SkScalar[]) {}
|
||||
|
||||
// NOTE: If you are adding a new onDraw virtual to SkCanvas, PLEASE add an override to
|
||||
// SkCanvasVirtualEnforcer (in SkCanvasVirtualEnforcer.h). This ensures that subclasses using
|
||||
|
@ -157,11 +157,8 @@ public:
|
||||
}
|
||||
|
||||
SkM44& preTranslate(SkScalar x, SkScalar y);
|
||||
SkM44& preScale(SkScalar x, SkScalar y);
|
||||
SkM44& preConcat(const SkMatrix&);
|
||||
|
||||
const SkScalar* peek_colMajor() const { return fMat; }
|
||||
|
||||
private:
|
||||
/* Stored in column-major.
|
||||
* Indices
|
||||
|
@ -27,11 +27,8 @@ protected:
|
||||
bool onDoSaveBehind(const SkRect*) override;
|
||||
void willRestore() override;
|
||||
|
||||
void didConcat44(const SkScalar[16]) override;
|
||||
void didConcat(const SkMatrix&) override;
|
||||
void didSetMatrix(const SkMatrix&) override;
|
||||
void didScale(SkScalar, SkScalar) override;
|
||||
void didTranslate(SkScalar, SkScalar) override;
|
||||
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -30,11 +30,8 @@ protected:
|
||||
bool onDoSaveBehind(const SkRect*) override;
|
||||
void willRestore() override;
|
||||
|
||||
void didConcat44(const SkScalar[16]) override;
|
||||
void didConcat(const SkMatrix&) override;
|
||||
void didSetMatrix(const SkMatrix&) override;
|
||||
void didScale(SkScalar, SkScalar) override;
|
||||
void didTranslate(SkScalar, SkScalar) override;
|
||||
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -1439,24 +1439,9 @@ void SkCanvas::translate(SkScalar dx, SkScalar dy) {
|
||||
}
|
||||
|
||||
void SkCanvas::scale(SkScalar sx, SkScalar sy) {
|
||||
#ifdef SK_SUPPORT_LEGACY_CANVAS_MATRIX_VIRTUALS
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy);
|
||||
this->concat(m);
|
||||
#else
|
||||
if (sx != 1 || sy != 1) {
|
||||
this->checkForDeferredSave();
|
||||
fMCRec->fMatrix.preScale(sx, sy);
|
||||
|
||||
// shouldn't need to do this (theoretically), as the state shouldn't have changed,
|
||||
// but pre-scaling by a non-finite does change it, so we have to recompute.
|
||||
fIsScaleTranslate = fMCRec->fMatrix.isScaleTranslate();
|
||||
|
||||
FOR_EACH_TOP_DEVICE(device->setGlobalCTM(fMCRec->fMatrix));
|
||||
|
||||
this->didScale(sx, sy);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkCanvas::rotate(SkScalar degrees) {
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
|
||||
void reset() { fM.setIdentity(); }
|
||||
void preTranslate(SkScalar x, SkScalar y) { fM.preTranslate(x, y); }
|
||||
void preScale(SkScalar x, SkScalar y) { fM.preScale(x, y); }
|
||||
void preConcat(const SkMatrix& m) { fM.preConcat(m); }
|
||||
void preConcat44(const SkScalar m[]) { fM.setConcat(fM, m); }
|
||||
|
||||
|
@ -92,19 +92,11 @@ SkM44& SkM44::preTranslate(SkScalar x, SkScalar y) {
|
||||
sk4f c1 = sk4f::Load(fMat + 4);
|
||||
sk4f c3 = sk4f::Load(fMat + 12);
|
||||
|
||||
// only need to update the last column
|
||||
skvx::mad(c0, x, skvx::mad(c1, y, c3)).store(fMat + 12);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& SkM44::preScale(SkScalar x, SkScalar y) {
|
||||
sk4f c0 = sk4f::Load(fMat + 0);
|
||||
sk4f c1 = sk4f::Load(fMat + 4);
|
||||
|
||||
(c0 * x).store(fMat + 0);
|
||||
(c1 * y).store(fMat + 4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** We always perform the calculation in doubles, to avoid prematurely losing
|
||||
|
@ -104,9 +104,8 @@ enum DrawType {
|
||||
DRAW_EDGEAA_QUAD,
|
||||
|
||||
DRAW_BEHIND_PAINT,
|
||||
CONCAT44,
|
||||
|
||||
LAST_DRAWTYPE_ENUM = CONCAT44,
|
||||
LAST_DRAWTYPE_ENUM = DRAW_BEHIND_PAINT,
|
||||
};
|
||||
|
||||
enum DrawVertexFlags {
|
||||
|
@ -219,25 +219,6 @@ void SkPictureRecord::recordScale(const SkMatrix& m) {
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::didConcat44(const SkScalar m[16]) {
|
||||
this->validate(fWriter.bytesWritten(), 0);
|
||||
// op + matrix
|
||||
size_t size = kUInt32Size + 16 * sizeof(SkScalar);
|
||||
size_t initialOffset = this->addDraw(CONCAT44, &size);
|
||||
fWriter.write(m, 16 * sizeof(SkScalar));
|
||||
this->validate(initialOffset, size);
|
||||
|
||||
this->INHERITED::didConcat44(m);
|
||||
}
|
||||
|
||||
void SkPictureRecord::didScale(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeScale(x, y));
|
||||
}
|
||||
|
||||
void SkPictureRecord::didTranslate(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeTrans(x, y));
|
||||
}
|
||||
|
||||
void SkPictureRecord::didConcat(const SkMatrix& matrix) {
|
||||
switch (matrix.getType()) {
|
||||
case SkMatrix::kTranslate_Mask:
|
||||
|
@ -162,11 +162,8 @@ protected:
|
||||
bool onDoSaveBehind(const SkRect*) override;
|
||||
void willRestore() override;
|
||||
|
||||
void didConcat44(const SkScalar[16]) override;
|
||||
void didConcat(const SkMatrix&) override;
|
||||
void didSetMatrix(const SkMatrix&) override;
|
||||
void didScale(SkScalar, SkScalar) override;
|
||||
void didTranslate(SkScalar, SkScalar) override;
|
||||
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
|
||||
|
@ -93,10 +93,8 @@ template <> void Draw::draw(const DrawBehind& r) {
|
||||
}
|
||||
|
||||
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
|
||||
DRAW(Concat44, concat44(r.matrix.peek_colMajor()));
|
||||
DRAW(Concat, concat(r.matrix));
|
||||
DRAW(Translate, translate(r.dx, r.dy));
|
||||
DRAW(Scale, scale(r.sx, r.sy));
|
||||
|
||||
DRAW(ClipPath, clipPath(r.path, r.opAA.op(), r.opAA.aa()));
|
||||
DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op(), r.opAA.aa()));
|
||||
@ -248,9 +246,7 @@ private:
|
||||
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 Concat44& op) { fCTM.preConcat(op.matrix.asM33()); }
|
||||
void updateCTM(const Concat& op) { fCTM.preConcat(op.matrix); }
|
||||
void updateCTM(const Scale& op) { fCTM.preScale(op.sx, op.sy); }
|
||||
void updateCTM(const Translate& op) { fCTM.preTranslate(op.dx, op.dy); }
|
||||
|
||||
// The bounds of these ops must be calculated when we hit the Restore
|
||||
@ -262,8 +258,6 @@ private:
|
||||
|
||||
void trackBounds(const SetMatrix&) { this->pushControl(); }
|
||||
void trackBounds(const Concat&) { this->pushControl(); }
|
||||
void trackBounds(const Concat44&) { this->pushControl(); }
|
||||
void trackBounds(const Scale&) { this->pushControl(); }
|
||||
void trackBounds(const Translate&) { this->pushControl(); }
|
||||
void trackBounds(const ClipRect&) { this->pushControl(); }
|
||||
void trackBounds(const ClipRRect&) { this->pushControl(); }
|
||||
|
@ -370,10 +370,6 @@ void SkRecorder::didRestore() {
|
||||
this->append<SkRecords::Restore>(this->getTotalMatrix());
|
||||
}
|
||||
|
||||
void SkRecorder::didConcat44(const SkScalar m[16]) {
|
||||
this->append<SkRecords::Concat44>(m);
|
||||
}
|
||||
|
||||
void SkRecorder::didConcat(const SkMatrix& matrix) {
|
||||
this->append<SkRecords::Concat>(matrix);
|
||||
}
|
||||
@ -382,10 +378,6 @@ void SkRecorder::didSetMatrix(const SkMatrix& matrix) {
|
||||
this->append<SkRecords::SetMatrix>(matrix);
|
||||
}
|
||||
|
||||
void SkRecorder::didScale(SkScalar sx, SkScalar sy) {
|
||||
this->append<SkRecords::Scale>(sx, sy);
|
||||
}
|
||||
|
||||
void SkRecorder::didTranslate(SkScalar dx, SkScalar dy) {
|
||||
this->append<SkRecords::Translate>(dx, dy);
|
||||
}
|
||||
|
@ -67,10 +67,8 @@ public:
|
||||
void willRestore() override {}
|
||||
void didRestore() override;
|
||||
|
||||
void didConcat44(const SkScalar[16]) override;
|
||||
void didConcat(const SkMatrix&) override;
|
||||
void didSetMatrix(const SkMatrix&) override;
|
||||
void didScale(SkScalar, SkScalar) override;
|
||||
void didTranslate(SkScalar, SkScalar) override;
|
||||
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkTextBlob.h"
|
||||
#include "include/core/SkVertices.h"
|
||||
#include "include/private/SkM44.h"
|
||||
#include "src/core/SkDrawShadowInfo.h"
|
||||
|
||||
namespace SkRecords {
|
||||
@ -47,9 +46,7 @@ namespace SkRecords {
|
||||
M(SaveBehind) \
|
||||
M(SetMatrix) \
|
||||
M(Translate) \
|
||||
M(Scale) \
|
||||
M(Concat) \
|
||||
M(Concat44) \
|
||||
M(ClipPath) \
|
||||
M(ClipRRect) \
|
||||
M(ClipRect) \
|
||||
@ -156,13 +153,6 @@ struct TypedMatrix : public SkMatrix {
|
||||
TypedMatrix(const SkMatrix& matrix);
|
||||
};
|
||||
|
||||
struct Matrix44 : public SkM44 {
|
||||
Matrix44() {}
|
||||
Matrix44(const SkScalar m[16]) {
|
||||
this->setColMajor(m);
|
||||
}
|
||||
};
|
||||
|
||||
enum Tags {
|
||||
kDraw_Tag = 1, // May draw something (usually named DrawFoo).
|
||||
kHasImage_Tag = 2, // Contains an SkImage or SkBitmap.
|
||||
@ -201,17 +191,11 @@ RECORD(SetMatrix, 0,
|
||||
TypedMatrix matrix);
|
||||
RECORD(Concat, 0,
|
||||
TypedMatrix matrix);
|
||||
RECORD(Concat44, 0,
|
||||
Matrix44 matrix);
|
||||
|
||||
RECORD(Translate, 0,
|
||||
SkScalar dx;
|
||||
SkScalar dy);
|
||||
|
||||
RECORD(Scale, 0,
|
||||
SkScalar sx;
|
||||
SkScalar sy);
|
||||
|
||||
struct ClipOpAndAA {
|
||||
ClipOpAndAA() {}
|
||||
ClipOpAndAA(SkClipOp op, bool aa) : fOp(static_cast<unsigned>(op)), fAA(aa) {}
|
||||
|
@ -110,15 +110,6 @@ void SkLuaCanvas::willRestore() {
|
||||
this->INHERITED::willRestore();
|
||||
}
|
||||
|
||||
void SkLuaCanvas::didConcat44(const SkScalar m[16]) {
|
||||
// TODO
|
||||
}
|
||||
void SkLuaCanvas::didScale(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeScale(x, y));
|
||||
}
|
||||
void SkLuaCanvas::didTranslate(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeTrans(x, y));
|
||||
}
|
||||
void SkLuaCanvas::didConcat(const SkMatrix& matrix) {
|
||||
switch (matrix.getType()) {
|
||||
case SkMatrix::kTranslate_Mask: {
|
||||
|
@ -92,14 +92,6 @@ void SkNWayCanvas::willRestore() {
|
||||
this->INHERITED::willRestore();
|
||||
}
|
||||
|
||||
void SkNWayCanvas::didConcat44(const SkScalar m[16]) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->concat44(m);
|
||||
}
|
||||
this->INHERITED::didConcat44(m);
|
||||
}
|
||||
|
||||
void SkNWayCanvas::didConcat(const SkMatrix& matrix) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
@ -116,22 +108,6 @@ void SkNWayCanvas::didSetMatrix(const SkMatrix& matrix) {
|
||||
this->INHERITED::didSetMatrix(matrix);
|
||||
}
|
||||
|
||||
void SkNWayCanvas::didScale(SkScalar x, SkScalar y) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->scale(x, y);
|
||||
}
|
||||
this->INHERITED::didScale(x, y);
|
||||
}
|
||||
|
||||
void SkNWayCanvas::didTranslate(SkScalar x, SkScalar y) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->translate(x, y);
|
||||
}
|
||||
this->INHERITED::didTranslate(x, y);
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
|
@ -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::Scale> (r, record, 2);
|
||||
assert_type<SkRecords::Concat> (r, record, 2);
|
||||
assert_type<SkRecords::Restore> (r, record, 3);
|
||||
|
||||
recorder.save();
|
||||
|
@ -312,19 +312,6 @@ void DebugCanvas::onClipRegion(const SkRegion& region, SkClipOp op) {
|
||||
this->addDrawCommand(new ClipRegionCommand(region, op));
|
||||
}
|
||||
|
||||
void DebugCanvas::didConcat44(const SkScalar m[16]) {
|
||||
// TODO
|
||||
this->INHERITED::didConcat44(m);
|
||||
}
|
||||
|
||||
void DebugCanvas::didScale(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeScale(x, y));
|
||||
}
|
||||
|
||||
void DebugCanvas::didTranslate(SkScalar x, SkScalar y) {
|
||||
this->didConcat(SkMatrix::MakeTrans(x, y));
|
||||
}
|
||||
|
||||
void DebugCanvas::didConcat(const SkMatrix& matrix) {
|
||||
this->addDrawCommand(new ConcatCommand(matrix));
|
||||
this->INHERITED::didConcat(matrix);
|
||||
|
@ -129,11 +129,9 @@ protected:
|
||||
bool onDoSaveBehind(const SkRect*) override;
|
||||
void willRestore() override;
|
||||
|
||||
void didConcat44(const SkScalar[16]) override;
|
||||
void didConcat(const SkMatrix&) override;
|
||||
|
||||
void didSetMatrix(const SkMatrix&) override;
|
||||
void didScale(SkScalar, SkScalar) override;
|
||||
void didTranslate(SkScalar, SkScalar) override;
|
||||
|
||||
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
|
||||
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
||||
|
Loading…
Reference in New Issue
Block a user