diff options
author | Mike Reed <reed@google.com> | 2016-10-05 19:59:51 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-05 20:20:14 +0000 |
commit | c245574ba3d0e2ade6c94b2812de3baa383bf4c4 (patch) | |
tree | e008f8500d56d8487a2941cb217c5ff8d1151dcf /src/utils | |
parent | 62f6856ebe003743192508653914b5e01ffcc857 (diff) |
Revert[7] "replace SkXfermode obj with SkBlendMode enum in paints"
This reverts commit Ib4a154cdd5f5d1dcac921ef50d53b79a2d6a1be8.
Reason for revert: new assert from 100K bot
Original change's description:
> Revert[6] "replace SkXfermode obj with SkBlendMode enum in paints"
>
> - perform version check in CreateProc for XfermodeImageFilter and ArithmeticImageFilter
> This reverts commit 3ed485f4249e17abb4b11f5018d03175fd1afb44.
>
> BUG=skia:
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2992
>
> Change-Id: Ib4a154cdd5f5d1dcac921ef50d53b79a2d6a1be8
> Reviewed-on: https://skia-review.googlesource.com/2992
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
>
TBR=reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I848e5a69c5cd67f2c14889f4f0a346652578c4ff
Reviewed-on: https://skia-review.googlesource.com/3023
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkDumpCanvas.cpp | 8 | ||||
-rw-r--r-- | src/utils/SkLua.cpp | 40 | ||||
-rw-r--r-- | src/utils/SkRGBAToYUV.cpp | 2 |
3 files changed, 44 insertions, 6 deletions
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index 68bd13eccb..fcb24d28c4 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -209,8 +209,8 @@ SkCanvas::SaveLayerStrategy SkDumpCanvas::getSaveLayerStrategy(const SaveLayerRe if (paint->getAlpha() != 0xFF) { str.appendf(" alpha:0x%02X", paint->getAlpha()); } - if (!paint->isSrcOver()) { - str.appendf(" blendmode:%d", paint->getBlendMode()); + if (paint->getXfermode()) { + str.appendf(" xfermode:%p", paint->getXfermode()); } } this->dump(kSave_Verb, paint, str.c_str()); @@ -540,10 +540,8 @@ void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb, if (p) { msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags()); - if (!p->isSrcOver()) { - msg.appendf(" blendmode:%d", p->getBlendMode()); - } appendFlattenable(&msg, p->getShader(), "shader"); + appendFlattenable(&msg, p->getXfermode(), "xfermode"); appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); appendFlattenable(&msg, p->getMaskFilter(), "maskFilter"); appendFlattenable(&msg, p->getPathEffect(), "pathEffect"); diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index ba311af61c..e80708c71c 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -28,6 +28,7 @@ #include "SkSurface.h" #include "SkTextBlob.h" #include "SkTypeface.h" +#include "SkXfermode.h" extern "C" { #include "lua.h" @@ -58,6 +59,7 @@ DEF_MTNAME(SkShader) DEF_MTNAME(SkSurface) DEF_MTNAME(SkTextBlob) DEF_MTNAME(SkTypeface) +DEF_MTNAME(SkXfermode) template <typename T> T* push_new(lua_State* L) { T* addr = (T*)lua_newuserdata(L, sizeof(T)); @@ -1071,9 +1073,26 @@ static int lpaint_getEffects(lua_State* L) { setfield_bool_if(L, "shader", !!paint->getShader()); setfield_bool_if(L, "colorFilter", !!paint->getColorFilter()); setfield_bool_if(L, "imageFilter", !!paint->getImageFilter()); + setfield_bool_if(L, "xfermode", !!paint->getXfermode()); return 1; } +static int lpaint_getXfermode(lua_State* L) { + const SkPaint* paint = get_obj<SkPaint>(L, 1); + SkXfermode* xfermode = paint->getXfermode(); + if (xfermode) { + push_ref(L, xfermode); + return 1; + } + return 0; +} + +static int lpaint_setXfermode(lua_State* L) { + SkPaint* paint = get_obj<SkPaint>(L, 1); + paint->setXfermode(sk_ref_sp(get_ref<SkXfermode>(L, 2))); + return 0; +} + static int lpaint_getColorFilter(lua_State* L) { const SkPaint* paint = get_obj<SkPaint>(L, 1); SkColorFilter* cf = paint->getColorFilter(); @@ -1198,6 +1217,8 @@ static const struct luaL_Reg gSkPaint_Methods[] = { { "setColorFilter", lpaint_setColorFilter }, { "getImageFilter", lpaint_getImageFilter }, { "setImageFilter", lpaint_setImageFilter }, + { "getXfermode", lpaint_getXfermode }, + { "setXfermode", lpaint_setXfermode }, { "getShader", lpaint_getShader }, { "setShader", lpaint_setShader }, { "getPathEffect", lpaint_getPathEffect }, @@ -1320,6 +1341,24 @@ static const struct luaL_Reg gSkPathEffect_Methods[] = { /////////////////////////////////////////////////////////////////////////////// +static int lpxfermode_getTypeName(lua_State* L) { + lua_pushstring(L, get_ref<SkXfermode>(L, 1)->getTypeName()); + return 1; +} + +static int lpxfermode_gc(lua_State* L) { + get_ref<SkXfermode>(L, 1)->unref(); + return 0; +} + +static const struct luaL_Reg gSkXfermode_Methods[] = { + { "getTypeName", lpxfermode_getTypeName }, + { "__gc", lpxfermode_gc }, + { nullptr, nullptr } +}; + +/////////////////////////////////////////////////////////////////////////////// + static int lpcolorfilter_gc(lua_State* L) { get_ref<SkColorFilter>(L, 1)->unref(); return 0; @@ -2139,6 +2178,7 @@ void SkLua::Load(lua_State* L) { REG_CLASS(L, SkSurface); REG_CLASS(L, SkTextBlob); REG_CLASS(L, SkTypeface); + REG_CLASS(L, SkXfermode); } extern "C" int luaopen_skia(lua_State* L); diff --git a/src/utils/SkRGBAToYUV.cpp b/src/utils/SkRGBAToYUV.cpp index 0528b144f0..63d9152362 100644 --- a/src/utils/SkRGBAToYUV.cpp +++ b/src/utils/SkRGBAToYUV.cpp @@ -45,7 +45,7 @@ bool SkRGBAToYUV(const SkImage* image, const SkISize sizes[3], void* const plane } SkPaint paint; paint.setFilterQuality(kLow_SkFilterQuality); - paint.setBlendMode(SkBlendMode::kSrc); + paint.setXfermodeMode(SkXfermode::kSrc_Mode); int rowStartIdx = 5 * i; const SkScalar* row = kYUVColorSpaceInvMatrices[colorSpace] + rowStartIdx; paint.setColorFilter( |