From d6889293dd0942f27f9593f679722c956831f2c4 Mon Sep 17 00:00:00 2001 From: reed Date: Tue, 22 Mar 2016 08:59:19 -0700 Subject: Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #3 id:40001 of https://codereview.chromium.org/1825073002/ ) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reason for revert: CreateModeFilter not compiling Original issue's description: > Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.org/1822623002/ )" > > Fixed legacy withColorFilter to call new(er) make method > > This reverts commit 1eb81db650d31f50be67b12d60c4f9e7dd08432f. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825073002 > > TBR= > > Committed: https://skia.googlesource.com/skia/+/4c9776b046dd5e9e46e2d1ce35154855c8fcb381 TBR= # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1821103004 --- gm/tablecolorfilter.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'gm/tablecolorfilter.cpp') diff --git a/gm/tablecolorfilter.cpp b/gm/tablecolorfilter.cpp index c9ca474e76..dcc29f37cf 100644 --- a/gm/tablecolorfilter.cpp +++ b/gm/tablecolorfilter.cpp @@ -73,27 +73,27 @@ static void make_table2(uint8_t table[]) { } } -static sk_sp make_null_cf() { +static SkColorFilter* make_null_cf() { return nullptr; } -static sk_sp make_cf0() { +static SkColorFilter* make_cf0() { uint8_t table[256]; make_table0(table); - return SkTableColorFilter::Make(table); + return SkTableColorFilter::Create(table); } -static sk_sp make_cf1() { +static SkColorFilter* make_cf1() { uint8_t table[256]; make_table1(table); - return SkTableColorFilter::Make(table); + return SkTableColorFilter::Create(table); } -static sk_sp make_cf2() { +static SkColorFilter* make_cf2() { uint8_t table[256]; make_table2(table); - return SkTableColorFilter::Make(table); + return SkTableColorFilter::Create(table); } -static sk_sp make_cf3() { +static SkColorFilter* make_cf3() { uint8_t table0[256]; make_table0(table0); uint8_t table1[256]; make_table1(table1); uint8_t table2[256]; make_table2(table2); - return SkTableColorFilter::MakeARGB(nullptr, table0, table1, table2); + return SkTableColorFilter::CreateARGB(nullptr, table0, table1, table2); } class TableColorFilterGM : public skiagm::GM { @@ -114,9 +114,8 @@ protected: canvas->translate(20, 20); - static sk_sp (*gColorFilterMakers[])() = { - make_null_cf, make_cf0, make_cf1, make_cf2, make_cf3 - }; + static SkColorFilter* (*gColorFilterMakers[])() = { make_null_cf, make_cf0, make_cf1, + make_cf2, make_cf3 }; static void (*gBitmapMakers[])(SkBitmap*) = { make_bm0, make_bm1 }; // This test will be done once for each bitmap with the results stacked vertically. @@ -156,25 +155,25 @@ protected: // each draw being at xOffset of the previous one for (unsigned i = 1; i < SK_ARRAY_COUNT(gColorFilterMakers); ++i) { x += xOffset; - paint.setColorFilter(gColorFilterMakers[i]()); + paint.setColorFilter(gColorFilterMakers[i]())->unref(); canvas->drawBitmap(bm, x, y, &paint); } paint.setColorFilter(nullptr); for (unsigned i = 0; i < SK_ARRAY_COUNT(gColorFilterMakers); ++i) { - auto colorFilter1(gColorFilterMakers[i]()); + SkAutoTUnref colorFilter1(gColorFilterMakers[i]()); SkAutoTUnref imageFilter1(SkColorFilterImageFilter::Create( - colorFilter1.get(), nullptr, nullptr)); + colorFilter1, nullptr, nullptr)); // Move down to the next line and draw it // each draw being at xOffset of the previous one y += yOffset; x = 0; for (unsigned j = 1; j < SK_ARRAY_COUNT(gColorFilterMakers); ++j) { - auto colorFilter2(gColorFilterMakers[j]()); + SkAutoTUnref colorFilter2(gColorFilterMakers[j]()); SkAutoTUnref imageFilter2(SkColorFilterImageFilter::Create( - colorFilter2.get(), imageFilter1, nullptr)); + colorFilter2, imageFilter1, nullptr)); paint.setImageFilter(imageFilter2); canvas->drawBitmap(bm, x, y, &paint); x += xOffset; @@ -226,11 +225,11 @@ protected: canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); const int MODES = MODE_COUNT * COLOR_COUNT; - sk_sp filters[MODES]; + SkAutoTUnref filters[MODES]; int index = 0; for (int i = 0; i < MODE_COUNT; ++i) { for (int j = 0; j < COLOR_COUNT; ++j) { - filters[index++] = SkColorFilter::MakeModeFilter(fColors[j], fModes[i]); + filters[index++].reset(SkColorFilter::CreateModeFilter(fColors[j], fModes[i])); } } @@ -262,7 +261,9 @@ protected: for (int y = 0; y < MODES; ++y) { canvas->save(); for (int x = 0; x < MODES; ++x) { - paint.setColorFilter(SkColorFilter::MakeComposeFilter(filters[y], filters[x])); + SkAutoTUnref compose(SkColorFilter::CreateComposeFilter(filters[y], + filters[x])); + paint.setColorFilter(compose); canvas->drawRect(r, paint); canvas->translate(r.width() + spacer, 0); } -- cgit v1.2.3