add sampling param to drawAtlas

Bug: skia:7650
Change-Id: I8e72870775736c8bab7b077208b275372f632bc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347961
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2020-12-28 22:31:12 -05:00 committed by Skia Commit-Bot
parent 9dc8a8ce40
commit 7027aa0ae7
9 changed files with 20 additions and 17 deletions

View File

@ -557,13 +557,14 @@ void SkBitmapDevice::drawVertices(const SkVertices* vertices, SkBlendMode bmode,
void SkBitmapDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkBlendMode mode, const SkPaint& paint) {
SkBlendMode mode, const SkSamplingOptions& sampling,
const SkPaint& paint) {
// set this to true for performance comparisons with the old drawVertices way
if (false) {
this->INHERITED::drawAtlas(atlas, xform, tex, colors, count, mode, paint);
this->INHERITED::drawAtlas(atlas, xform, tex, colors, count, mode, sampling, paint);
return;
}
BDDraw(this).drawAtlas(atlas, xform, tex, colors, count, mode, paint);
BDDraw(this).drawAtlas(atlas, xform, tex, colors, count, mode, sampling, paint);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -97,7 +97,7 @@ protected:
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
SkBlendMode, const SkPaint&) override;
SkBlendMode, const SkSamplingOptions&, const SkPaint&) override;
///////////////////////////////////////////////////////////////////////////

View File

@ -2487,13 +2487,14 @@ void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const
const SkRect* cull, const SkPaint* paint) {
// drawAtlas is a combination of drawVertices and drawImage...
SkPaint realPaint = clean_paint_for_drawVertices(clean_paint_for_drawImage(paint));
SkSamplingOptions sampling(paint_to_sampling(paint, this->recordingContext()));
if (cull && this->internalQuickReject(*cull, realPaint)) {
return;
}
AutoLayerForImageFilter layer(this, realPaint);
this->topDevice()->drawAtlas(atlas, xform, tex, colors, count, bmode, layer.paint());
this->topDevice()->drawAtlas(atlas, xform, tex, colors, count, bmode, sampling, layer.paint());
}
void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {

View File

@ -206,7 +206,8 @@ static SkPoint* quad_to_tris(SkPoint tris[6], const SkPoint quad[4]) {
void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int quadCount,
SkBlendMode mode, const SkPaint& paint) {
SkBlendMode mode, const SkSamplingOptions& sampling,
const SkPaint& paint) {
const int triCount = quadCount << 1;
const int vertexCount = triCount * 3;
uint32_t flags = SkVertices::kHasTexCoords_BuilderFlag;
@ -232,7 +233,7 @@ void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
}
}
SkPaint p(paint);
p.setShader(atlas->makeShader(SkSamplingOptions()));
p.setShader(atlas->makeShader(sampling));
this->drawVertices(builder.detach().get(), mode, p);
}

View File

@ -283,7 +283,8 @@ protected:
// default implementation calls drawPath
virtual void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[],
const SkColor[], int count, SkBlendMode, const SkPaint&);
const SkColor[], int count, SkBlendMode, const SkSamplingOptions&,
const SkPaint&);
virtual void drawAnnotation(const SkRect&, const char[], SkData*) {}

View File

@ -65,7 +65,7 @@ public:
SkGlyphRunListPainter* glyphPainter) const;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) const;
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
SkBlendMode, const SkPaint&);
SkBlendMode, const SkSamplingOptions&, const SkPaint&);
/**
* Overwrite the target with the path's coverage (i.e. its mask).

View File

@ -47,8 +47,9 @@ static void load_color(SkRasterPipeline_UniformColorCtx* ctx, const float rgba[]
}
void SkDraw::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect textures[],
const SkColor colors[], int count, SkBlendMode bmode, const SkPaint& paint) {
sk_sp<SkShader> atlasShader = atlas->makeShader(SkSamplingOptions(paint.getFilterQuality()));
const SkColor colors[], int count, SkBlendMode bmode,
const SkSamplingOptions& sampling, const SkPaint& paint) {
sk_sp<SkShader> atlasShader = atlas->makeShader(sampling);
if (!atlasShader) {
return;
}

View File

@ -938,12 +938,10 @@ void SkGpuDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
///////////////////////////////////////////////////////////////////////////////
// TODO: pass samplingoptions explicitly
void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
const SkRect texRect[], const SkColor colors[], int count,
SkBlendMode mode, const SkPaint& paint) {
SkSamplingOptions sampling(paint.getFilterQuality(), SkSamplingOptions::kMedium_asMipmapLinear);
SkBlendMode mode, const SkSamplingOptions& sampling,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawAtlas", fContext.get());

View File

@ -105,8 +105,8 @@ public:
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawShadow(const SkPath&, const SkDrawShadowRec&) override;
void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[],
const SkColor[], int count, SkBlendMode, const SkPaint&) override;
void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkSamplingOptions&, const SkPaint&) override;
void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkSamplingOptions&, const SkPaint&,