Merge "Store filterbitmap on Paint"

This commit is contained in:
Mike Reed
2021-07-12 19:16:36 +00:00
committed by Android (Google) Code Review
18 changed files with 92 additions and 107 deletions

View File

@@ -15,6 +15,7 @@
*/
#include "RecordingCanvas.h"
#include <hwui/Paint.h>
#include <GrRecordingContext.h>
@@ -495,7 +496,7 @@ struct DrawVectorDrawable final : Op {
sp<VectorDrawableRoot> mRoot;
SkRect mBounds;
SkPaint paint;
Paint paint;
BitmapPalette palette;
};
@@ -833,7 +834,8 @@ constexpr color_transform_fn colorTransformForOp() {
// TODO: We should be const. Or not. Or just use a different map
// Unclear, but this is the quick fix
const T* op = reinterpret_cast<const T*>(opRaw);
transformPaint(transform, const_cast<SkPaint*>(&(op->paint)), op->palette);
const SkPaint* paint = &op->paint;
transformPaint(transform, const_cast<SkPaint*>(paint), op->palette);
};
}
else if
@@ -842,7 +844,8 @@ constexpr color_transform_fn colorTransformForOp() {
// TODO: We should be const. Or not. Or just use a different map
// Unclear, but this is the quick fix
const T* op = reinterpret_cast<const T*>(opRaw);
transformPaint(transform, const_cast<SkPaint*>(&(op->paint)));
const SkPaint* paint = &op->paint;
transformPaint(transform, const_cast<SkPaint*>(paint));
};
}
else {

View File

@@ -182,7 +182,7 @@ int SkiaCanvas::saveUnclippedLayer(int left, int top, int right, int bottom) {
return SkAndroidFrameworkUtils::SaveBehind(mCanvas, &bounds);
}
void SkiaCanvas::restoreUnclippedLayer(int restoreCount, const SkPaint& paint) {
void SkiaCanvas::restoreUnclippedLayer(int restoreCount, const Paint& paint) {
while (mCanvas->getSaveCount() > restoreCount + 1) {
this->restore();
@@ -439,13 +439,13 @@ void SkiaCanvas::drawColor(int color, SkBlendMode mode) {
mCanvas->drawColor(color, mode);
}
void SkiaCanvas::onFilterPaint(SkPaint& paint) {
void SkiaCanvas::onFilterPaint(Paint& paint) {
if (mPaintFilter) {
mPaintFilter->filter(&paint);
mPaintFilter->filterFullPaint(&paint);
}
}
void SkiaCanvas::drawPaint(const SkPaint& paint) {
void SkiaCanvas::drawPaint(const Paint& paint) {
mCanvas->drawPaint(filterPaint(paint));
}
@@ -552,9 +552,8 @@ void SkiaCanvas::drawVertices(const SkVertices* vertices, SkBlendMode mode, cons
void SkiaCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const Paint* paint) {
auto image = bitmap.makeImage();
applyLooper(paint, [&](const SkPaint& p) {
auto sampling = SkSamplingOptions(p.getFilterQuality());
mCanvas->drawImage(image, left, top, sampling, &p);
applyLooper(paint, [&](const Paint& p) {
mCanvas->drawImage(image, left, top, p.sampling(), &p);
});
}
@@ -562,9 +561,8 @@ void SkiaCanvas::drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, const Paint*
auto image = bitmap.makeImage();
SkAutoCanvasRestore acr(mCanvas, true);
mCanvas->concat(matrix);
applyLooper(paint, [&](const SkPaint& p) {
auto sampling = SkSamplingOptions(p.getFilterQuality());
mCanvas->drawImage(image, 0, 0, sampling, &p);
applyLooper(paint, [&](const Paint& p) {
mCanvas->drawImage(image, 0, 0, p.sampling(), &p);
});
}
@@ -575,18 +573,12 @@ void SkiaCanvas::drawBitmap(Bitmap& bitmap, float srcLeft, float srcTop, float s
SkRect srcRect = SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom);
SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
applyLooper(paint, [&](const SkPaint& p) {
auto sampling = SkSamplingOptions(p.getFilterQuality());
mCanvas->drawImageRect(image, srcRect, dstRect, sampling, &p,
applyLooper(paint, [&](const Paint& p) {
mCanvas->drawImageRect(image, srcRect, dstRect, p.sampling(), &p,
SkCanvas::kFast_SrcRectConstraint);
});
}
static SkFilterMode paintToFilter(const Paint* paint) {
return paint && paint->isFilterBitmap() ? SkFilterMode::kLinear
: SkFilterMode::kNearest;
}
void SkiaCanvas::drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight,
const float* vertices, const int* colors, const Paint* paint) {
const int ptCount = (meshWidth + 1) * (meshHeight + 1);
@@ -668,13 +660,13 @@ void SkiaCanvas::drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight,
if (paint) {
pnt = *paint;
}
SkSamplingOptions sampling(paintToFilter(&pnt));
SkSamplingOptions sampling = pnt.sampling();
pnt.setShader(image->makeShader(sampling));
auto v = builder.detach();
applyLooper(&pnt, [&](const SkPaint& p) {
applyLooper(&pnt, [&](const Paint& p) {
SkPaint copy(p);
auto s = SkSamplingOptions(p.getFilterQuality());
auto s = p.sampling();
if (s != sampling) {
// applyLooper changed the quality?
copy.setShader(image->makeShader(s));
@@ -707,9 +699,8 @@ void SkiaCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& chunk, floa
lattice.fBounds = nullptr;
SkRect dst = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
auto image = bitmap.makeImage();
applyLooper(paint, [&](const SkPaint& p) {
auto filter = SkSamplingOptions(p.getFilterQuality()).filter;
mCanvas->drawImageLattice(image.get(), lattice, dst, filter, &p);
applyLooper(paint, [&](const Paint& p) {
mCanvas->drawImageLattice(image.get(), lattice, dst, p.filterMode(), &p);
});
}

View File

@@ -23,6 +23,7 @@
#include "VectorDrawable.h"
#include "hwui/Canvas.h"
#include "hwui/Paint.h"
#include "hwui/BlurDrawLooper.h"
#include <SkCanvas.h>
#include "pipeline/skia/AnimatedDrawables.h"
@@ -73,7 +74,7 @@ public:
virtual int save(SaveFlags::Flags flags) override;
virtual void restore() override;
virtual void restoreToCount(int saveCount) override;
virtual void restoreUnclippedLayer(int saveCount, const SkPaint& paint) override;
virtual void restoreUnclippedLayer(int saveCount, const Paint& paint) override;
virtual int saveLayer(float left, float top, float right, float bottom, const SkPaint* paint) override;
virtual int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) override;
@@ -99,7 +100,7 @@ public:
virtual SkCanvasState* captureCanvasState() const override;
virtual void drawColor(int color, SkBlendMode mode) override;
virtual void drawPaint(const SkPaint& paint) override;
virtual void drawPaint(const Paint& paint) override;
virtual void drawPoint(float x, float y, const Paint& paint) override;
virtual void drawPoints(const float* points, int count, const Paint& paint) override;
@@ -167,10 +168,10 @@ protected:
const Paint& paint, const SkPath& path, size_t start,
size_t end) override;
void onFilterPaint(SkPaint& paint);
void onFilterPaint(Paint& paint);
SkPaint filterPaint(const SkPaint& src) {
SkPaint dst(src);
Paint filterPaint(const Paint& src) {
Paint dst(src);
this->onFilterPaint(dst);
return dst;
}
@@ -179,21 +180,20 @@ protected:
template <typename Proc>
void applyLooper(const Paint* paint, Proc proc, void (*preFilter)(SkPaint&) = nullptr) {
BlurDrawLooper* looper = paint ? paint->getLooper() : nullptr;
const SkPaint* skpPtr = paint;
SkPaint skp = skpPtr ? *skpPtr : SkPaint();
Paint pnt = paint ? *paint : Paint();
if (preFilter) {
preFilter(skp);
preFilter(pnt);
}
this->onFilterPaint(skp);
this->onFilterPaint(pnt);
if (looper) {
looper->apply(skp, [&](SkPoint offset, const SkPaint& modifiedPaint) {
looper->apply(pnt, [&](SkPoint offset, const Paint& modifiedPaint) {
mCanvas->save();
mCanvas->translate(offset.fX, offset.fY);
proc(modifiedPaint);
mCanvas->restore();
});
} else {
proc(skp);
proc(pnt);
}
}

View File

@@ -463,10 +463,10 @@ void Tree::drawStaging(Canvas* outCanvas) {
mStagingCache.dirty = false;
}
SkPaint skp;
Paint skp;
getPaintFor(&skp, mStagingProperties);
Paint paint;
paint.setFilterQuality(skp.getFilterQuality());
paint.setFilterBitmap(skp.isFilterBitmap());
paint.setColorFilter(skp.refColorFilter());
paint.setAlpha(skp.getAlpha());
outCanvas->drawBitmap(*mStagingCache.bitmap, 0, 0, mStagingCache.bitmap->width(),
@@ -476,9 +476,9 @@ void Tree::drawStaging(Canvas* outCanvas) {
mStagingProperties.getBounds().bottom(), &paint);
}
void Tree::getPaintFor(SkPaint* outPaint, const TreeProperties& prop) const {
void Tree::getPaintFor(Paint* outPaint, const TreeProperties& prop) const {
// HWUI always draws VD with bilinear filtering.
outPaint->setFilterQuality(kLow_SkFilterQuality);
outPaint->setFilterBitmap(true);
if (prop.getColorFilter() != nullptr) {
outPaint->setColorFilter(sk_ref_sp(prop.getColorFilter()));
}

View File

@@ -648,7 +648,7 @@ public:
*/
void draw(SkCanvas* canvas, const SkRect& bounds, const SkPaint& paint);
void getPaintFor(SkPaint* outPaint, const TreeProperties &props) const;
void getPaintFor(Paint* outPaint, const TreeProperties &props) const;
BitmapPalette computePalette();
void setAntiAlias(bool aa) { mRootNode->setAntiAlias(aa); }

View File

@@ -157,7 +157,6 @@ void AnimatedImageDrawable::onDraw(SkCanvas* canvas) {
lazyPaint.emplace();
lazyPaint->setAlpha(mProperties.mAlpha);
lazyPaint->setColorFilter(mProperties.mColorFilter);
lazyPaint->setFilterQuality(kLow_SkFilterQuality);
}
canvas->concat(matrix);

View File

@@ -24,7 +24,7 @@ BlurDrawLooper::BlurDrawLooper(SkColor4f color, float blurSigma, SkPoint offset)
BlurDrawLooper::~BlurDrawLooper() = default;
SkPoint BlurDrawLooper::apply(SkPaint* paint) const {
SkPoint BlurDrawLooper::apply(Paint* paint) const {
paint->setColor(mColor);
if (mBlurSigma > 0) {
paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, mBlurSigma, true));

View File

@@ -17,7 +17,7 @@
#ifndef ANDROID_GRAPHICS_BLURDRAWLOOPER_H_
#define ANDROID_GRAPHICS_BLURDRAWLOOPER_H_
#include <SkPaint.h>
#include <hwui/Paint.h>
#include <SkRefCnt.h>
class SkColorSpace;
@@ -30,10 +30,10 @@ public:
~BlurDrawLooper() override;
// proc(SkPoint offset, const SkPaint& modifiedPaint)
// proc(SkPoint offset, const Paint& modifiedPaint)
template <typename DrawProc>
void apply(const SkPaint& paint, DrawProc proc) const {
SkPaint p(paint);
void apply(const Paint& paint, DrawProc proc) const {
Paint p(paint);
proc(this->apply(&p), p); // draw the shadow
proc({0, 0}, paint); // draw the original (on top)
}
@@ -43,7 +43,7 @@ private:
const float mBlurSigma;
const SkPoint mOffset;
SkPoint apply(SkPaint* paint) const;
SkPoint apply(Paint* paint) const;
BlurDrawLooper(SkColor4f, float, SkPoint);
};

View File

@@ -162,7 +162,7 @@ public:
virtual int save(SaveFlags::Flags flags) = 0;
virtual void restore() = 0;
virtual void restoreToCount(int saveCount) = 0;
virtual void restoreUnclippedLayer(int saveCount, const SkPaint& paint) = 0;
virtual void restoreUnclippedLayer(int saveCount, const Paint& paint) = 0;
virtual int saveLayer(float left, float top, float right, float bottom, const SkPaint* paint) = 0;
virtual int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) = 0;
@@ -197,7 +197,7 @@ public:
// Canvas draw operations
// ----------------------------------------------------------------------------
virtual void drawColor(int color, SkBlendMode mode) = 0;
virtual void drawPaint(const SkPaint& paint) = 0;
virtual void drawPaint(const Paint& paint) = 0;
// Geometry
virtual void drawPoint(float x, float y, const Paint& paint) = 0;

View File

@@ -17,13 +17,13 @@
#ifndef ANDROID_GRAPHICS_PAINT_H_
#define ANDROID_GRAPHICS_PAINT_H_
#include "BlurDrawLooper.h"
#include "Typeface.h"
#include <cutils/compiler.h>
#include <SkFont.h>
#include <SkPaint.h>
#include <SkSamplingOptions.h>
#include <string>
#include <minikin/FontFamily.h>
@@ -32,6 +32,8 @@
namespace android {
class BlurDrawLooper;
class Paint : public SkPaint {
public:
// Default values for underlined and strikethrough text,
@@ -60,7 +62,7 @@ public:
const SkFont& getSkFont() const { return mFont; }
BlurDrawLooper* getLooper() const { return mLooper.get(); }
void setLooper(sk_sp<BlurDrawLooper> looper) { mLooper = std::move(looper); }
void setLooper(sk_sp<BlurDrawLooper> looper);
// These shadow the methods on SkPaint, but we need to so we can keep related
// attributes in-sync.
@@ -138,7 +140,15 @@ public:
void setDevKern(bool d) { mDevKern = d; }
// Deprecated -- bitmapshaders will be taking this flag explicitly
bool isFilterBitmap() const { return this->getFilterQuality() != kNone_SkFilterQuality; }
bool isFilterBitmap() const { return mFilterBitmap; }
void setFilterBitmap(bool filter) { mFilterBitmap = filter; }
SkFilterMode filterMode() const {
return mFilterBitmap ? SkFilterMode::kLinear : SkFilterMode::kNearest;
}
SkSamplingOptions sampling() const {
return SkSamplingOptions(this->filterMode());
}
// The Java flags (Paint.java) no longer fit into the native apis directly.
// These methods handle converting to and from them and the native representations
@@ -169,6 +179,7 @@ private:
// nullptr is valid: it means the default typeface.
const Typeface* mTypeface = nullptr;
Align mAlign = kLeft_Align;
bool mFilterBitmap = false;
bool mStrikeThru = false;
bool mUnderline = false;
bool mDevKern = false;

View File

@@ -1,17 +1,18 @@
#ifndef ANDROID_GRAPHICS_PAINT_FILTER_H_
#define ANDROID_GRAPHICS_PAINT_FILTER_H_
class SkPaint;
#include <SkRefCnt.h>
namespace android {
class Paint;
class PaintFilter : public SkRefCnt {
public:
/**
* Called with the paint that will be used to draw.
* The implementation may modify the paint as they wish.
*/
virtual void filter(SkPaint*) = 0;
virtual void filterFullPaint(Paint*) = 0;
};

View File

@@ -15,6 +15,7 @@
*/
#include "Paint.h"
#include "BlurDrawLooper.h"
namespace android {
@@ -43,6 +44,7 @@ Paint::Paint(const Paint& paint)
, mHyphenEdit(paint.mHyphenEdit)
, mTypeface(paint.mTypeface)
, mAlign(paint.mAlign)
, mFilterBitmap(paint.mFilterBitmap)
, mStrikeThru(paint.mStrikeThru)
, mUnderline(paint.mUnderline)
, mDevKern(paint.mDevKern) {}
@@ -62,6 +64,7 @@ Paint& Paint::operator=(const Paint& other) {
mHyphenEdit = other.mHyphenEdit;
mTypeface = other.mTypeface;
mAlign = other.mAlign;
mFilterBitmap = other.mFilterBitmap;
mStrikeThru = other.mStrikeThru;
mUnderline = other.mUnderline;
mDevKern = other.mDevKern;
@@ -77,6 +80,7 @@ bool operator==(const Paint& a, const Paint& b) {
a.mMinikinLocaleListId == b.mMinikinLocaleListId &&
a.mFamilyVariant == b.mFamilyVariant && a.mHyphenEdit == b.mHyphenEdit &&
a.mTypeface == b.mTypeface && a.mAlign == b.mAlign &&
a.mFilterBitmap == b.mFilterBitmap &&
a.mStrikeThru == b.mStrikeThru && a.mUnderline == b.mUnderline &&
a.mDevKern == b.mDevKern;
}
@@ -88,11 +92,16 @@ void Paint::reset() {
mFont.setEdging(SkFont::Edging::kAlias);
mLooper.reset();
mFilterBitmap = false;
mStrikeThru = false;
mUnderline = false;
mDevKern = false;
}
void Paint::setLooper(sk_sp<BlurDrawLooper> looper) {
mLooper = std::move(looper);
}
void Paint::setAntiAlias(bool aa) {
// Java does not support/understand subpixel(lcd) antialiasing
SkASSERT(mFont.getEdging() != SkFont::Edging::kSubpixelAntiAlias);
@@ -131,9 +140,6 @@ static uint32_t paintToLegacyFlags(const SkPaint& paint) {
uint32_t flags = 0;
flags |= -(int)paint.isAntiAlias() & sAntiAliasFlag;
flags |= -(int)paint.isDither() & sDitherFlag;
if (paint.getFilterQuality() != kNone_SkFilterQuality) {
flags |= sFilterBitmapFlag;
}
return flags;
}
@@ -150,12 +156,6 @@ static uint32_t fontToLegacyFlags(const SkFont& font) {
static void applyLegacyFlagsToPaint(uint32_t flags, SkPaint* paint) {
paint->setAntiAlias((flags & sAntiAliasFlag) != 0);
paint->setDither ((flags & sDitherFlag) != 0);
if (flags & sFilterBitmapFlag) {
paint->setFilterQuality(kLow_SkFilterQuality);
} else {
paint->setFilterQuality(kNone_SkFilterQuality);
}
}
static void applyLegacyFlagsToFont(uint32_t flags, SkFont* font) {
@@ -182,18 +182,20 @@ void Paint::SetSkPaintJavaFlags(SkPaint* paint, uint32_t flags) {
uint32_t Paint::getJavaFlags() const {
uint32_t flags = paintToLegacyFlags(*this) | fontToLegacyFlags(mFont);
flags |= -(int)mStrikeThru & sStrikeThruFlag;
flags |= -(int)mUnderline & sUnderlineFlag;
flags |= -(int)mDevKern & sDevKernFlag;
flags |= -(int)mStrikeThru & sStrikeThruFlag;
flags |= -(int)mUnderline & sUnderlineFlag;
flags |= -(int)mDevKern & sDevKernFlag;
flags |= -(int)mFilterBitmap & sFilterBitmapFlag;
return flags;
}
void Paint::setJavaFlags(uint32_t flags) {
applyLegacyFlagsToPaint(flags, this);
applyLegacyFlagsToFont(flags, &mFont);
mStrikeThru = (flags & sStrikeThruFlag) != 0;
mUnderline = (flags & sUnderlineFlag) != 0;
mDevKern = (flags & sDevKernFlag) != 0;
mStrikeThru = (flags & sStrikeThruFlag) != 0;
mUnderline = (flags & sUnderlineFlag) != 0;
mDevKern = (flags & sDevKernFlag) != 0;
mFilterBitmap = (flags & sFilterBitmapFlag) != 0;
}
} // namespace android

View File

@@ -663,8 +663,7 @@ namespace PaintGlue {
}
static void setFilterBitmap(CRITICAL_JNI_PARAMS_COMMA jlong paintHandle, jboolean filterBitmap) {
reinterpret_cast<Paint*>(paintHandle)->setFilterQuality(
filterBitmap ? kLow_SkFilterQuality : kNone_SkFilterQuality);
reinterpret_cast<Paint*>(paintHandle)->setFilterBitmap(filterBitmap);
}
static void setDither(CRITICAL_JNI_PARAMS_COMMA jlong paintHandle, jboolean dither) {

View File

@@ -29,10 +29,6 @@ public:
fClearFlags = static_cast<uint16_t>(clearFlags);
fSetFlags = static_cast<uint16_t>(setFlags);
}
void filter(SkPaint* paint) override {
uint32_t flags = Paint::GetSkPaintJavaFlags(*paint);
Paint::SetSkPaintJavaFlags(paint, (flags & ~fClearFlags) | fSetFlags);
}
void filterFullPaint(Paint* paint) override {
paint->setJavaFlags((paint->getJavaFlags() & ~fClearFlags) | fSetFlags);
}

View File

@@ -233,7 +233,7 @@ static void drawColorLong(JNIEnv* env, jobject, jlong canvasHandle, jlong colorS
jlong colorLong, jint modeHandle) {
SkColor4f color = GraphicsJNI::convertColorLong(colorLong);
sk_sp<SkColorSpace> cs = GraphicsJNI::getNativeColorSpace(colorSpaceHandle);
SkPaint p;
Paint p;
p.setColor4f(color, cs.get());
SkBlendMode mode = static_cast<SkBlendMode>(modeHandle);
@@ -421,7 +421,7 @@ static void drawNinePatch(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmap
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
filteredPaint.setFilterBitmap(true);
canvas->drawNinePatch(bitmap, *chunk, 0, 0, (right-left)/scale, (bottom-top)/scale,
&filteredPaint);
@@ -443,7 +443,7 @@ static void drawBitmap(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHan
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
filteredPaint.setFilterBitmap(true);
canvas->drawBitmap(bitmap, left, top, &filteredPaint);
} else {
canvas->drawBitmap(bitmap, left, top, paint);
@@ -458,7 +458,7 @@ static void drawBitmap(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHan
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
filteredPaint.setFilterBitmap(true);
canvas->drawBitmap(bitmap, 0, 0, &filteredPaint);
canvas->restore();
@@ -486,7 +486,7 @@ static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jlong bitma
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
filteredPaint.setFilterBitmap(true);
canvas->drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, &filteredPaint);
} else {

View File

@@ -192,23 +192,13 @@ void SkiaRecordingCanvas::FilterForImage(SkPaint& paint) {
}
}
static SkFilterMode Paint_to_filter(const SkPaint& paint) {
return paint.getFilterQuality() != kNone_SkFilterQuality ? SkFilterMode::kLinear
: SkFilterMode::kNearest;
}
static SkSamplingOptions Paint_to_sampling(const SkPaint& paint) {
// Android only has 1-bit for "filter", so we don't try to cons-up mipmaps or cubics
return SkSamplingOptions(Paint_to_filter(paint), SkMipmapMode::kNone);
}
void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const Paint* paint) {
sk_sp<SkImage> image = bitmap.makeImage();
applyLooper(
paint,
[&](const SkPaint& p) {
mRecorder.drawImage(image, left, top, Paint_to_sampling(p), &p, bitmap.palette());
[&](const Paint& p) {
mRecorder.drawImage(image, left, top, p.sampling(), &p, bitmap.palette());
},
FilterForImage);
@@ -228,8 +218,8 @@ void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, con
applyLooper(
paint,
[&](const SkPaint& p) {
mRecorder.drawImage(image, 0, 0, Paint_to_sampling(p), &p, bitmap.palette());
[&](const Paint& p) {
mRecorder.drawImage(image, 0, 0, p.sampling(), &p, bitmap.palette());
},
FilterForImage);
@@ -248,8 +238,8 @@ void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float srcLeft, float srcTop
applyLooper(
paint,
[&](const SkPaint& p) {
mRecorder.drawImageRect(image, srcRect, dstRect, Paint_to_sampling(p), &p,
[&](const Paint& p) {
mRecorder.drawImageRect(image, srcRect, dstRect, p.sampling(), &p,
SkCanvas::kFast_SrcRectConstraint, bitmap.palette());
},
FilterForImage);

View File

@@ -49,7 +49,7 @@ public:
paint.setAntiAlias(true);
paint.setColor(Color::Green_700);
canvas.drawCircle(200, 200, 200, paint);
SkPaint alphaPaint;
Paint alphaPaint;
alphaPaint.setAlpha(128);
canvas.restoreUnclippedLayer(unclippedSaveLayer, alphaPaint);
canvas.restore();

View File

@@ -32,13 +32,6 @@ namespace uirenderer {
*/
class PaintUtils {
public:
static inline GLenum getFilter(const SkPaint* paint) {
if (!paint || paint->getFilterQuality() != kNone_SkFilterQuality) {
return GL_LINEAR;
}
return GL_NEAREST;
}
static bool isOpaquePaint(const SkPaint* paint) {
if (!paint) return true; // default (paintless) behavior is SrcOver, black