Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: src/core/SkSpriteBlitter4f.cpp

Issue 1721223002: simplify/unify xferproc api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBlitter_PM4f.cpp ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpriteBlitter4f.cpp
diff --git a/src/core/SkSpriteBlitter4f.cpp b/src/core/SkSpriteBlitter4f.cpp
index fc4b4809511f1bec8730afdb84b2a0ddcf326b94..474bf4d0f606bb0681dc6dd748b747f7bce1692a 100644
--- a/src/core/SkSpriteBlitter4f.cpp
+++ b/src/core/SkSpriteBlitter4f.cpp
@@ -13,12 +13,14 @@
class Sprite_4f : public SkSpriteBlitter {
public:
Sprite_4f(const SkPixmap& src, const SkPaint& paint) : INHERITED(src) {
+ fXfer = paint.getXfermode();
fLoader = SkLoadSpanProc_Choose(src.info());
fFilter = SkFilterSpanProc_Choose(paint);
fBuffer.reset(src.width());
}
protected:
+ SkXfermode* fXfer;
SkLoadSpanProc fLoader;
SkFilterSpanProc fFilter;
SkAutoTMalloc<SkPM4f> fBuffer;
@@ -29,22 +31,14 @@ private:
///////////////////////////////////////////////////////////////////////////////////////////////////
-static SkXfermode::Mode get_mode(const SkXfermode* xfer) {
- SkXfermode::Mode mode;
- if (!SkXfermode::AsMode(xfer, &mode)) {
- mode = SkXfermode::kSrcOver_Mode;
- }
- return mode;
-}
-
class Sprite_F16 : public Sprite_4f {
public:
Sprite_F16(const SkPixmap& src, const SkPaint& paint) : INHERITED(src, paint) {
- fState = { paint.getXfermode(), SkXfermode::kDstIsFloat16_U64Flag };
+ uint32_t flags = SkXfermode::kDstIsFloat16_D64Flag;
if (src.isOpaque()) {
- fState.fFlags |= SkXfermode::kSrcIsOpaque_U64Flag;
+ flags |= SkXfermode::kSrcIsOpaque_D64Flag;
}
- fXfer = SkXfermode::GetU64ProcN(get_mode(fState.fXfer), fState.fFlags);
+ fWriter = SkXfermode::GetD64Proc(fXfer, flags);
}
void blitRect(int x, int y, int width, int height) override {
@@ -55,14 +49,13 @@ public:
for (int bottom = y + height; y < bottom; ++y) {
fLoader(fSource, x - fLeft, y - fTop, fBuffer, width);
fFilter(*fPaint, fBuffer, width);
- fXfer(fState, dst, fBuffer, width, nullptr);
+ fWriter(fXfer, dst, fBuffer, width, nullptr);
dst = (uint64_t* SK_RESTRICT)((char*)dst + dstRB);
}
}
private:
- SkXfermode::U64State fState;
- SkXfermode::U64ProcN fXfer;
+ SkXfermode::D64Proc fWriter;
typedef Sprite_4f INHERITED;
};
@@ -90,11 +83,11 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseF16(const SkPixmap& source, const SkPain
class Sprite_sRGB : public Sprite_4f {
public:
Sprite_sRGB(const SkPixmap& src, const SkPaint& paint) : INHERITED(src, paint) {
- fState = { paint.getXfermode(), SkXfermode::kDstIsSRGB_PM4fFlag };
+ uint32_t flags = SkXfermode::kDstIsSRGB_D32Flag;
if (src.isOpaque()) {
- fState.fFlags |= SkXfermode::kSrcIsOpaque_PM4fFlag;
+ flags |= SkXfermode::kSrcIsOpaque_D32Flag;
}
- fXfer = SkXfermode::GetPM4fProcN(get_mode(fState.fXfer), fState.fFlags);
+ fWriter = SkXfermode::GetD32Proc(fXfer, flags);
}
void blitRect(int x, int y, int width, int height) override {
@@ -105,14 +98,13 @@ public:
for (int bottom = y + height; y < bottom; ++y) {
fLoader(fSource, x - fLeft, y - fTop, fBuffer, width);
fFilter(*fPaint, fBuffer, width);
- fXfer(fState, dst, fBuffer, width, nullptr);
+ fWriter(fXfer, dst, fBuffer, width, nullptr);
dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
}
}
protected:
- SkXfermode::PM4fState fState;
- SkXfermode::PM4fProcN fXfer;
+ SkXfermode::D32Proc fWriter;
private:
typedef Sprite_4f INHERITED;
« no previous file with comments | « src/core/SkBlitter_PM4f.cpp ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698