aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-22 08:59:19 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-22 08:59:19 -0700
commitd6889293dd0942f27f9593f679722c956831f2c4 (patch)
treee7c4f9aa9ee2c4e318e8e5c8d69f6918fba1e865 /bench
parent1088db92348baa013511a49392178fccf03e8008 (diff)
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/ )
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
Diffstat (limited to 'bench')
-rw-r--r--bench/BlurRoundRectBench.cpp5
-rw-r--r--bench/ColorCubeBench.cpp16
-rw-r--r--bench/ColorFilterBench.cpp13
-rw-r--r--bench/ImageFilterCollapse.cpp44
4 files changed, 51 insertions, 27 deletions
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp
index 46f410d3b3..85852d581e 100644
--- a/bench/BlurRoundRectBench.cpp
+++ b/bench/BlurRoundRectBench.cpp
@@ -54,8 +54,9 @@ public:
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf),
SkBlurMaskFilter::kHighQuality_BlurFlag);
paint->setMaskFilter(maskFilter)->unref();
- paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY,
- SkXfermode::kSrcIn_Mode));
+ SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(SK_ColorLTGRAY,
+ SkXfermode::kSrcIn_Mode);
+ paint->setColorFilter(colorFilter)->unref();
paint->setColor(SK_ColorGRAY);
}
{
diff --git a/bench/ColorCubeBench.cpp b/bench/ColorCubeBench.cpp
index 6a7774012d..9f6bd001ff 100644
--- a/bench/ColorCubeBench.cpp
+++ b/bench/ColorCubeBench.cpp
@@ -13,14 +13,20 @@
class ColorCubeBench : public Benchmark {
SkISize fSize;
int fCubeDimension;
- sk_sp<SkData> fCubeData;
+ SkData* fCubeData;
SkBitmap fBitmap;
public:
- ColorCubeBench() : fCubeDimension(0) {
+ ColorCubeBench()
+ : fCubeDimension(0)
+ , fCubeData(nullptr) {
fSize = SkISize::Make(2880, 1800); // 2014 Macbook Pro resolution
}
+ ~ColorCubeBench() {
+ SkSafeUnref(fCubeData);
+ }
+
protected:
const char* onGetName() override {
return "colorcube";
@@ -65,7 +71,7 @@ private:
void makeCubeData() {
fCubeDimension = 32;
- fCubeData = SkData::MakeUninitialized(sizeof(SkColor) *
+ fCubeData = SkData::NewUninitialized(sizeof(SkColor) *
fCubeDimension * fCubeDimension * fCubeDimension);
SkColor* pixels = (SkColor*)(fCubeData->writable_data());
SkAutoTMalloc<uint8_t> lutMemory(fCubeDimension);
@@ -89,7 +95,9 @@ private:
void test(int loops, SkCanvas* canvas) {
SkPaint paint;
for (int i = 0; i < loops; i++) {
- paint.setColorFilter(SkColorCubeFilter::Make(fCubeData, fCubeDimension));
+ SkAutoTUnref<SkColorFilter> colorCube(
+ SkColorCubeFilter::Create(fCubeData, fCubeDimension));
+ paint.setColorFilter(colorCube);
canvas->drawBitmap(fBitmap, 0, 0, &paint);
}
}
diff --git a/bench/ColorFilterBench.cpp b/bench/ColorFilterBench.cpp
index c4ba1e5dcb..5365a9c2ad 100644
--- a/bench/ColorFilterBench.cpp
+++ b/bench/ColorFilterBench.cpp
@@ -34,8 +34,8 @@ protected:
0, 1, 0, 0, amount255,
0, 0, 1, 0, amount255,
0, 0, 0, 1, 0 };
- auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
- return SkColorFilterImageFilter::Create(filter.get(), input);
+ SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix));
+ return SkColorFilterImageFilter::Create(filter, input);
}
static SkImageFilter* make_grayscale(SkImageFilter* input = nullptr) {
@@ -45,13 +45,14 @@ protected:
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
matrix[18] = 1.0f;
- auto filter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
- return SkColorFilterImageFilter::Create(filter.get(), input);
+ SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix));
+ return SkColorFilterImageFilter::Create(filter, input);
}
static SkImageFilter* make_mode_blue(SkImageFilter* input = nullptr) {
- auto filter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
- return SkColorFilterImageFilter::Create(filter.get(), input);
+ SkAutoTUnref<SkColorFilter> filter(
+ SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
+ return SkColorFilterImageFilter::Create(filter, input);
}
inline bool isSmall() const { return fIsSmall; }
diff --git a/bench/ImageFilterCollapse.cpp b/bench/ImageFilterCollapse.cpp
index cafcd38c6e..bd3f80fefb 100644
--- a/bench/ImageFilterCollapse.cpp
+++ b/bench/ImageFilterCollapse.cpp
@@ -28,12 +28,12 @@ public:
}
protected:
- void doPreDraw(sk_sp<SkColorFilter> colorFilters[], int nFilters) {
+ void doPreDraw(SkColorFilter* colorFilters[], int nFilters) {
// Create a chain of ImageFilters from colorFilters
fImageFilter = nullptr;
for(int i = nFilters; i --> 0;) {
SkAutoTUnref<SkImageFilter> filter(
- SkColorFilterImageFilter::Create(colorFilters[i].get(), fImageFilter, nullptr)
+ SkColorFilterImageFilter::Create(colorFilters[i], fImageFilter, nullptr)
);
SkRefCnt_SafeAssign(fImageFilter, filter.get());
}
@@ -73,12 +73,15 @@ private:
};
class TableCollapseBench: public BaseImageFilterCollapseBench {
+public:
+ virtual ~TableCollapseBench() {}
+
protected:
- const char* onGetName() override {
+ virtual const char* onGetName() override {
return "image_filter_collapse_table";
}
- void onDelayedSetup() override {
+ virtual void onDelayedSetup() override {
for (int i = 0; i < 256; ++i) {
int n = i >> 5;
table1[i] = (n << 5) | (n << 2) | (n >> 1);
@@ -89,52 +92,63 @@ protected:
table3[i] = static_cast<uint8_t>(sqrtf(fi) * 255);
}
- sk_sp<SkColorFilter> colorFilters[] = {
- SkTableColorFilter::Make(table1),
- SkTableColorFilter::Make(table2),
- SkTableColorFilter::Make(table3),
+ SkColorFilter* colorFilters[] = {
+ SkTableColorFilter::Create(table1),
+ SkTableColorFilter::Create(table2),
+ SkTableColorFilter::Create(table3),
};
doPreDraw(colorFilters, SK_ARRAY_COUNT(colorFilters));
+
+ for(unsigned i = 0; i < SK_ARRAY_COUNT(colorFilters); i++) {
+ colorFilters[i]->unref();
+ }
}
private:
uint8_t table1[256], table2[256], table3[256];
};
-static sk_sp<SkColorFilter> make_brightness(float amount) {
+static SkColorFilter* make_brightness(float amount) {
SkScalar amount255 = SkScalarMul(amount, SkIntToScalar(255));
SkScalar matrix[20] = { 1, 0, 0, 0, amount255,
0, 1, 0, 0, amount255,
0, 0, 1, 0, amount255,
0, 0, 0, 1, 0 };
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
+ return SkColorMatrixFilter::Create(matrix);
}
-static sk_sp<SkColorFilter> make_grayscale() {
+static SkColorFilter* make_grayscale() {
SkScalar matrix[20];
memset(matrix, 0, 20 * sizeof(SkScalar));
matrix[0] = matrix[5] = matrix[10] = 0.2126f;
matrix[1] = matrix[6] = matrix[11] = 0.7152f;
matrix[2] = matrix[7] = matrix[12] = 0.0722f;
matrix[18] = 1.0f;
- return SkColorFilter::MakeMatrixFilterRowMajor255(matrix);
+ return SkColorMatrixFilter::Create(matrix);
}
class MatrixCollapseBench: public BaseImageFilterCollapseBench {
+public:
+ virtual ~MatrixCollapseBench() {}
+
protected:
- const char* onGetName() override {
+ virtual const char* onGetName() override {
return "image_filter_collapse_matrix";
}
- void onDelayedSetup() override {
- sk_sp<SkColorFilter> colorFilters[] = {
+ virtual void onDelayedSetup() override {
+ SkColorFilter* colorFilters[] = {
make_brightness(0.1f),
make_grayscale(),
make_brightness(-0.1f),
};
doPreDraw(colorFilters, SK_ARRAY_COUNT(colorFilters));
+
+ for(unsigned i = 0; i < SK_ARRAY_COUNT(colorFilters); i++) {
+ colorFilters[i]->unref();
+ }
}
};