remove use of xfermode* in procs
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4592 Change-Id: I99f35924ff5325dfac527bb573a86d2d0366e0b3 Reviewed-on: https://skia-review.googlesource.com/4592 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
d3ea9b75f7
commit
6a01554e9e
@ -17,13 +17,13 @@
|
||||
// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
|
||||
class XferD32Bench : public Benchmark {
|
||||
public:
|
||||
XferD32Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t flags)
|
||||
XferD32Bench(SkBlendMode mode, const char name[], bool doN, uint32_t flags)
|
||||
: fDoN(doN)
|
||||
, fFlags(flags & ~USE_AA)
|
||||
{
|
||||
fXfer = SkXfermode::Make(mode);
|
||||
fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
|
||||
fProcN = SkXfermode::GetD32Proc(fXfer, fFlags);
|
||||
fMode = mode;
|
||||
fProc1 = SkXfermode::GetD32Proc(fMode, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
|
||||
fProcN = SkXfermode::GetD32Proc(fMode, fFlags);
|
||||
fName.printf("xfer4f_%s_%s_%c_%s_%s",
|
||||
name,
|
||||
(flags & USE_AA) ? "aa" : "bw",
|
||||
@ -52,15 +52,15 @@ protected:
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
for (int i = 0; i < loops * INNER_LOOPS; ++i) {
|
||||
if (fDoN) {
|
||||
fProcN(fXfer.get(), fDst, fSrc, N, fAA);
|
||||
fProcN(fMode, fDst, fSrc, N, fAA);
|
||||
} else {
|
||||
fProc1(fXfer.get(), fDst, fSrc, N, fAA);
|
||||
fProc1(fMode, fDst, fSrc, N, fAA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkXfermode> fXfer;
|
||||
SkBlendMode fMode;
|
||||
SkString fName;
|
||||
SkXfermode::D32Proc fProc1;
|
||||
SkXfermode::D32Proc fProcN;
|
||||
@ -83,22 +83,22 @@ private:
|
||||
#define F10 (SkXfermode::kDstIsSRGB_D32Flag)
|
||||
#define F11 (SkXfermode::kSrcIsOpaque_D32Flag | SkXfermode::kDstIsSRGB_D32Flag)
|
||||
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F10); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F00); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F11); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F01); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F10); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F00); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F11); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F01); )
|
||||
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F10); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F00); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F11); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F01); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F10); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F00); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F11); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F01); )
|
||||
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F10 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F00 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F11 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", false, F01 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F10 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F00 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F11 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", false, F01 | USE_AA); )
|
||||
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F10 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F00 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F11 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkXfermode::kSrcOver_Mode, "srcover", true, F01 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F10 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F00 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F11 | USE_AA); )
|
||||
DEF_BENCH( return new XferD32Bench(SkBlendMode::kSrcOver, "srcover", true, F01 | USE_AA); )
|
||||
|
@ -17,14 +17,13 @@
|
||||
// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
|
||||
class XferF16Bench : public Benchmark {
|
||||
public:
|
||||
XferF16Bench(SkXfermode::Mode mode, const char name[], bool doN, uint32_t flags)
|
||||
XferF16Bench(SkBlendMode mode, const char name[], bool doN, uint32_t flags)
|
||||
: fDoN(doN)
|
||||
, fFlags(flags & ~USE_AA)
|
||||
{
|
||||
fXfer = SkXfermode::Make(mode);
|
||||
|
||||
fProc1 = SkXfermode::GetF16Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_F16Flag);
|
||||
fProcN = SkXfermode::GetF16Proc(fXfer, fFlags);
|
||||
fMode = mode;
|
||||
fProc1 = SkXfermode::GetF16Proc(mode, fFlags | SkXfermode::kSrcIsSingle_F16Flag);
|
||||
fProcN = SkXfermode::GetF16Proc(mode, fFlags);
|
||||
fName.printf("xferF16_%s_%s_%c_%s",
|
||||
name,
|
||||
(flags & USE_AA) ? "aa" : "bw",
|
||||
@ -52,15 +51,15 @@ protected:
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
for (int i = 0; i < loops * INNER_LOOPS; ++i) {
|
||||
if (fDoN) {
|
||||
fProcN(fXfer.get(), fDst, fSrc, N, fAA);
|
||||
fProcN(fMode, fDst, fSrc, N, fAA);
|
||||
} else {
|
||||
fProc1(fXfer.get(), fDst, fSrc, N, fAA);
|
||||
fProc1(fMode, fDst, fSrc, N, fAA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkXfermode> fXfer;
|
||||
SkBlendMode fMode;
|
||||
SkString fName;
|
||||
SkXfermode::F16Proc fProc1;
|
||||
SkXfermode::F16Proc fProcN;
|
||||
@ -81,7 +80,7 @@ private:
|
||||
#define F00 0
|
||||
#define F01 (SkXfermode::kSrcIsOpaque_F16Flag)
|
||||
|
||||
#define MODE SkXfermode::kSrcOver_Mode
|
||||
#define MODE SkBlendMode::kSrcOver
|
||||
#define NAME "srcover"
|
||||
|
||||
DEF_BENCH( return new XferF16Bench(MODE, NAME, true, F00 | USE_AA); )
|
||||
|
@ -113,7 +113,7 @@ static void draw_rect_fp(SkCanvas* canvas, const SkRect& r, SkColor c, const SkM
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
auto procN = SkXfermode::GetD32Proc(nullptr, flags);
|
||||
auto procN = SkXfermode::GetD32Proc(SkBlendMode::kSrcOver, flags);
|
||||
|
||||
SkLinearBitmapPipeline pipeline{
|
||||
inv, filterQuality,
|
||||
@ -121,7 +121,7 @@ static void draw_rect_fp(SkCanvas* canvas, const SkRect& r, SkColor c, const SkM
|
||||
|
||||
for (int y = 0; y < ir.height(); y++) {
|
||||
pipeline.shadeSpan4f(0, y, dstBits, ir.width());
|
||||
procN(nullptr, pmdst.writable_addr32(0, y), dstBits, ir.width(), nullptr);
|
||||
procN(SkBlendMode::kSrcOver, pmdst.writable_addr32(0, y), dstBits, ir.width(), nullptr);
|
||||
}
|
||||
|
||||
delete [] dstBits;
|
||||
|
@ -21,7 +21,6 @@ class SkColorSpace;
|
||||
class SkImage;
|
||||
class SkPath;
|
||||
class SkPicture;
|
||||
class SkXfermode;
|
||||
class GrContext;
|
||||
class GrFragmentProcessor;
|
||||
|
||||
@ -153,7 +152,7 @@ public:
|
||||
struct BlitState {
|
||||
// inputs
|
||||
Context* fCtx;
|
||||
SkXfermode* fXfer;
|
||||
SkBlendMode fMode;
|
||||
|
||||
// outputs
|
||||
enum { N = 2 };
|
||||
|
@ -176,13 +176,8 @@ public:
|
||||
return (SkBlendMode)mode;
|
||||
}
|
||||
|
||||
/** Return a function pointer to a routine that applies the specified
|
||||
porter-duff transfer mode.
|
||||
*/
|
||||
static SkXfermodeProc GetProc(Mode mode);
|
||||
static SkXfermodeProc4f GetProc4f(Mode);
|
||||
|
||||
virtual SkXfermodeProc4f getProc4f() const;
|
||||
static SkXfermodeProc GetProc(SkBlendMode);
|
||||
static SkXfermodeProc4f GetProc4f(SkBlendMode);
|
||||
|
||||
/**
|
||||
* If the specified mode can be represented by a pair of Coeff, then return
|
||||
@ -263,23 +258,17 @@ public:
|
||||
kSrcIsSingle_D32Flag = 1 << 1,
|
||||
kDstIsSRGB_D32Flag = 1 << 2,
|
||||
};
|
||||
typedef void (*D32Proc)(const SkXfermode*, uint32_t dst[], const SkPM4f src[],
|
||||
typedef void (*D32Proc)(SkBlendMode, uint32_t dst[], const SkPM4f src[],
|
||||
int count, const SkAlpha coverage[]);
|
||||
static D32Proc GetD32Proc(SkXfermode*, uint32_t flags);
|
||||
static D32Proc GetD32Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) {
|
||||
return GetD32Proc(xfer.get(), flags);
|
||||
}
|
||||
static D32Proc GetD32Proc(SkBlendMode, uint32_t flags);
|
||||
|
||||
enum F16Flags {
|
||||
kSrcIsOpaque_F16Flag = 1 << 0,
|
||||
kSrcIsSingle_F16Flag = 1 << 1,
|
||||
};
|
||||
typedef void (*F16Proc)(const SkXfermode*, uint64_t dst[], const SkPM4f src[], int count,
|
||||
typedef void (*F16Proc)(SkBlendMode, uint64_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha coverage[]);
|
||||
static F16Proc GetF16Proc(SkXfermode*, uint32_t flags);
|
||||
static F16Proc GetF16Proc(const sk_sp<SkXfermode>& xfer, uint32_t flags) {
|
||||
return GetF16Proc(xfer.get(), flags);
|
||||
}
|
||||
static F16Proc GetF16Proc(SkBlendMode, uint32_t flags);
|
||||
|
||||
enum LCDFlags {
|
||||
kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1
|
||||
@ -305,9 +294,6 @@ protected:
|
||||
*/
|
||||
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
|
||||
|
||||
virtual D32Proc onGetD32Proc(uint32_t flags) const;
|
||||
virtual F16Proc onGetF16Proc(uint32_t flags) const;
|
||||
|
||||
private:
|
||||
enum {
|
||||
kModeCount = kLastMode + 1
|
||||
|
@ -127,8 +127,7 @@ public:
|
||||
// To implement the old shadeSpan entry-point, we need to efficiently convert our native
|
||||
// floats into SkPMColor. The SkXfermode::D32Procs do exactly that.
|
||||
//
|
||||
sk_sp<SkXfermode> xfer(SkXfermode::Make(SkXfermode::kSrc_Mode));
|
||||
fXferProc = SkXfermode::GetD32Proc(xfer.get(), 0);
|
||||
fSrcModeProc = SkXfermode::GetD32Proc(SkBlendMode::kSrc, 0);
|
||||
}
|
||||
|
||||
void shadeSpan4f(int x, int y, SkPM4f dstC[], int count) override {
|
||||
@ -142,7 +141,7 @@ public:
|
||||
while (count > 0) {
|
||||
const int n = SkTMin(count, N);
|
||||
fShaderPipeline->shadeSpan4f(x, y, tmp, n);
|
||||
fXferProc(nullptr, dstC, tmp, n, nullptr);
|
||||
fSrcModeProc(SkBlendMode::kSrc, dstC, tmp, n, nullptr);
|
||||
dstC += n;
|
||||
x += n;
|
||||
count -= n;
|
||||
@ -150,15 +149,12 @@ public:
|
||||
}
|
||||
|
||||
bool onChooseBlitProcs(const SkImageInfo& dstInfo, BlitState* state) override {
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(state->fXfer, &mode)) { return false; }
|
||||
|
||||
if (SkLinearBitmapPipeline::ClonePipelineForBlitting(
|
||||
&fBlitterPipeline, *fShaderPipeline,
|
||||
fMatrixTypeMask,
|
||||
fXMode, fYMode,
|
||||
fFilterQuality, fSrcPixmap,
|
||||
fAlpha, mode, dstInfo))
|
||||
fAlpha, state->fMode, dstInfo))
|
||||
{
|
||||
state->fStorage[0] = fBlitterPipeline.get();
|
||||
state->fBlitBW = &LinearPipelineContext::ForwardToPipeline;
|
||||
@ -178,7 +174,7 @@ public:
|
||||
private:
|
||||
SkEmbeddableLinearPipeline fShaderPipeline;
|
||||
SkEmbeddableLinearPipeline fBlitterPipeline;
|
||||
SkXfermode::D32Proc fXferProc;
|
||||
SkXfermode::D32Proc fSrcModeProc;
|
||||
SkPixmap fSrcPixmap;
|
||||
float fAlpha;
|
||||
SkShader::TileMode fXMode;
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void blitH(int x, int y, int width) override {
|
||||
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
|
||||
|
||||
fState.fProc1(fState.fXfer, State::WritableAddr(fDevice, x, y),
|
||||
fState.fProc1(fState.fMode, State::WritableAddr(fDevice, x, y),
|
||||
&fState.fPM4f, width, nullptr);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public:
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
|
||||
for (int i = 0; i < height; ++i) {
|
||||
fState.fProc1(fState.fXfer, device, &fState.fPM4f, 1, &alpha);
|
||||
fState.fProc1(fState.fMode, device, &fState.fPM4f, 1, &alpha);
|
||||
device = (typename State::DstType*)((char*)device + deviceRB);
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ public:
|
||||
size_t deviceRB = fDevice.rowBytes();
|
||||
|
||||
do {
|
||||
fState.fProc1(fState.fXfer, device, &fState.fPM4f, width, nullptr);
|
||||
fState.fProc1(fState.fMode, device, &fState.fPM4f, width, nullptr);
|
||||
y += 1;
|
||||
device = (typename State::DstType*)((char*)device + deviceRB);
|
||||
} while (--height > 0);
|
||||
@ -68,10 +68,10 @@ public:
|
||||
int aa = *antialias;
|
||||
if (aa) {
|
||||
if (aa == 255) {
|
||||
fState.fProc1(fState.fXfer, device, &fState.fPM4f, count, nullptr);
|
||||
fState.fProc1(fState.fMode, device, &fState.fPM4f, count, nullptr);
|
||||
} else {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
fState.fProc1(fState.fXfer, &device[i], &fState.fPM4f, 1, antialias);
|
||||
fState.fProc1(fState.fMode, &device[i], &fState.fPM4f, 1, antialias);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ public:
|
||||
const size_t maskRB = mask.fRowBytes;
|
||||
|
||||
for (int i = 0; i < height; ++i) {
|
||||
fState.fProc1(fState.fXfer, device, &fState.fPM4f, width, maskRow);
|
||||
fState.fProc1(fState.fMode, device, &fState.fPM4f, width, maskRow);
|
||||
device = (typename State::DstType*)((char*)device + dstRB);
|
||||
maskRow += maskRB;
|
||||
}
|
||||
@ -155,7 +155,7 @@ public:
|
||||
|
||||
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
|
||||
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
|
||||
fState.fProcN(fState.fXfer, device, fState.fBuffer, width, nullptr);
|
||||
fState.fProcN(fState.fMode, device, fState.fBuffer, width, nullptr);
|
||||
}
|
||||
|
||||
void blitV(int x, int y, int height, SkAlpha alpha) override {
|
||||
@ -178,7 +178,7 @@ public:
|
||||
if (!fConstInY) {
|
||||
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, 1);
|
||||
}
|
||||
fState.fProcN(fState.fXfer, device, fState.fBuffer, 1, &alpha);
|
||||
fState.fProcN(fState.fMode, device, fState.fBuffer, 1, &alpha);
|
||||
device = (typename State::DstType*)((char*)device + deviceRB);
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ public:
|
||||
if (!fConstInY) {
|
||||
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
|
||||
}
|
||||
fState.fProcN(fState.fXfer, device, fState.fBuffer, width, nullptr);
|
||||
fState.fProcN(fState.fMode, device, fState.fBuffer, width, nullptr);
|
||||
device = (typename State::DstType*)((char*)device + deviceRB);
|
||||
}
|
||||
}
|
||||
@ -224,10 +224,10 @@ public:
|
||||
} else {
|
||||
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, count);
|
||||
if (aa == 255) {
|
||||
fState.fProcN(fState.fXfer, device, fState.fBuffer, count, nullptr);
|
||||
fState.fProcN(fState.fMode, device, fState.fBuffer, count, nullptr);
|
||||
} else {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
fState.fProcN(fState.fXfer, &device[i], &fState.fBuffer[i], 1, antialias);
|
||||
fState.fProcN(fState.fMode, &device[i], &fState.fBuffer[i], 1, antialias);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ public:
|
||||
if (!fConstInY) {
|
||||
fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width);
|
||||
}
|
||||
fState.fProcN(fState.fXfer, device, fState.fBuffer, width, maskRow);
|
||||
fState.fProcN(fState.fMode, device, fState.fBuffer, width, maskRow);
|
||||
device = (typename State::DstType*)((char*)device + deviceRB);
|
||||
maskRow += maskRB;
|
||||
}
|
||||
@ -325,7 +325,7 @@ static bool is_opaque(const SkPaint& paint, const SkShader::Context* shaderConte
|
||||
|
||||
struct State4f {
|
||||
State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext) {
|
||||
fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
fMode = paint.getBlendMode();
|
||||
if (shaderContext) {
|
||||
fBuffer.reset(info.width());
|
||||
} else {
|
||||
@ -334,10 +334,10 @@ struct State4f {
|
||||
fFlags = 0;
|
||||
}
|
||||
|
||||
SkXfermode* fXfer;
|
||||
SkPM4f fPM4f;
|
||||
SkAutoTMalloc<SkPM4f> fBuffer;
|
||||
uint32_t fFlags;
|
||||
SkBlendMode fMode;
|
||||
|
||||
SkShader::Context::BlitState fBState;
|
||||
};
|
||||
@ -357,8 +357,8 @@ struct State32 : State4f {
|
||||
if (info.gammaCloseToSRGB()) {
|
||||
fFlags |= SkXfermode::kDstIsSRGB_D32Flag;
|
||||
}
|
||||
fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
|
||||
fProcN = SkXfermode::GetD32Proc(fXfer, fFlags);
|
||||
fProc1 = SkXfermode::GetD32Proc(fMode, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
|
||||
fProcN = SkXfermode::GetD32Proc(fMode, fFlags);
|
||||
}
|
||||
|
||||
SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const {
|
||||
@ -387,8 +387,8 @@ struct StateF16 : State4f {
|
||||
fFlags |= SkXfermode::kSrcIsOpaque_F16Flag;
|
||||
}
|
||||
SkASSERT(kRGBA_F16_SkColorType == info.colorType());
|
||||
fProc1 = SkXfermode::GetF16Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_F16Flag);
|
||||
fProcN = SkXfermode::GetF16Proc(fXfer, fFlags);
|
||||
fProc1 = SkXfermode::GetF16Proc(fMode, fFlags | SkXfermode::kSrcIsSingle_F16Flag);
|
||||
fProcN = SkXfermode::GetF16Proc(fMode, fFlags);
|
||||
}
|
||||
|
||||
SkXfermode::LCDF16Proc getLCDProc(uint32_t oneOrManyFlag) const {
|
||||
@ -410,7 +410,7 @@ template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain
|
||||
SkShader::Context::BlitState bstate;
|
||||
sk_bzero(&bstate, sizeof(bstate));
|
||||
bstate.fCtx = shaderContext;
|
||||
bstate.fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
bstate.fMode = paint.getBlendMode();
|
||||
|
||||
(void)shaderContext->chooseBlitProcs(device.info(), &bstate);
|
||||
return allocator->createT<SkState_Shader_Blitter<State>>(device, paint, bstate);
|
||||
|
@ -246,28 +246,28 @@ static void D32_BlitBW(SkShader::Context::BlitState* state, int x, int y, const
|
||||
int count) {
|
||||
SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
|
||||
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
|
||||
proc(state->fXfer, dst.writable_addr32(x, y), src, count, nullptr);
|
||||
proc(state->fMode, dst.writable_addr32(x, y), src, count, nullptr);
|
||||
}
|
||||
|
||||
static void D32_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
|
||||
int count, const SkAlpha aa[]) {
|
||||
SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
|
||||
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
|
||||
proc(state->fXfer, dst.writable_addr32(x, y), src, count, aa);
|
||||
proc(state->fMode, dst.writable_addr32(x, y), src, count, aa);
|
||||
}
|
||||
|
||||
static void F16_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
|
||||
int count) {
|
||||
SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
|
||||
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
|
||||
proc(state->fXfer, dst.writable_addr64(x, y), src, count, nullptr);
|
||||
proc(state->fMode, dst.writable_addr64(x, y), src, count, nullptr);
|
||||
}
|
||||
|
||||
static void F16_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
|
||||
int count, const SkAlpha aa[]) {
|
||||
SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
|
||||
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
|
||||
proc(state->fXfer, dst.writable_addr64(x, y), src, count, aa);
|
||||
proc(state->fMode, dst.writable_addr64(x, y), src, count, aa);
|
||||
}
|
||||
|
||||
static bool choose_blitprocs(const SkPM4f* pm4, const SkImageInfo& info,
|
||||
@ -281,13 +281,13 @@ static bool choose_blitprocs(const SkPM4f* pm4, const SkImageInfo& info,
|
||||
if (info.gammaCloseToSRGB()) {
|
||||
flags |= SkXfermode::kDstIsSRGB_D32Flag;
|
||||
}
|
||||
state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, flags);
|
||||
state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fMode, flags);
|
||||
state->fStorage[1] = (void*)pm4;
|
||||
state->fBlitBW = D32_BlitBW;
|
||||
state->fBlitAA = D32_BlitAA;
|
||||
return true;
|
||||
case kRGBA_F16_SkColorType:
|
||||
state->fStorage[0] = (void*)SkXfermode::GetF16Proc(state->fXfer, flags);
|
||||
state->fStorage[0] = (void*)SkXfermode::GetF16Proc(state->fMode, flags);
|
||||
state->fStorage[1] = (void*)pm4;
|
||||
state->fBlitBW = F16_BlitBW;
|
||||
state->fBlitAA = F16_BlitAA;
|
||||
|
@ -671,12 +671,11 @@ bool SkLinearBitmapPipeline::ClonePipelineForBlitting(
|
||||
SkFilterQuality filterQuality,
|
||||
const SkPixmap& srcPixmap,
|
||||
float finalAlpha,
|
||||
SkXfermode::Mode xferMode,
|
||||
SkBlendMode blendMode,
|
||||
const SkImageInfo& dstInfo)
|
||||
{
|
||||
if (xferMode == SkXfermode::kSrcOver_Mode
|
||||
&& srcPixmap.info().alphaType() == kOpaque_SkAlphaType) {
|
||||
xferMode = SkXfermode::kSrc_Mode;
|
||||
if (blendMode == SkBlendMode::kSrcOver && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) {
|
||||
blendMode = SkBlendMode::kSrc;
|
||||
}
|
||||
|
||||
if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return false; }
|
||||
@ -689,11 +688,11 @@ bool SkLinearBitmapPipeline::ClonePipelineForBlitting(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xferMode != SkXfermode::kSrc_Mode && xferMode != SkXfermode::kSrcOver_Mode) {
|
||||
if (blendMode != SkBlendMode::kSrc && blendMode != SkBlendMode::kSrcOver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pipelineStorage->init(pipeline, srcPixmap, xferMode, dstInfo);
|
||||
pipelineStorage->init(pipeline, srcPixmap, blendMode, dstInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -701,14 +700,14 @@ bool SkLinearBitmapPipeline::ClonePipelineForBlitting(
|
||||
SkLinearBitmapPipeline::SkLinearBitmapPipeline(
|
||||
const SkLinearBitmapPipeline& pipeline,
|
||||
const SkPixmap& srcPixmap,
|
||||
SkXfermode::Mode mode,
|
||||
SkBlendMode mode,
|
||||
const SkImageInfo& dstInfo)
|
||||
{
|
||||
SkASSERT(mode == SkXfermode::kSrc_Mode || mode == SkXfermode::kSrcOver_Mode);
|
||||
SkASSERT(mode == SkBlendMode::kSrc || mode == SkBlendMode::kSrcOver);
|
||||
SkASSERT(srcPixmap.info().colorType() == dstInfo.colorType()
|
||||
&& srcPixmap.info().colorType() == kRGBA_8888_SkColorType);
|
||||
|
||||
if (mode == SkXfermode::kSrc_Mode) {
|
||||
if (mode == SkBlendMode::kSrc) {
|
||||
fSampleStage.initSink<RGBA8888UnitRepeatSrc>(
|
||||
srcPixmap.writable_addr32(0, 0), srcPixmap.rowBytes() / 4);
|
||||
fLastStage = fSampleStage.getInterface<DestinationInterface, RGBA8888UnitRepeatSrc>();
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
SkLinearBitmapPipeline(
|
||||
const SkLinearBitmapPipeline& pipeline,
|
||||
const SkPixmap& srcPixmap,
|
||||
SkXfermode::Mode xferMode,
|
||||
SkBlendMode blendMode,
|
||||
const SkImageInfo& dstInfo);
|
||||
|
||||
static bool ClonePipelineForBlitting(
|
||||
@ -49,7 +49,7 @@ public:
|
||||
SkFilterQuality filterQuality,
|
||||
const SkPixmap& srcPixmap,
|
||||
float finalAlpha,
|
||||
SkXfermode::Mode xferMode,
|
||||
SkBlendMode,
|
||||
const SkImageInfo& dstInfo);
|
||||
|
||||
~SkLinearBitmapPipeline();
|
||||
|
@ -61,7 +61,7 @@ void SkModeColorFilter::filterSpan(const SkPMColor shader[], int count, SkPMColo
|
||||
}
|
||||
|
||||
void SkModeColorFilter::filterSpan4f(const SkPM4f shader[], int count, SkPM4f result[]) const {
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f((SkXfermode::Mode)fMode);
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f(fMode);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
result[i] = proc(fPM4f, shader[i]);
|
||||
@ -75,7 +75,7 @@ void SkModeColorFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
void SkModeColorFilter::updateCache() {
|
||||
fPMColor = SkPreMultiplyColor(fColor);
|
||||
fProc = SkXfermode::GetProc((SkXfermode::Mode)fMode);
|
||||
fProc = SkXfermode::GetProc(fMode);
|
||||
fPM4f = SkColor4f::FromColor(fColor).premul();
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,14 @@
|
||||
class Sprite_4f : public SkSpriteBlitter {
|
||||
public:
|
||||
Sprite_4f(const SkPixmap& src, const SkPaint& paint) : INHERITED(src) {
|
||||
fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
fMode = paint.getBlendMode();
|
||||
fLoader = SkLoadSpanProc_Choose(src.info());
|
||||
fFilter = SkFilterSpanProc_Choose(paint);
|
||||
fBuffer.reset(src.width());
|
||||
}
|
||||
|
||||
protected:
|
||||
SkXfermode* fXfer;
|
||||
SkBlendMode fMode;
|
||||
SkLoadSpanProc fLoader;
|
||||
SkFilterSpanProc fFilter;
|
||||
SkAutoTMalloc<SkPM4f> fBuffer;
|
||||
@ -38,7 +38,7 @@ public:
|
||||
if (src.isOpaque()) {
|
||||
flags |= SkXfermode::kSrcIsOpaque_F16Flag;
|
||||
}
|
||||
fWriter = SkXfermode::GetF16Proc(fXfer, flags);
|
||||
fWriter = SkXfermode::GetF16Proc(fMode, flags);
|
||||
}
|
||||
|
||||
void blitRect(int x, int y, int width, int height) override {
|
||||
@ -49,7 +49,7 @@ public:
|
||||
for (int bottom = y + height; y < bottom; ++y) {
|
||||
fLoader(fSource, x - fLeft, y - fTop, fBuffer, width);
|
||||
fFilter(*fPaint, fBuffer, width);
|
||||
fWriter(fXfer, dst, fBuffer, width, nullptr);
|
||||
fWriter(fMode, dst, fBuffer, width, nullptr);
|
||||
dst = (uint64_t* SK_RESTRICT)((char*)dst + dstRB);
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ public:
|
||||
if (src.isOpaque()) {
|
||||
flags |= SkXfermode::kSrcIsOpaque_D32Flag;
|
||||
}
|
||||
fWriter = SkXfermode::GetD32Proc(fXfer, flags);
|
||||
fWriter = SkXfermode::GetD32Proc(fMode, flags);
|
||||
}
|
||||
|
||||
void blitRect(int x, int y, int width, int height) override {
|
||||
@ -98,7 +98,7 @@ public:
|
||||
for (int bottom = y + height; y < bottom; ++y) {
|
||||
fLoader(fSource, x - fLeft, y - fTop, fBuffer, width);
|
||||
fFilter(*fPaint, fBuffer, width);
|
||||
fWriter(fXfer, dst, fBuffer, width, nullptr);
|
||||
fWriter(fMode, dst, fBuffer, width, nullptr);
|
||||
dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
|
||||
}
|
||||
}
|
||||
|
@ -1336,31 +1336,22 @@ sk_sp<SkXfermode> SkXfermode::Make(SkBlendMode mode) {
|
||||
return sk_ref_sp(cached[(int)mode]);
|
||||
}
|
||||
|
||||
SkXfermodeProc SkXfermode::GetProc(Mode mode) {
|
||||
SkXfermodeProc SkXfermode::GetProc(SkBlendMode mode) {
|
||||
SkXfermodeProc proc = nullptr;
|
||||
if ((unsigned)mode < kModeCount) {
|
||||
proc = gProcCoeffs[mode].fProc;
|
||||
proc = gProcCoeffs[(unsigned)mode].fProc;
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
||||
SkXfermodeProc4f SkXfermode::GetProc4f(Mode mode) {
|
||||
SkXfermodeProc4f SkXfermode::GetProc4f(SkBlendMode mode) {
|
||||
SkXfermodeProc4f proc = nullptr;
|
||||
if ((unsigned)mode < kModeCount) {
|
||||
proc = gProcCoeffs[mode].fProc4f;
|
||||
proc = gProcCoeffs[(unsigned)mode].fProc4f;
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
||||
static SkPM4f missing_proc4f(const SkPM4f& src, const SkPM4f& dst) {
|
||||
return src;
|
||||
}
|
||||
|
||||
SkXfermodeProc4f SkXfermode::getProc4f() const {
|
||||
Mode mode;
|
||||
return this->asMode(&mode) ? GetProc4f(mode) : missing_proc4f;
|
||||
}
|
||||
|
||||
bool SkXfermode::ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst) {
|
||||
SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
|
||||
|
||||
|
@ -73,10 +73,10 @@ static void store_4_srgb(void* ptr, const Sk4x4f& p) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <DstType D> void general_1(const SkXfermode* xfer, uint32_t dst[],
|
||||
template <DstType D> void general_1(SkBlendMode mode, uint32_t dst[],
|
||||
const SkPM4f* src, int count, const SkAlpha aa[]) {
|
||||
const SkPM4f s = rgba_to_pmcolor_order(*src);
|
||||
SkXfermodeProc4f proc = xfer->getProc4f();
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f(mode);
|
||||
SkPM4f d;
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -94,9 +94,9 @@ template <DstType D> void general_1(const SkXfermode* xfer, uint32_t dst[],
|
||||
}
|
||||
}
|
||||
|
||||
template <DstType D> void general_n(const SkXfermode* xfer, uint32_t dst[],
|
||||
template <DstType D> void general_n(SkBlendMode mode, uint32_t dst[],
|
||||
const SkPM4f src[], int count, const SkAlpha aa[]) {
|
||||
SkXfermodeProc4f proc = xfer->getProc4f();
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f(mode);
|
||||
SkPM4f d;
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -123,8 +123,8 @@ const SkXfermode::D32Proc gProcs_General[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void clear_linear(const SkXfermode*, uint32_t dst[], const SkPM4f[],
|
||||
int count, const SkAlpha aa[]) {
|
||||
static void clear_linear(SkBlendMode, uint32_t dst[], const SkPM4f[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
unsigned a = aa[i];
|
||||
@ -142,8 +142,7 @@ static void clear_linear(const SkXfermode*, uint32_t dst[], const SkPM4f[],
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_srgb(const SkXfermode*, uint32_t dst[], const SkPM4f[],
|
||||
int count, const SkAlpha aa[]) {
|
||||
static void clear_srgb(SkBlendMode, uint32_t dst[], const SkPM4f[], int count, const SkAlpha aa[]) {
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (aa[i]) {
|
||||
@ -165,8 +164,8 @@ const SkXfermode::D32Proc gProcs_Clear[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <DstType D> void src_n(const SkXfermode*, uint32_t dst[],
|
||||
const SkPM4f src[], int count, const SkAlpha aa[]) {
|
||||
template <DstType D> void src_n(SkBlendMode, uint32_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
unsigned a = 0xFF;
|
||||
if (aa) {
|
||||
@ -188,8 +187,8 @@ static Sk4f lerp(const Sk4f& src, const Sk4f& dst, const Sk4f& src_scale) {
|
||||
return dst + (src - dst) * src_scale;
|
||||
}
|
||||
|
||||
template <DstType D> void src_1(const SkXfermode*, uint32_t dst[],
|
||||
const SkPM4f* src, int count, const SkAlpha aa[]) {
|
||||
template <DstType D> void src_1(SkBlendMode, uint32_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
const Sk4f s4 = src->to4f_pmorder();
|
||||
|
||||
if (aa) {
|
||||
@ -225,7 +224,7 @@ const SkXfermode::D32Proc gProcs_Src[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void dst(const SkXfermode*, uint32_t dst[], const SkPM4f[], int count, const SkAlpha aa[]) {}
|
||||
static void dst(SkBlendMode, uint32_t dst[], const SkPM4f[], int count, const SkAlpha aa[]) {}
|
||||
|
||||
const SkXfermode::D32Proc gProcs_Dst[] = {
|
||||
dst, dst, dst, dst, dst, dst, dst, dst,
|
||||
@ -234,8 +233,8 @@ const SkXfermode::D32Proc gProcs_Dst[] = {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template <DstType D> void srcover_n(const SkXfermode*, uint32_t dst[],
|
||||
const SkPM4f src[], int count, const SkAlpha aa[]) {
|
||||
template <DstType D> void srcover_n(SkBlendMode, uint32_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
unsigned a = aa[i];
|
||||
@ -276,8 +275,8 @@ template <DstType D> void srcover_n(const SkXfermode*, uint32_t dst[],
|
||||
}
|
||||
}
|
||||
|
||||
static void srcover_linear_dst_1(const SkXfermode*, uint32_t dst[],
|
||||
const SkPM4f* src, int count, const SkAlpha aa[]) {
|
||||
static void srcover_linear_dst_1(SkBlendMode, uint32_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
const Sk4f s4 = src->to4f_pmorder();
|
||||
const Sk4f dst_scale = Sk4f(1 - get_alpha(s4));
|
||||
|
||||
@ -305,8 +304,8 @@ static void srcover_linear_dst_1(const SkXfermode*, uint32_t dst[],
|
||||
}
|
||||
}
|
||||
|
||||
static void srcover_srgb_dst_1(const SkXfermode*, uint32_t dst[],
|
||||
const SkPM4f* src, int count, const SkAlpha aa[]) {
|
||||
static void srcover_srgb_dst_1(SkBlendMode, uint32_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
Sk4f s4 = src->to4f_pmorder();
|
||||
Sk4f dst_scale = Sk4f(1 - get_alpha(s4));
|
||||
|
||||
@ -360,33 +359,21 @@ const SkXfermode::D32Proc gProcs_SrcOver[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkXfermode::D32Proc find_proc(SkXfermode::Mode mode, uint32_t flags) {
|
||||
SkXfermode::D32Proc SkXfermode::GetD32Proc(SkBlendMode mode, uint32_t flags) {
|
||||
SkASSERT(0 == (flags & ~7));
|
||||
flags &= 7;
|
||||
|
||||
switch (mode) {
|
||||
case SkXfermode::kClear_Mode: return gProcs_Clear[flags];
|
||||
case SkXfermode::kSrc_Mode: return gProcs_Src[flags];
|
||||
case SkXfermode::kDst_Mode: return gProcs_Dst[flags];
|
||||
case SkXfermode::kSrcOver_Mode: return gProcs_SrcOver[flags];
|
||||
case SkBlendMode::kClear: return gProcs_Clear[flags];
|
||||
case SkBlendMode::kSrc: return gProcs_Src[flags];
|
||||
case SkBlendMode::kDst: return gProcs_Dst[flags];
|
||||
case SkBlendMode::kSrcOver: return gProcs_SrcOver[flags];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return gProcs_General[flags];
|
||||
}
|
||||
|
||||
SkXfermode::D32Proc SkXfermode::onGetD32Proc(uint32_t flags) const {
|
||||
SkASSERT(0 == (flags & ~7));
|
||||
flags &= 7;
|
||||
|
||||
Mode mode;
|
||||
return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags];
|
||||
}
|
||||
|
||||
SkXfermode::D32Proc SkXfermode::GetD32Proc(SkXfermode* xfer, uint32_t flags) {
|
||||
return xfer ? xfer->onGetD32Proc(flags) : find_proc(SkXfermode::kSrcOver_Mode, flags);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#include "SkColorPriv.h"
|
||||
|
||||
|
@ -16,9 +16,9 @@ static Sk4f lerp_by_coverage(const Sk4f& src, const Sk4f& dst, uint8_t srcCovera
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void xfer_1(const SkXfermode* xfer, uint64_t dst[], const SkPM4f* src, int count,
|
||||
static void xfer_1(SkBlendMode mode, uint64_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
SkXfermodeProc4f proc = xfer->getProc4f();
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f(mode);
|
||||
SkPM4f d;
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -36,9 +36,9 @@ static void xfer_1(const SkXfermode* xfer, uint64_t dst[], const SkPM4f* src, in
|
||||
}
|
||||
}
|
||||
|
||||
static void xfer_n(const SkXfermode* xfer, uint64_t dst[], const SkPM4f src[], int count,
|
||||
static void xfer_n(SkBlendMode mode, uint64_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
SkXfermodeProc4f proc = xfer->getProc4f();
|
||||
SkXfermodeProc4f proc = SkXfermode::GetProc4f(mode);
|
||||
SkPM4f d;
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -60,7 +60,7 @@ const SkXfermode::F16Proc gProcs_General[] = { xfer_n, xfer_n, xfer_1, xfer_1 };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void clear(const SkXfermode*, uint64_t dst[], const SkPM4f*, int count, const SkAlpha aa[]) {
|
||||
static void clear(SkBlendMode, uint64_t dst[], const SkPM4f*, int count, const SkAlpha aa[]) {
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (aa[i]) {
|
||||
@ -77,8 +77,7 @@ const SkXfermode::F16Proc gProcs_Clear[] = { clear, clear, clear, clear };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void src_1(const SkXfermode*, uint64_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
static void src_1(SkBlendMode, uint64_t dst[], const SkPM4f* src, int count, const SkAlpha aa[]) {
|
||||
const Sk4f s4 = Sk4f::Load(src->fVec);
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -92,8 +91,7 @@ static void src_1(const SkXfermode*, uint64_t dst[], const SkPM4f* src, int coun
|
||||
}
|
||||
}
|
||||
|
||||
static void src_n(const SkXfermode*, uint64_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
static void src_n(SkBlendMode, uint64_t dst[], const SkPM4f src[], int count, const SkAlpha aa[]) {
|
||||
if (aa) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const Sk4f s4 = Sk4f::Load(src[i].fVec);
|
||||
@ -112,13 +110,13 @@ const SkXfermode::F16Proc gProcs_Src[] = { src_n, src_n, src_1, src_1 };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void dst(const SkXfermode*, uint64_t*, const SkPM4f*, int count, const SkAlpha[]) {}
|
||||
static void dst(SkBlendMode, uint64_t*, const SkPM4f*, int count, const SkAlpha[]) {}
|
||||
|
||||
const SkXfermode::F16Proc gProcs_Dst[] = { dst, dst, dst, dst };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void srcover_1(const SkXfermode*, uint64_t dst[], const SkPM4f* src, int count,
|
||||
static void srcover_1(SkBlendMode, uint64_t dst[], const SkPM4f* src, int count,
|
||||
const SkAlpha aa[]) {
|
||||
const Sk4f s4 = Sk4f::Load(src->fVec);
|
||||
const Sk4f dst_scale = Sk4f(1 - get_alpha(s4));
|
||||
@ -133,7 +131,7 @@ static void srcover_1(const SkXfermode*, uint64_t dst[], const SkPM4f* src, int
|
||||
}
|
||||
}
|
||||
|
||||
static void srcover_n(const SkXfermode*, uint64_t dst[], const SkPM4f src[], int count,
|
||||
static void srcover_n(SkBlendMode, uint64_t dst[], const SkPM4f src[], int count,
|
||||
const SkAlpha aa[]) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Sk4f s = Sk4f::Load(src+i),
|
||||
@ -150,29 +148,17 @@ const SkXfermode::F16Proc gProcs_SrcOver[] = { srcover_n, src_n, srcover_1, src_
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkXfermode::F16Proc find_proc(SkXfermode::Mode mode, uint32_t flags) {
|
||||
SkXfermode::F16Proc SkXfermode::GetF16Proc(SkBlendMode mode, uint32_t flags) {
|
||||
SkASSERT(0 == (flags & ~3));
|
||||
flags &= 3;
|
||||
|
||||
switch (mode) {
|
||||
case SkXfermode::kClear_Mode: return gProcs_Clear[flags];
|
||||
case SkXfermode::kSrc_Mode: return gProcs_Src[flags];
|
||||
case SkXfermode::kDst_Mode: return gProcs_Dst[flags];
|
||||
case SkXfermode::kSrcOver_Mode: return gProcs_SrcOver[flags];
|
||||
case SkBlendMode::kClear: return gProcs_Clear[flags];
|
||||
case SkBlendMode::kSrc: return gProcs_Src[flags];
|
||||
case SkBlendMode::kDst: return gProcs_Dst[flags];
|
||||
case SkBlendMode::kSrcOver: return gProcs_SrcOver[flags];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return gProcs_General[flags];
|
||||
}
|
||||
|
||||
SkXfermode::F16Proc SkXfermode::onGetF16Proc(uint32_t flags) const {
|
||||
SkASSERT(0 == (flags & ~3));
|
||||
flags &= 3;
|
||||
|
||||
Mode mode;
|
||||
return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags];
|
||||
}
|
||||
|
||||
SkXfermode::F16Proc SkXfermode::GetF16Proc(SkXfermode* xfer, uint32_t flags) {
|
||||
return xfer ? xfer->onGetF16Proc(flags) : find_proc(SkXfermode::kSrcOver_Mode, flags);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static SkColor xferColor(SkColor src, SkColor dst, SkBlendMode mode) {
|
||||
default: {
|
||||
SkPMColor pmS = SkPreMultiplyColor(src);
|
||||
SkPMColor pmD = SkPreMultiplyColor(dst);
|
||||
SkPMColor result = SkXfermode::GetProc((SkXfermode::Mode)mode)(pmS, pmD);
|
||||
SkPMColor result = SkXfermode::GetProc(mode)(pmS, pmD);
|
||||
return SkUnPreMultiply::PMColorToColor(result);
|
||||
}
|
||||
}
|
||||
|
@ -320,8 +320,8 @@ SkXfermodeImageFilter_Base::makeFGFrag(sk_sp<GrFragmentProcessor> bgFP) const {
|
||||
// than us and won't return a kSrcOver_Mode SkXfermode. That means we
|
||||
// have to get one the hard way.
|
||||
struct ProcCoeff rec;
|
||||
rec.fProc = SkXfermode::GetProc(SkXfermode::kSrcOver_Mode);
|
||||
SkXfermode::ModeAsCoeff(SkXfermode::kSrcOver_Mode, &rec.fSC, &rec.fDC);
|
||||
rec.fProc = SkXfermode::GetProc(SkBlendMode::kSrcOver);
|
||||
SkXfermode::ModeAsCoeff(SkBlendMode::kSrcOver, &rec.fSC, &rec.fDC);
|
||||
|
||||
srcover.reset(new SkProcCoeffXfermode(rec, SkBlendMode::kSrcOver));
|
||||
xfer = srcover.get();
|
||||
|
@ -462,13 +462,8 @@ LinearGradient4fContext::mapTs(int x, int y, SkScalar ts[], int count) const {
|
||||
|
||||
bool SkLinearGradient::LinearGradient4fContext::onChooseBlitProcs(const SkImageInfo& info,
|
||||
BlitState* state) {
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(state->fXfer, &mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode != SkXfermode::kSrc_Mode &&
|
||||
!(mode == SkXfermode::kSrcOver_Mode && (fFlags & kOpaqueAlpha_Flag))) {
|
||||
if (state->fMode != SkBlendMode::kSrc &&
|
||||
!(state->fMode == SkBlendMode::kSrcOver && (fFlags & kOpaqueAlpha_Flag))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -111,9 +111,9 @@ static bool compare_procs(SkXfermodeProc proc32, SkXfermodeProc4f proc4f) {
|
||||
DEF_TEST(Color4f_xfermode_proc4f, reporter) {
|
||||
// TODO: extend xfermodes so that all cases can be tested.
|
||||
//
|
||||
for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; ++mode) {
|
||||
SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode);
|
||||
SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode);
|
||||
for (int mode = (int)SkBlendMode::kClear; mode <= (int)SkBlendMode::kScreen; ++mode) {
|
||||
SkXfermodeProc proc32 = SkXfermode::GetProc((SkBlendMode)mode);
|
||||
SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkBlendMode)mode);
|
||||
REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user