diff options
author | Mike Reed <reed@google.com> | 2016-10-03 18:02:50 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-03 18:03:29 +0000 |
commit | ce02e7175872abde3721df9e5d3ec0ab8384cd8e (patch) | |
tree | 620eec63e1082137df3111d09cd2bf1eb7ebd180 /src/utils | |
parent | 6fb592e6afb0061c9c0af15ddf599e2903f508f1 (diff) |
Revert "replace SkXfermode obj with SkBlendMode enum in paints"
This reverts commit I4fb489ba6b3f77b458f7e4a99f79c7ad10859135.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> replace SkXfermode obj with SkBlendMode enum in paints
>
> BUG=skia:5814
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2714
>
> Change-Id: I4fb489ba6b3f77b458f7e4a99f79c7ad10859135
> Reviewed-on: https://skia-review.googlesource.com/2714
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
>
TBR=bsalomon@google.com,fmalita@chromium.org,fmalita@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I3e43f79ef5c1709929663fe63cc1f67cd78270b7
Reviewed-on: https://skia-review.googlesource.com/2871
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: 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( |