More hiding of legacy drawImage calls
Also cleanup some of the duplicate code in SkRecords Bug: skia:7650 Change-Id: I4d3167a892c126c19a54002beab25c9a6c96fa5d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357000 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
3727917611
commit
e02d7f844b
@ -116,7 +116,7 @@ private:
|
||||
p.setColorFilter(fColorFilter);
|
||||
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
canvas->drawImage(fImage, 0, 0, &p);
|
||||
canvas->drawImage(fImage, 0, 0, SkSamplingOptions(), &p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ protected:
|
||||
// Draw reduced version of surface to original canvas, to trigger mip generation
|
||||
canvas->save();
|
||||
canvas->scale(0.1f, 0.1f);
|
||||
canvas->drawImage(fSurface->makeImageSnapshot(), 0, 0, &paint);
|
||||
canvas->drawImage(fSurface->makeImageSnapshot(), 0, 0, SkSamplingOptions(), &paint);
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ protected:
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kNone_SkFilterQuality);
|
||||
paint.setAntiAlias(true);
|
||||
static constexpr SkScalar kPad = 2;
|
||||
// To avoid tripping up bounds tracking we position the draws such that all the
|
||||
@ -71,7 +70,8 @@ protected:
|
||||
SkScalar imageYOffset = i * rowsPerImage * (kImageSize.fHeight + kPad);
|
||||
SkScalar rowYOffset = (r / imagesPerRow) * (kImageSize.fHeight + kPad);
|
||||
SkScalar x = (r % imagesPerRow) * (kImageSize.fWidth + kPad);
|
||||
canvas->drawImage(fImages[i].get(), x, imageYOffset + rowYOffset, &paint);
|
||||
canvas->drawImage(fImages[i].get(), x, imageYOffset + rowYOffset,
|
||||
SkSamplingOptions(), &paint);
|
||||
}
|
||||
}
|
||||
// Prevent any batching between "frames".
|
||||
|
@ -278,7 +278,7 @@ static void fuzz_drawImage(Fuzz* fuzz) {
|
||||
SkScalar a, b;
|
||||
fuzz->next(&a, &b);
|
||||
if (bl) {
|
||||
surface->getCanvas()->drawImage(image, a, b, &p);
|
||||
surface->getCanvas()->drawImage(image, a, b, SkSamplingOptions(), &p);
|
||||
}
|
||||
else {
|
||||
SkRect dst = SkRect::MakeWH(a, b);
|
||||
@ -287,7 +287,7 @@ static void fuzz_drawImage(Fuzz* fuzz) {
|
||||
uint8_t x;
|
||||
fuzz->nextRange(&x, 0, 1);
|
||||
SkCanvas::SrcRectConstraint cst = (SkCanvas::SrcRectConstraint)x;
|
||||
surface->getCanvas()->drawImageRect(image, src, dst, &p, cst);
|
||||
surface->getCanvas()->drawImageRect(image.get(), src, dst, SkSamplingOptions(), &p, cst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,7 @@ bool FuzzImageDecode(sk_sp<SkData> bytes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPaint p;
|
||||
s->getCanvas()->drawImage(img, 0, 0, &p);
|
||||
s->getCanvas()->drawImage(img, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -46,17 +46,17 @@ DEF_SIMPLE_GM(alpha_image, canvas, 256, 256) {
|
||||
|
||||
paint.setColorFilter(make_color_filter());
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 10.0f));
|
||||
canvas->drawImage(image.get(), 16, 16, &paint);
|
||||
canvas->drawImage(image.get(), 16, 16, SkSamplingOptions(), &paint);
|
||||
|
||||
paint.setColorFilter(nullptr);
|
||||
paint.setShader(SkShaders::Color(SK_ColorCYAN));
|
||||
canvas->drawImage(image.get(), 144, 16, &paint);
|
||||
canvas->drawImage(image.get(), 144, 16, SkSamplingOptions(), &paint);
|
||||
|
||||
paint.setColorFilter(make_color_filter());
|
||||
canvas->drawImage(image.get(), 16, 144, &paint);
|
||||
canvas->drawImage(image.get(), 16, 144, SkSamplingOptions(), &paint);
|
||||
|
||||
paint.setMaskFilter(nullptr);
|
||||
canvas->drawImage(image.get(), 144, 144, &paint);
|
||||
canvas->drawImage(image.get(), 144, 144, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
// Created to demonstrate skbug.com/10556 - GPU backend was failing to apply paint alpha to
|
||||
|
@ -26,9 +26,7 @@ DEF_SIMPLE_GM(bicubic, canvas, 300, 320) {
|
||||
|
||||
canvas->scale(40, 8);
|
||||
for (auto q : {kNone_SkFilterQuality, kLow_SkFilterQuality, kHigh_SkFilterQuality}) {
|
||||
SkPaint p;
|
||||
p.setFilterQuality(q);
|
||||
canvas->drawImage(img, 0, 0, &p);
|
||||
canvas->drawImage(img, 0, 0, SkSamplingOptions(q), nullptr);
|
||||
canvas->translate(0, img->height() + 1.0f);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ protected:
|
||||
SkRect bound3 = SkRect::MakeXYWH(320, 320,
|
||||
SkIntToScalar(kBitmapSize),
|
||||
SkIntToScalar(kBitmapSize));
|
||||
canvas->drawImageRect(fGreenImage.get(), bound2, bound3, nullptr,
|
||||
canvas->drawImageRect(fGreenImage.get(), bound2, bound3, SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->restore();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static sk_sp<SkImage> make_argb4444_gradient() {
|
||||
// Using draw rather than readPixels to suppress dither
|
||||
SkPaint paint;
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
SkCanvas{ bitmap }.drawImage(make_argb8888_gradient(), 0, 0, &paint);
|
||||
SkCanvas{ bitmap }.drawImage(make_argb8888_gradient(), 0, 0, SkSamplingOptions(), &paint);
|
||||
return bitmap.asImage();
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ static sk_sp<SkImage> make_argb4444_stripes() {
|
||||
// Using draw rather than readPixels to suppress dither
|
||||
SkPaint paint;
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
SkCanvas{ bitmap }.drawImage(make_argb8888_stripes(), 0, 0, &paint);
|
||||
SkCanvas{ bitmap }.drawImage(make_argb8888_stripes(), 0, 0, SkSamplingOptions(), &paint);
|
||||
return bitmap.asImage();
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ protected:
|
||||
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
auto sampling = SkSamplingOptions();
|
||||
|
||||
auto image = make_image();
|
||||
|
||||
@ -75,12 +76,13 @@ protected:
|
||||
SkRect srcR;
|
||||
srcR.set(src[i]);
|
||||
|
||||
canvas->drawImage(image, 0, 0, &paint);
|
||||
canvas->drawImage(image, 0, 0, sampling, &paint);
|
||||
if (!fUseIRect) {
|
||||
canvas->drawImageRect(image, srcR, dstR, &paint,
|
||||
canvas->drawImageRect(image.get(), srcR, dstR, sampling, &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
} else {
|
||||
canvas->drawImageRect(image, src[i], dstR, &paint);
|
||||
canvas->drawImageRect(image.get(), SkRect::Make(src[i]), dstR, sampling, &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
|
||||
canvas->drawRect(dstR, paint);
|
||||
|
@ -46,7 +46,7 @@ protected:
|
||||
};
|
||||
paint.setColorFilter(SkColorFilters::Matrix(opaqueGrayMatrix));
|
||||
|
||||
canvas->drawImage(bitmap.asImage(), 100.0f, 100.0f, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 100.0f, 100.0f, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -92,7 +92,6 @@ protected:
|
||||
|
||||
SkPaint fillPaint;
|
||||
fillPaint.setAntiAlias(true);
|
||||
fillPaint.setFilterQuality(kLow_SkFilterQuality);
|
||||
fillPaint.setColor(faceColors[i]);
|
||||
|
||||
// Leverages GrFillRectOp on GPU backend
|
||||
@ -101,7 +100,8 @@ protected:
|
||||
// Leverages GrTextureOp on GPU backend, to ensure sure both quad paths handle clipping
|
||||
canvas->drawImageRect(fCubeImage.get(),
|
||||
SkRect::MakeWH(fCubeImage->width(), fCubeImage->height()),
|
||||
SkRect::MakeWH(viewportWidth, viewportWidth), &fillPaint,
|
||||
SkRect::MakeWH(viewportWidth, viewportWidth),
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &fillPaint,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
|
||||
canvas->restore();
|
||||
|
@ -1659,6 +1659,10 @@ public:
|
||||
|
||||
void drawImage(const SkImage*, SkScalar x, SkScalar y, const SkSamplingOptions&,
|
||||
const SkPaint* = nullptr);
|
||||
void drawImage(const sk_sp<SkImage>& image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint = nullptr) {
|
||||
this->drawImage(image.get(), x, y, sampling, paint);
|
||||
}
|
||||
void drawImageRect(const SkImage*, const SkRect& src, const SkRect& dst,
|
||||
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
|
||||
void drawImageRect(const SkImage*, const SkRect& dst, const SkSamplingOptions&,
|
||||
@ -2480,11 +2484,6 @@ public:
|
||||
GrBackendRenderTarget topLayerBackendRenderTarget() const;
|
||||
#endif
|
||||
|
||||
// TEMP helpers until we switch virtual over to const& for src-rect
|
||||
void legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint,
|
||||
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
||||
|
||||
/**
|
||||
* Returns the global clip as a region. If the clip contains AA, then only the bounds
|
||||
* of the clip may be returned.
|
||||
|
@ -20,19 +20,8 @@ void Image::onRender(SkCanvas* canvas, const RenderContext* ctx) const {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignoring cubic params and trilerp for now.
|
||||
// TODO: convert to drawImage(sampling options) when available.
|
||||
auto legacy_quality = [](const SkSamplingOptions& sampling) {
|
||||
return
|
||||
sampling.useCubic ? SkFilterQuality::kHigh_SkFilterQuality :
|
||||
sampling.filter == SkFilterMode::kNearest ? SkFilterQuality::kNone_SkFilterQuality :
|
||||
sampling.mipmap == SkMipmapMode::kNone ? SkFilterQuality::kLow_SkFilterQuality :
|
||||
SkFilterQuality::kMedium_SkFilterQuality;
|
||||
};
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(fAntiAlias);
|
||||
SkPaintPriv::SetFQ(&paint, legacy_quality(fSamplingOptions));
|
||||
|
||||
sksg::RenderNode::ScopedRenderContext local_ctx(canvas, ctx);
|
||||
if (ctx) {
|
||||
@ -44,7 +33,7 @@ void Image::onRender(SkCanvas* canvas, const RenderContext* ctx) const {
|
||||
local_ctx->modulatePaint(canvas->getTotalMatrix(), &paint);
|
||||
}
|
||||
|
||||
canvas->drawImage(fImage, 0, 0, &paint);
|
||||
canvas->drawImage(fImage, 0, 0, fSamplingOptions, &paint);
|
||||
}
|
||||
|
||||
const RenderNode* Image::onNodeAt(const SkPoint& p) const {
|
||||
|
@ -21,25 +21,26 @@ static const int kWidth = 960;
|
||||
static const int kHeight = 640;
|
||||
|
||||
typedef void (*DrawAtlasProc)(SkCanvas*, SkImage*, const SkRSXform[], const SkRect[],
|
||||
const SkColor[], int, const SkRect*, const SkPaint*);
|
||||
const SkColor[], int, const SkRect*, const SkSamplingOptions&, const SkPaint*);
|
||||
|
||||
static void draw_atlas(SkCanvas* canvas, SkImage* atlas, const SkRSXform xform[],
|
||||
const SkRect tex[], const SkColor colors[], int count, const SkRect* cull,
|
||||
const SkPaint* paint) {
|
||||
canvas->drawAtlas(atlas, xform, tex, colors, count, SkBlendMode::kModulate, cull, paint);
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
canvas->drawAtlas(atlas, xform, tex, colors, count, SkBlendMode::kModulate, sampling,
|
||||
cull, paint);
|
||||
}
|
||||
|
||||
static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xform[],
|
||||
const SkRect tex[], const SkColor colors[], int count, const SkRect* cull,
|
||||
const SkPaint* paint) {
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
SkMatrix matrix;
|
||||
matrix.setRSXform(xform[i]);
|
||||
|
||||
canvas->save();
|
||||
canvas->concat(matrix);
|
||||
canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()), paint,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()),
|
||||
sampling, paint, SkCanvas::kFast_SrcRectConstraint);
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
@ -97,7 +98,6 @@ protected:
|
||||
}
|
||||
|
||||
SkPaint paint;
|
||||
SkPaintPriv::SetFQ(&paint, kLow_SkFilterQuality);
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
|
||||
SkScalar anchorX = fAtlas->width()*0.5f;
|
||||
@ -118,7 +118,8 @@ protected:
|
||||
fXform[i].fTy += dy;
|
||||
}
|
||||
|
||||
fProc(canvas, fAtlas.get(), fXform, fTex, nullptr, kGrid*kGrid+1, nullptr, &paint);
|
||||
fProc(canvas, fAtlas.get(), fXform, fTex, nullptr, kGrid*kGrid+1, nullptr,
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &paint);
|
||||
}
|
||||
|
||||
bool onAnimate(double nanos) override {
|
||||
|
@ -40,9 +40,10 @@ struct TimingSample : public Sample {
|
||||
for (int y = 0; y < H; y++)
|
||||
for (int x = 0; x < W; x++) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
canvas->drawImageRect(fImg, SkRect::MakeXYWH(x,y,1,1)
|
||||
, SkRect::MakeXYWH(x,y,1,1)
|
||||
, /*paint=*/nullptr);
|
||||
canvas->drawImageRect(fImg.get(),
|
||||
SkRect::MakeXYWH(x,y,1,1), SkRect::MakeXYWH(x,y,1,1),
|
||||
SkSamplingOptions(), /*paint=*/nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
auto elapsed = std::chrono::steady_clock::now() - start;
|
||||
|
||||
cost[y][x] = elapsed.count();
|
||||
|
@ -343,9 +343,7 @@ void SkAnimatedImage::onDraw(SkCanvas* canvas) {
|
||||
{
|
||||
SkAutoCanvasRestore acr(canvas, fPostProcess != nullptr);
|
||||
canvas->concat(fMatrix);
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
canvas->drawImage(image, 0, 0, &paint);
|
||||
canvas->drawImage(image, 0, 0, SkSamplingOptions(SkFilterMode::kLinear), nullptr);
|
||||
}
|
||||
if (fPostProcess) {
|
||||
canvas->drawPicture(fPostProcess);
|
||||
|
@ -2000,17 +2000,6 @@ void SkCanvas::drawAnnotation(const SkRect& rect, const char key[], SkData* valu
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
|
||||
const SkPaint* paint, SrcRectConstraint constraint) {
|
||||
RETURN_ON_NULL(image);
|
||||
if (src) {
|
||||
this->drawImageRect(image, *src, dst, paint, constraint);
|
||||
} else {
|
||||
this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()),
|
||||
dst, paint, constraint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::private_draw_shadow_rec(const SkPath& path, const SkDrawShadowRec& rec) {
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
this->onDrawShadowRec(path, rec);
|
||||
|
@ -417,7 +417,13 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
|
||||
}
|
||||
BREAK_ON_READ_ERROR(reader);
|
||||
|
||||
canvas->legacy_drawImageRect(image, src, dst, paint, constraint);
|
||||
auto sampling = SkSamplingOptions(paint ? paint->getFilterQuality()
|
||||
: kNone_SkFilterQuality);
|
||||
if (src) {
|
||||
canvas->drawImageRect(image, *src, dst, sampling, paint, constraint);
|
||||
} else {
|
||||
canvas->drawImageRect(image, dst, sampling, paint, constraint);
|
||||
}
|
||||
} break;
|
||||
case DRAW_IMAGE_RECT2: {
|
||||
const SkPaint* paint = fPictureData->optionalPaint(reader);
|
||||
|
@ -107,22 +107,9 @@ DRAW(ClipShader, clipShader(r.shader, r.op));
|
||||
|
||||
DRAW(DrawArc, drawArc(r.oval, r.startAngle, r.sweepAngle, r.useCenter, r.paint));
|
||||
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
|
||||
DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.paint));
|
||||
DRAW(DrawImage2, drawImage(r.image.get(), r.left, r.top, r.sampling, r.paint));
|
||||
DRAW(DrawImage, drawImage(r.image.get(), r.left, r.top, r.sampling, r.paint));
|
||||
|
||||
template <> void Draw::draw(const DrawImageLattice& r) {
|
||||
SkCanvas::Lattice lattice;
|
||||
lattice.fXCount = r.xCount;
|
||||
lattice.fXDivs = r.xDivs;
|
||||
lattice.fYCount = r.yCount;
|
||||
lattice.fYDivs = r.yDivs;
|
||||
lattice.fRectTypes = (0 == r.flagCount) ? nullptr : r.flags;
|
||||
lattice.fColors = (0 == r.flagCount) ? nullptr : r.colors;
|
||||
lattice.fBounds = &r.src;
|
||||
fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.paint);
|
||||
}
|
||||
|
||||
template <> void Draw::draw(const DrawImageLattice2& r) {
|
||||
SkCanvas::Lattice lattice;
|
||||
lattice.fXCount = r.xCount;
|
||||
lattice.fXDivs = r.xDivs;
|
||||
@ -134,8 +121,7 @@ template <> void Draw::draw(const DrawImageLattice2& r) {
|
||||
fCanvas->drawImageLattice(r.image.get(), lattice, r.dst, r.filter, r.paint);
|
||||
}
|
||||
|
||||
DRAW(DrawImageRect, legacy_drawImageRect(r.image.get(), r.src, r.dst, r.paint, r.constraint));
|
||||
DRAW(DrawImageRect2, drawImageRect(r.image.get(), r.src, r.dst, r.sampling, r.paint, r.constraint));
|
||||
DRAW(DrawImageRect, drawImageRect(r.image.get(), r.src, r.dst, r.sampling, r.paint, r.constraint));
|
||||
DRAW(DrawOval, drawOval(r.oval, r.paint));
|
||||
DRAW(DrawPaint, drawPaint(r.paint));
|
||||
DRAW(DrawPath, drawPath(r.path, r.paint));
|
||||
@ -146,10 +132,8 @@ DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
|
||||
DRAW(DrawRect, drawRect(r.rect, r.paint));
|
||||
DRAW(DrawRegion, drawRegion(r.region, r.paint));
|
||||
DRAW(DrawTextBlob, drawTextBlob(r.blob.get(), r.x, r.y, r.paint));
|
||||
DRAW(DrawAtlas, drawAtlas(r.atlas.get(),
|
||||
r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint));
|
||||
DRAW(DrawAtlas2, drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.sampling,
|
||||
r.cull, r.paint));
|
||||
DRAW(DrawAtlas, drawAtlas(r.atlas.get(), r.xforms, r.texs, r.colors, r.count, r.mode, r.sampling,
|
||||
r.cull, r.paint));
|
||||
DRAW(DrawVertices, drawVertices(r.vertices, r.bmode, r.paint));
|
||||
DRAW(DrawShadowRec, private_draw_shadow_rec(r.path, r.rec));
|
||||
DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get()));
|
||||
@ -157,8 +141,6 @@ DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get()));
|
||||
DRAW(DrawEdgeAAQuad, experimental_DrawEdgeAAQuad(
|
||||
r.rect, r.clip, r.aa, r.color, r.mode));
|
||||
DRAW(DrawEdgeAAImageSet, experimental_DrawEdgeAAImageSet(
|
||||
r.set.get(), r.count, r.dstClips, r.preViewMatrices, r.paint, r.constraint));
|
||||
DRAW(DrawEdgeAAImageSet2, experimental_DrawEdgeAAImageSet(
|
||||
r.set.get(), r.count, r.dstClips, r.preViewMatrices, r.sampling, r.paint, r.constraint));
|
||||
|
||||
#undef DRAW
|
||||
@ -417,24 +399,12 @@ private:
|
||||
|
||||
return this->adjustAndMap(rect, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawImage2& op) const {
|
||||
const SkImage* image = op.image.get();
|
||||
SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height());
|
||||
|
||||
return this->adjustAndMap(rect, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawImageLattice& op) const {
|
||||
return this->adjustAndMap(op.dst, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawImageLattice2& op) const {
|
||||
return this->adjustAndMap(op.dst, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawImageRect& op) const {
|
||||
return this->adjustAndMap(op.dst, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawImageRect2& op) const {
|
||||
return this->adjustAndMap(op.dst, op.paint);
|
||||
}
|
||||
Bounds bounds(const DrawPath& op) const {
|
||||
return op.path.isInverseFillType() ? fCullRect
|
||||
: this->adjustAndMap(op.path.getBounds(), &op.paint);
|
||||
@ -468,16 +438,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
Bounds bounds(const DrawAtlas2& op) const {
|
||||
if (op.cull) {
|
||||
// TODO: <reed> can we pass nullptr for the paint? Isn't cull already "correct"
|
||||
// for the paint (by the caller)?
|
||||
return this->adjustAndMap(*op.cull, op.paint);
|
||||
} else {
|
||||
return fCullRect;
|
||||
}
|
||||
}
|
||||
|
||||
Bounds bounds(const DrawShadowRec& op) const {
|
||||
SkRect bounds;
|
||||
SkDrawShadowMetrics::GetLocalBounds(op.path, op.rec, fCTM, &bounds);
|
||||
@ -526,22 +486,6 @@ private:
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
Bounds bounds(const DrawEdgeAAImageSet2& op) const {
|
||||
SkRect rect = SkRect::MakeEmpty();
|
||||
int clipIndex = 0;
|
||||
for (int i = 0; i < op.count; ++i) {
|
||||
SkRect entryBounds = op.set[i].fDstRect;
|
||||
if (op.set[i].fHasClip) {
|
||||
entryBounds.setBounds(op.dstClips + clipIndex, 4);
|
||||
clipIndex += 4;
|
||||
}
|
||||
if (op.set[i].fMatrixIndex >= 0) {
|
||||
op.preViewMatrices[op.set[i].fMatrixIndex].mapRect(&entryBounds);
|
||||
}
|
||||
rect.join(this->adjustAndMap(entryBounds, nullptr));
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
// Returns true if rect was meaningfully adjusted for the effects of paint,
|
||||
// false if the paint could affect the rect in unknown ways.
|
||||
|
@ -206,21 +206,21 @@ void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
|
||||
void SkRecorder::onDrawImage2(const SkImage* image, SkScalar x, SkScalar y,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint) {
|
||||
this->append<SkRecords::DrawImage2>(this->copy(paint), sk_ref_sp(image), x, y, sampling);
|
||||
this->append<SkRecords::DrawImage>(this->copy(paint), sk_ref_sp(image), x, y, sampling);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawImageRect2(const SkImage* image, const SkRect& src, const SkRect& dst,
|
||||
const SkSamplingOptions& sampling, const SkPaint* paint,
|
||||
SrcRectConstraint constraint) {
|
||||
this->append<SkRecords::DrawImageRect2>(this->copy(paint), sk_ref_sp(image), src, dst,
|
||||
sampling, constraint);
|
||||
this->append<SkRecords::DrawImageRect>(this->copy(paint), sk_ref_sp(image), src, dst,
|
||||
sampling, constraint);
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawImageLattice2(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
||||
SkFilterMode filter, const SkPaint* paint) {
|
||||
int flagCount = lattice.fRectTypes ? (lattice.fXCount + 1) * (lattice.fYCount + 1) : 0;
|
||||
SkASSERT(lattice.fBounds);
|
||||
this->append<SkRecords::DrawImageLattice2>(this->copy(paint), sk_ref_sp(image),
|
||||
this->append<SkRecords::DrawImageLattice>(this->copy(paint), sk_ref_sp(image),
|
||||
lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
|
||||
lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount),
|
||||
flagCount, this->copy(lattice.fRectTypes, flagCount),
|
||||
@ -259,7 +259,7 @@ void SkRecorder::onDrawAtlas2(const SkImage* atlas, const SkRSXform xform[], con
|
||||
const SkColor colors[], int count, SkBlendMode mode,
|
||||
const SkSamplingOptions& sampling, const SkRect* cull,
|
||||
const SkPaint* paint) {
|
||||
this->append<SkRecords::DrawAtlas2>(this->copy(paint),
|
||||
this->append<SkRecords::DrawAtlas>(this->copy(paint),
|
||||
sk_ref_sp(atlas),
|
||||
this->copy(xform, count),
|
||||
this->copy(tex, count),
|
||||
@ -296,7 +296,7 @@ void SkRecorder::onDrawEdgeAAImageSet2(const ImageSetEntry set[], int count,
|
||||
setCopy[i] = set[i];
|
||||
}
|
||||
|
||||
this->append<SkRecords::DrawEdgeAAImageSet2>(this->copy(paint), std::move(setCopy), count,
|
||||
this->append<SkRecords::DrawEdgeAAImageSet>(this->copy(paint), std::move(setCopy), count,
|
||||
this->copy(dstClips, totalDstClipCount),
|
||||
this->copy(preViewMatrices, totalMatrixCount), sampling, constraint);
|
||||
}
|
||||
|
@ -62,9 +62,6 @@ namespace SkRecords {
|
||||
M(DrawImage) \
|
||||
M(DrawImageLattice) \
|
||||
M(DrawImageRect) \
|
||||
M(DrawImage2) \
|
||||
M(DrawImageLattice2) \
|
||||
M(DrawImageRect2) \
|
||||
M(DrawDRRect) \
|
||||
M(DrawOval) \
|
||||
M(DrawBehind) \
|
||||
@ -78,13 +75,11 @@ namespace SkRecords {
|
||||
M(DrawRegion) \
|
||||
M(DrawTextBlob) \
|
||||
M(DrawAtlas) \
|
||||
M(DrawAtlas2) \
|
||||
M(DrawVertices) \
|
||||
M(DrawShadowRec) \
|
||||
M(DrawAnnotation) \
|
||||
M(DrawEdgeAAQuad) \
|
||||
M(DrawEdgeAAImageSet) \
|
||||
M(DrawEdgeAAImageSet2)
|
||||
M(DrawEdgeAAImageSet)
|
||||
|
||||
|
||||
// Defines SkRecords::Type, an enum of all record types.
|
||||
@ -240,29 +235,12 @@ RECORD(DrawDrawable, kDraw_Tag,
|
||||
SkRect worstCaseBounds;
|
||||
int32_t index);
|
||||
RECORD(DrawImage, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
SkScalar left;
|
||||
SkScalar top);
|
||||
RECORD(DrawImage2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
SkScalar left;
|
||||
SkScalar top;
|
||||
SkSamplingOptions sampling);
|
||||
RECORD(DrawImageLattice, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
int xCount;
|
||||
PODArray<int> xDivs;
|
||||
int yCount;
|
||||
PODArray<int> yDivs;
|
||||
int flagCount;
|
||||
PODArray<SkCanvas::Lattice::RectType> flags;
|
||||
PODArray<SkColor> colors;
|
||||
SkIRect src;
|
||||
SkRect dst);
|
||||
RECORD(DrawImageLattice2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
int xCount;
|
||||
@ -276,12 +254,6 @@ RECORD(DrawImageLattice2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
SkRect dst;
|
||||
SkFilterMode filter);
|
||||
RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
Optional<SkRect> src;
|
||||
SkRect dst;
|
||||
SkCanvas::SrcRectConstraint constraint);
|
||||
RECORD(DrawImageRect2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> image;
|
||||
SkRect src;
|
||||
@ -328,15 +300,6 @@ RECORD(DrawPatch, kDraw_Tag|kHasPaint_Tag,
|
||||
PODArray<SkPoint> texCoords;
|
||||
SkBlendMode bmode);
|
||||
RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> atlas;
|
||||
PODArray<SkRSXform> xforms;
|
||||
PODArray<SkRect> texs;
|
||||
PODArray<SkColor> colors;
|
||||
int count;
|
||||
SkBlendMode mode;
|
||||
Optional<SkRect> cull);
|
||||
RECORD(DrawAtlas2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
sk_sp<const SkImage> atlas;
|
||||
PODArray<SkRSXform> xforms;
|
||||
@ -364,13 +327,6 @@ RECORD(DrawEdgeAAQuad, kDraw_Tag,
|
||||
SkColor4f color;
|
||||
SkBlendMode mode);
|
||||
RECORD(DrawEdgeAAImageSet, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
SkAutoTArray<SkCanvas::ImageSetEntry> set;
|
||||
int count;
|
||||
PODArray<SkPoint> dstClips;
|
||||
PODArray<SkMatrix> preViewMatrices;
|
||||
SkCanvas::SrcRectConstraint constraint);
|
||||
RECORD(DrawEdgeAAImageSet2, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
|
||||
Optional<SkPaint> paint;
|
||||
SkAutoTArray<SkCanvas::ImageSetEntry> set;
|
||||
int count;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
static void draw(SkCanvas* canvas, const SkImage* image, SkColor4f paintColor) {
|
||||
SkPaint paint(paintColor);
|
||||
canvas->drawImage(image, 0, 0, &paint);
|
||||
canvas->drawImage(image, 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
static SkBitmap to_bitmap(const SkImage* image) {
|
||||
|
@ -90,7 +90,7 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
|
||||
Tally tally;
|
||||
tally.apply(record);
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage2>());
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>());
|
||||
}
|
||||
REPORTER_ASSERT(reporter, image->unique());
|
||||
|
||||
@ -106,7 +106,7 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
|
||||
Tally tally;
|
||||
tally.apply(record);
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect2>());
|
||||
REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
|
||||
}
|
||||
REPORTER_ASSERT(reporter, image->unique());
|
||||
}
|
||||
|
@ -127,7 +127,9 @@ void DDLTileHelper::createComposeDDL() {
|
||||
|
||||
SkASSERT(promiseImage->bounds().contains(srcRect));
|
||||
|
||||
recordingCanvas->drawImageRect(promiseImage.get(), srcRect, dstRect, nullptr);
|
||||
recordingCanvas->drawImageRect(promiseImage.get(), SkRect::Make(srcRect), dstRect,
|
||||
SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
|
||||
fComposeDDL = recorder.detach();
|
||||
|
@ -434,7 +434,8 @@ void DebugCanvas::onDrawImageRect2(const SkImage* image,
|
||||
// Instead of adding a DrawImageRectCommand, we need a deferred command, that when
|
||||
// executed, will call drawImageRect(fLayerManager->getLayerAsImage())
|
||||
this->addDrawCommand(new DrawImageRectLayerCommand(
|
||||
fLayerManager, fnextDrawImageRectLayerId, fFrame, &src, dst, paint, constraint));
|
||||
fLayerManager, fnextDrawImageRectLayerId, fFrame, src, dst, sampling,
|
||||
paint, constraint));
|
||||
} else {
|
||||
this->addDrawCommand(new DrawImageRectCommand(image, src, dst, sampling, paint, constraint));
|
||||
}
|
||||
|
@ -1354,8 +1354,9 @@ void DrawImageRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataM
|
||||
DrawImageRectLayerCommand::DrawImageRectLayerCommand(DebugLayerManager* layerManager,
|
||||
const int nodeId,
|
||||
const int frame,
|
||||
const SkRect* src,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint)
|
||||
: INHERITED(kDrawImageRectLayer_OpType)
|
||||
@ -1364,13 +1365,13 @@ DrawImageRectLayerCommand::DrawImageRectLayerCommand(DebugLayerManager* layer
|
||||
, fFrame(frame)
|
||||
, fSrc(src)
|
||||
, fDst(dst)
|
||||
, fSampling(sampling)
|
||||
, fPaint(paint)
|
||||
, fConstraint(constraint) {}
|
||||
|
||||
void DrawImageRectLayerCommand::execute(SkCanvas* canvas) const {
|
||||
sk_sp<SkImage> snapshot = fLayerManager->getLayerAsImage(fNodeId, fFrame);
|
||||
canvas->legacy_drawImageRect(
|
||||
snapshot.get(), fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
|
||||
canvas->drawImageRect(snapshot.get(), fSrc, fDst, SkSamplingOptions(), fPaint.getMaybeNull(), fConstraint);
|
||||
}
|
||||
|
||||
bool DrawImageRectLayerCommand::render(SkCanvas* canvas) const {
|
||||
@ -1392,10 +1393,9 @@ void DrawImageRectLayerCommand::toJSON(SkJSONWriter& writer, UrlDataManager& url
|
||||
// Append the node id, and the layer inspector of the debugger will know what to do with it.
|
||||
writer.appendS64(DEBUGCANVAS_ATTRIBUTE_LAYERNODEID, fNodeId);
|
||||
|
||||
if (fSrc.isValid()) {
|
||||
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
|
||||
MakeJsonRect(writer, *fSrc);
|
||||
}
|
||||
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
|
||||
MakeJsonRect(writer, fSrc);
|
||||
|
||||
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
||||
MakeJsonRect(writer, fDst);
|
||||
if (fPaint.isValid()) {
|
||||
|
@ -321,8 +321,9 @@ public:
|
||||
DrawImageRectLayerCommand(DebugLayerManager* layerManager,
|
||||
const int nodeId,
|
||||
const int frame,
|
||||
const SkRect* src,
|
||||
const SkRect& src,
|
||||
const SkRect& dst,
|
||||
const SkSamplingOptions& sampling,
|
||||
const SkPaint* paint,
|
||||
SkCanvas::SrcRectConstraint constraint);
|
||||
void execute(SkCanvas* canvas) const override;
|
||||
@ -333,8 +334,9 @@ private:
|
||||
DebugLayerManager* fLayerManager;
|
||||
int fNodeId;
|
||||
int fFrame;
|
||||
SkTLazy<SkRect> fSrc;
|
||||
SkRect fSrc;
|
||||
SkRect fDst;
|
||||
SkSamplingOptions fSampling;
|
||||
SkTLazy<SkPaint> fPaint;
|
||||
SkCanvas::SrcRectConstraint fConstraint;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user