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

Unified Diff: samplecode/SampleFilterFuzz.cpp

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « samplecode/SampleColorFilter.cpp ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFilterFuzz.cpp
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index dd0fa4044e6f5b9bbeaf776b4d454d7311ecea78..82934ea3cc774079e7bcef4f17cdf1cf6bfca582 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -298,9 +298,9 @@
return bitmap[R(2)];
}
-static SkData* make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
+static sk_sp<SkData> make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
int size = 4 << R(5);
- SkData* data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size);
+ auto data = SkData::MakeUninitialized(sizeof(SkColor) * size * size * size);
SkColor* pixels = (SkColor*)(data->writable_data());
SkAutoTMalloc<uint8_t> lutMemory(size);
SkAutoTMalloc<uint8_t> invLutMemory(size);
@@ -350,20 +350,17 @@
}
}
-static SkColorFilter* make_color_filter() {
- SkColorFilter* colorFilter;
+static sk_sp<SkColorFilter> make_color_filter() {
switch (R(6)) {
case 0: {
SkScalar array[20];
for (int i = 0; i < 20; ++i) {
array[i] = make_scalar();
}
- colorFilter = SkColorMatrixFilter::Create(array);
- break;
+ return SkColorFilter::MakeMatrixFilterRowMajor255(array);
}
case 1:
- colorFilter = SkLumaColorFilter::Create();
- break;
+ return SkLumaColorFilter::Make();
case 2: {
uint8_t tableA[256];
uint8_t tableR[256];
@@ -373,21 +370,17 @@
rand_color_table(tableR);
rand_color_table(tableG);
rand_color_table(tableB);
- colorFilter = SkTableColorFilter::CreateARGB(tableA, tableR, tableG, tableB);
- break;
+ return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
}
case 3:
- colorFilter = SkColorFilter::CreateModeFilter(make_color(), make_xfermode());
- break;
+ return SkColorFilter::MakeModeFilter(make_color(), make_xfermode());
case 4:
- colorFilter = SkColorMatrixFilter::CreateLightingFilter(make_color(), make_color());
- break;
+ return SkColorMatrixFilter::MakeLightingFilter(make_color(), make_color());
case 5:
default:
- colorFilter = nullptr;
- break;
- }
- return colorFilter;
+ break;
+ }
+ return nullptr;
}
static SkPath make_path() {
@@ -538,7 +531,7 @@
rasterizerBuilder.addLayer(paintForRasterizer);
paint.setRasterizer(rasterizerBuilder.detach());
paint.setImageFilter(make_image_filter());
- SkAutoDataUnref data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
+ sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
paint.setTextAlign(make_paint_align());
paint.setTextSize(make_scalar());
paint.setTextScaleX(make_scalar());
@@ -567,16 +560,16 @@
break;
case COLOR:
{
- SkAutoTUnref<SkColorFilter> cf(make_color_filter());
- filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filter()) : 0;
+ sk_sp<SkColorFilter> cf(make_color_filter());
+ filter = cf ? SkColorFilterImageFilter::Create(cf.get(), make_image_filter()) : 0;
}
break;
case LUT3D:
{
int cubeDimension;
- SkAutoDataUnref lut3D(make_3Dlut(&cubeDimension, (R(2) == 1), (R(2) == 1), (R(2) == 1)));
- SkAutoTUnref<SkColorFilter> cf(SkColorCubeFilter::Create(lut3D, cubeDimension));
- filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filter()) : 0;
+ sk_sp<SkData> lut3D(make_3Dlut(&cubeDimension, (R(2) == 1), (R(2) == 1), (R(2) == 1)));
+ sk_sp<SkColorFilter> cf(SkColorCubeFilter::Make(lut3D, cubeDimension));
+ filter = cf ? SkColorFilterImageFilter::Create(cf.get(), make_image_filter()) : 0;
}
break;
case BLUR:
« no previous file with comments | « samplecode/SampleColorFilter.cpp ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698