deprecate getTotalMatrix
Change-Id: Iec7d67f4ec3fdf4d5280f3de3d6146a69a60c646 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339995 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
041f6656dc
commit
1a4140e598
@ -145,7 +145,7 @@ protected:
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
GrRenderTargetContext* rtc = canvas->internal_private_accessTopLayerRenderTargetContext();
|
||||
SkMatrix view = canvas->getTotalMatrix();
|
||||
SkMatrix view = canvas->getLocalToDeviceAs3x3();
|
||||
SkSimpleMatrixProvider matrixProvider(view);
|
||||
GrPaint grPaint;
|
||||
SkPaintToGrPaint(context, rtc->colorInfo(), paint, matrixProvider, &grPaint);
|
||||
|
@ -74,7 +74,7 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
|
||||
clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fTop));
|
||||
fSurfaces.back()->getCanvas()->clipRect(clip);
|
||||
|
||||
fSurfaces.back()->getCanvas()->setMatrix(canvas->getTotalMatrix());
|
||||
fSurfaces.back()->getCanvas()->setMatrix(canvas->getLocalToDevice());
|
||||
fSurfaces.back()->getCanvas()->scale(fScale, fScale);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
// HASH=4a00e6589e862fde5be532f4b6e316ce
|
||||
REG_FIDDLE(Canvas_empty_constructor, 256, 256, true, 0) {
|
||||
static void check_for_rotated_ctm(const SkCanvas* canvas) {
|
||||
const SkMatrix& matrix = canvas->getTotalMatrix();
|
||||
SkDebugf("rect stays rect is %s\n", matrix.rectStaysRect() ? "true" : "false");
|
||||
const SkM44 matrix = canvas->getLocalToDevice();
|
||||
SkDebugf("ctm is identity = \n", matrix == SkM44() ? "true" : "false");
|
||||
}
|
||||
|
||||
void draw(SkCanvas* canvas) {
|
||||
|
@ -68,7 +68,7 @@ protected:
|
||||
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props));
|
||||
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
|
||||
// init our new canvas with the old canvas's matrix
|
||||
canvas->setMatrix(inputCanvas->getTotalMatrix());
|
||||
canvas->setMatrix(inputCanvas->getLocalToDeviceAs3x3());
|
||||
// apply global scale to test glyph positioning
|
||||
canvas->scale(1.05f, 1.05f);
|
||||
canvas->clear(0xffffffff);
|
||||
|
@ -73,7 +73,7 @@ protected:
|
||||
auto surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
|
||||
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
|
||||
// init our new canvas with the old canvas's matrix
|
||||
canvas->setMatrix(inputCanvas->getTotalMatrix());
|
||||
canvas->setMatrix(inputCanvas->getLocalToDeviceAs3x3());
|
||||
SkScalar x = 0, y = 0;
|
||||
SkScalar maxH = 0;
|
||||
for (auto twm : {TranslateWithMatrix::kNo, TranslateWithMatrix::kYes}) {
|
||||
|
@ -99,7 +99,7 @@ static void drawTestCase(SkCanvas* canvas,
|
||||
// This demonstrates that we can not measure the text if
|
||||
// there's a device transform. The canvas total matrix will
|
||||
// end up being a device transform.
|
||||
bool drawRef = !(canvas->getTotalMatrix().getType() &
|
||||
bool drawRef = !(canvas->getLocalToDeviceAs3x3().getType() &
|
||||
~(SkMatrix::kIdentity_Mask | SkMatrix::kTranslate_Mask));
|
||||
|
||||
SkRect bounds;
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
SkFilterQuality filterQuality,
|
||||
sk_sp<SkImageFilter> input) {
|
||||
SkRect dstRect;
|
||||
canvas->getTotalMatrix().mapRect(&dstRect, rect);
|
||||
canvas->getLocalToDeviceAs3x3().mapRect(&dstRect, rect);
|
||||
canvas->save();
|
||||
SkScalar deviceScaleX = deviceSize.width() / dstRect.width();
|
||||
SkScalar deviceScaleY = deviceSize.height() / dstRect.height();
|
||||
|
@ -32,6 +32,9 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
// Working on allow this to be undefined
|
||||
#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
|
||||
|
||||
class GrRecordingContext;
|
||||
class GrRenderTargetContext;
|
||||
class SkBaseDevice;
|
||||
@ -2433,6 +2436,14 @@ public:
|
||||
*/
|
||||
SkM44 getLocalToDevice() const;
|
||||
|
||||
/**
|
||||
* Throws away the 3rd row and column in the matrix, so be warned.
|
||||
*/
|
||||
SkMatrix getLocalToDeviceAs3x3() const {
|
||||
return this->getLocalToDevice().asM33();
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
|
||||
/** DEPRECATED
|
||||
* Legacy version of getLocalToDevice(), which strips away any Z information, and
|
||||
* just returns a 3x3 version.
|
||||
@ -2443,6 +2454,7 @@ public:
|
||||
* example: https://fiddle.skia.org/c/@Clip
|
||||
*/
|
||||
SkMatrix getTotalMatrix() const;
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -126,7 +126,7 @@ protected:
|
||||
}
|
||||
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
if (!canvas->getTotalMatrix().invert(&fInvMatrix)) {
|
||||
if (!canvas->getLocalToDeviceAs3x3().invert(&fInvMatrix)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ public:
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
// The local content, e.g. what would be submitted to drawRect or the bounds to saveLayer
|
||||
const SkRect localContentRect = SkRect::MakeLTRB(100.f, 20.f, 180.f, 140.f);
|
||||
SkMatrix ctm = canvas->getTotalMatrix();
|
||||
SkMatrix ctm = canvas->getLocalToDeviceAs3x3();
|
||||
|
||||
// Base rendering of a filter
|
||||
SkPaint blurPaint;
|
||||
|
@ -42,7 +42,7 @@ void SkBigPicture::playback(SkCanvas* canvas, AbortCallback* callback) const {
|
||||
void SkBigPicture::partialPlayback(SkCanvas* canvas,
|
||||
int start,
|
||||
int stop,
|
||||
const SkMatrix& initialCTM) const {
|
||||
const SkM44& initialCTM) const {
|
||||
SkASSERT(canvas);
|
||||
SkRecordPartialDraw(*fRecord,
|
||||
canvas,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef SkBigPicture_DEFINED
|
||||
#define SkBigPicture_DEFINED
|
||||
|
||||
#include "include/core/SkM44.h"
|
||||
#include "include/core/SkPicture.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/private/SkNoncopyable.h"
|
||||
@ -52,7 +53,7 @@ public:
|
||||
void partialPlayback(SkCanvas*,
|
||||
int start,
|
||||
int stop,
|
||||
const SkMatrix& initialCTM) const;
|
||||
const SkM44& initialCTM) const;
|
||||
// Used by GrRecordReplaceDraw
|
||||
const SkBBoxHierarchy* bbh() const { return fBBH.get(); }
|
||||
const SkRecord* record() const { return fRecord.get(); }
|
||||
|
@ -22,9 +22,7 @@ void SkDrawLooper::Context::Info::applyToCTM(SkMatrix* ctm) const {
|
||||
|
||||
void SkDrawLooper::Context::Info::applyToCanvas(SkCanvas* canvas) const {
|
||||
if (fApplyPostCTM) {
|
||||
SkMatrix ctm = canvas->getTotalMatrix();
|
||||
ctm.postTranslate(fTranslate.fX, fTranslate.fY);
|
||||
canvas->setMatrix(ctm);
|
||||
canvas->setMatrix(canvas->getLocalToDevice().postTranslate(fTranslate.fX, fTranslate.fY));
|
||||
} else {
|
||||
canvas->translate(fTranslate.fX, fTranslate.fY);
|
||||
}
|
||||
@ -95,9 +93,8 @@ void SkDrawLooper::apply(SkCanvas* canvas, const SkPaint& paint,
|
||||
}
|
||||
canvas->save();
|
||||
if (info.fApplyPostCTM) {
|
||||
SkMatrix ctm = canvas->getTotalMatrix();
|
||||
ctm.postTranslate(info.fTranslate.fX, info.fTranslate.fY);
|
||||
canvas->setMatrix(ctm);
|
||||
canvas->setMatrix(canvas->getLocalToDevice().postTranslate(info.fTranslate.fX,
|
||||
info.fTranslate.fY));
|
||||
} else {
|
||||
canvas->translate(info.fTranslate.fX, info.fTranslate.fY);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void SkRecordDraw(const SkRecord& record,
|
||||
void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas,
|
||||
SkPicture const* const drawablePicts[], int drawableCount,
|
||||
int start, int stop,
|
||||
const SkMatrix& initialCTM) {
|
||||
const SkM44& initialCTM) {
|
||||
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
|
||||
|
||||
stop = std::min(stop, record.count());
|
||||
@ -92,8 +92,8 @@ template <> void Draw::draw(const DrawBehind& r) {
|
||||
}
|
||||
|
||||
DRAW(MarkCTM, markCTM(r.name.c_str()));
|
||||
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
|
||||
DRAW(SetM44, setMatrix(SkM44(fInitialCTM) * r.matrix));
|
||||
DRAW(SetMatrix, setMatrix(fInitialCTM.asM33() * r.matrix));
|
||||
DRAW(SetM44, setMatrix(fInitialCTM * r.matrix));
|
||||
DRAW(Concat44, concat(r.matrix));
|
||||
DRAW(Concat, concat(r.matrix));
|
||||
DRAW(Translate, translate(r.dx, r.dy));
|
||||
|
@ -39,7 +39,7 @@ void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic
|
||||
// the initialCTM parameter must set to just the replay matrix.
|
||||
void SkRecordPartialDraw(const SkRecord&, SkCanvas*,
|
||||
SkPicture const* const drawablePicts[], int drawableCount,
|
||||
int start, int stop, const SkMatrix& initialCTM);
|
||||
int start, int stop, const SkM44& initialCTM);
|
||||
|
||||
namespace SkRecords {
|
||||
|
||||
@ -48,8 +48,8 @@ class Draw : SkNoncopyable {
|
||||
public:
|
||||
explicit Draw(SkCanvas* canvas, SkPicture const* const drawablePicts[],
|
||||
SkDrawable* const drawables[], int drawableCount,
|
||||
const SkMatrix* initialCTM = nullptr)
|
||||
: fInitialCTM(initialCTM ? *initialCTM : canvas->getTotalMatrix())
|
||||
const SkM44* initialCTM = nullptr)
|
||||
: fInitialCTM(initialCTM ? *initialCTM : canvas->getLocalToDevice())
|
||||
, fCanvas(canvas)
|
||||
, fDrawablePicts(drawablePicts)
|
||||
, fDrawables(drawables)
|
||||
@ -71,7 +71,7 @@ private:
|
||||
// No base case, so we'll be compile-time checked that we implement all possibilities.
|
||||
template <typename T> void draw(const T&);
|
||||
|
||||
const SkMatrix fInitialCTM;
|
||||
const SkM44 fInitialCTM;
|
||||
SkCanvas* fCanvas;
|
||||
SkPicture const* const* fDrawablePicts;
|
||||
SkDrawable* const* fDrawables;
|
||||
|
@ -1011,7 +1011,7 @@ void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
|
||||
void SkGpuDevice::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkCanvas* canvas) {
|
||||
GrBackendApi api = this->recordingContext()->backend();
|
||||
if (GrBackendApi::kVulkan == api) {
|
||||
const SkMatrix& ctm = canvas->getTotalMatrix();
|
||||
const SkMatrix& ctm = canvas->getLocalToDeviceAs3x3();
|
||||
const SkMatrix& combinedMatrix = matrix ? SkMatrix::Concat(ctm, *matrix) : ctm;
|
||||
std::unique_ptr<SkDrawable::GpuDrawHandler> gpuDraw =
|
||||
drawable->snapGpuDrawHandler(api, combinedMatrix, canvas->getDeviceClipBounds(),
|
||||
|
@ -37,7 +37,7 @@ SkPaintFilterCanvas::SkPaintFilterCanvas(SkCanvas *canvas)
|
||||
|
||||
// Transfer matrix & clip state before adding the target canvas.
|
||||
this->clipRect(SkRect::Make(canvas->getDeviceClipBounds()));
|
||||
this->setMatrix(canvas->getTotalMatrix());
|
||||
this->setMatrix(canvas->getLocalToDevice());
|
||||
|
||||
this->addCanvas(canvas);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ DEF_TEST(RecordDraw_PartialStartStop, r) {
|
||||
|
||||
SkRecord rerecord;
|
||||
SkRecorder canvas(&rerecord, kWidth, kHeight);
|
||||
SkRecordPartialDraw(record, &canvas, nullptr, 0, 1, 2, SkMatrix::I()); // replay just drawRect of r2
|
||||
SkRecordPartialDraw(record, &canvas, nullptr, 0, 1, 2, SkM44()); // replay just drawRect of r2
|
||||
|
||||
REPORTER_ASSERT(r, 1 == count_instances_of_type<SkRecords::DrawRect>(rerecord));
|
||||
int index = find_first_instances_of_type<SkRecords::DrawRect>(rerecord);
|
||||
|
@ -177,7 +177,7 @@ void DebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
|
||||
finalCanvas->restore();
|
||||
}
|
||||
|
||||
fMatrix = finalCanvas->getTotalMatrix();
|
||||
fMatrix = finalCanvas->getLocalToDevice();
|
||||
fClip = finalCanvas->getDeviceClipBounds();
|
||||
if (fShowOrigin) {
|
||||
const SkPaint originXPaint = SkPaint({1.0, 0, 0, 1.0});
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
/**
|
||||
Returns the most recently calculated transformation matrix
|
||||
*/
|
||||
const SkMatrix& getCurrentMatrix() { return fMatrix; }
|
||||
const SkM44& getCurrentMatrix() { return fMatrix; }
|
||||
|
||||
/**
|
||||
Returns the most recently calculated clip
|
||||
@ -219,7 +219,7 @@ protected:
|
||||
|
||||
private:
|
||||
SkTDArray<DrawCommand*> fCommandVector;
|
||||
SkMatrix fMatrix;
|
||||
SkM44 fMatrix;
|
||||
SkIRect fClip;
|
||||
|
||||
bool fOverdrawViz = false;
|
||||
|
@ -260,12 +260,12 @@ sk_sp<SkData> Request::getJsonInfo(int n) {
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kFast);
|
||||
|
||||
SkMatrix vm = fDebugCanvas->getCurrentMatrix();
|
||||
SkM44 vm = fDebugCanvas->getCurrentMatrix();
|
||||
SkIRect clip = fDebugCanvas->getCurrentClip();
|
||||
|
||||
writer.beginObject(); // root
|
||||
writer.appendName("ViewMatrix");
|
||||
DrawCommand::MakeJsonMatrix(writer, vm);
|
||||
DrawCommand::MakeJsonMatrix44(writer, vm);
|
||||
writer.appendName("ClipRect");
|
||||
DrawCommand::MakeJsonIRect(writer, clip);
|
||||
writer.endObject(); // root
|
||||
|
Loading…
Reference in New Issue
Block a user