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

Unified Diff: bench/ImageFilterCollapse.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 | « bench/ColorFilterBench.cpp ('k') | gm/blurredclippedcircle.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ImageFilterCollapse.cpp
diff --git a/bench/ImageFilterCollapse.cpp b/bench/ImageFilterCollapse.cpp
index cafcd38c6e94cbf0054ea26fa5d6cd16f077e913..bd3f80fefb59a2b9f89b1f46c34ec8d54b0736f0 100644
--- a/bench/ImageFilterCollapse.cpp
+++ b/bench/ImageFilterCollapse.cpp
@@ -28,12 +28,12 @@
}
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 @@
};
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 @@
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();
+ }
}
};
« no previous file with comments | « bench/ColorFilterBench.cpp ('k') | gm/blurredclippedcircle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698