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

Unified Diff: samplecode/SampleFilterFuzz.cpp

Issue 1821103004: Revert of Revert[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 82934ea3cc774079e7bcef4f17cdf1cf6bfca582..dd0fa4044e6f5b9bbeaf776b4d454d7311ecea78 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -298,9 +298,9 @@
return bitmap[R(2)];
}
-static sk_sp<SkData> make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
+static SkData* make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
int size = 4 << R(5);
- auto data = SkData::MakeUninitialized(sizeof(SkColor) * size * size * size);
+ SkData* data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size);
SkColor* pixels = (SkColor*)(data->writable_data());
SkAutoTMalloc<uint8_t> lutMemory(size);
SkAutoTMalloc<uint8_t> invLutMemory(size);
@@ -350,17 +350,20 @@
}
}
-static sk_sp<SkColorFilter> make_color_filter() {
+static SkColorFilter* make_color_filter() {
+ SkColorFilter* colorFilter;
switch (R(6)) {
case 0: {
SkScalar array[20];
for (int i = 0; i < 20; ++i) {
array[i] = make_scalar();
}
- return SkColorFilter::MakeMatrixFilterRowMajor255(array);
+ colorFilter = SkColorMatrixFilter::Create(array);
+ break;
}
case 1:
- return SkLumaColorFilter::Make();
+ colorFilter = SkLumaColorFilter::Create();
+ break;
case 2: {
uint8_t tableA[256];
uint8_t tableR[256];
@@ -370,17 +373,21 @@
rand_color_table(tableR);
rand_color_table(tableG);
rand_color_table(tableB);
- return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
+ colorFilter = SkTableColorFilter::CreateARGB(tableA, tableR, tableG, tableB);
+ break;
}
case 3:
- return SkColorFilter::MakeModeFilter(make_color(), make_xfermode());
+ colorFilter = SkColorFilter::CreateModeFilter(make_color(), make_xfermode());
+ break;
case 4:
- return SkColorMatrixFilter::MakeLightingFilter(make_color(), make_color());
+ colorFilter = SkColorMatrixFilter::CreateLightingFilter(make_color(), make_color());
+ break;
case 5:
default:
- break;
- }
- return nullptr;
+ colorFilter = nullptr;
+ break;
+ }
+ return colorFilter;
}
static SkPath make_path() {
@@ -531,7 +538,7 @@
rasterizerBuilder.addLayer(paintForRasterizer);
paint.setRasterizer(rasterizerBuilder.detach());
paint.setImageFilter(make_image_filter());
- sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
+ SkAutoDataUnref data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
paint.setTextAlign(make_paint_align());
paint.setTextSize(make_scalar());
paint.setTextScaleX(make_scalar());
@@ -560,16 +567,16 @@
break;
case COLOR:
{
- sk_sp<SkColorFilter> cf(make_color_filter());
- filter = cf ? SkColorFilterImageFilter::Create(cf.get(), make_image_filter()) : 0;
+ SkAutoTUnref<SkColorFilter> cf(make_color_filter());
+ filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filter()) : 0;
}
break;
case LUT3D:
{
int cubeDimension;
- 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;
+ 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;
}
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