Index: bench/ImageFilterCollapse.cpp |
diff --git a/bench/ImageFilterCollapse.cpp b/bench/ImageFilterCollapse.cpp |
index bd3f80fefb59a2b9f89b1f46c34ec8d54b0736f0..cafcd38c6e94cbf0054ea26fa5d6cd16f077e913 100644 |
--- a/bench/ImageFilterCollapse.cpp |
+++ b/bench/ImageFilterCollapse.cpp |
@@ -28,12 +28,12 @@ |
} |
protected: |
- void doPreDraw(SkColorFilter* colorFilters[], int nFilters) { |
+ void doPreDraw(sk_sp<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], fImageFilter, nullptr) |
+ SkColorFilterImageFilter::Create(colorFilters[i].get(), fImageFilter, nullptr) |
); |
SkRefCnt_SafeAssign(fImageFilter, filter.get()); |
} |
@@ -73,15 +73,12 @@ |
}; |
class TableCollapseBench: public BaseImageFilterCollapseBench { |
-public: |
- virtual ~TableCollapseBench() {} |
- |
protected: |
- virtual const char* onGetName() override { |
+ const char* onGetName() override { |
return "image_filter_collapse_table"; |
} |
- virtual void onDelayedSetup() override { |
+ void onDelayedSetup() override { |
for (int i = 0; i < 256; ++i) { |
int n = i >> 5; |
table1[i] = (n << 5) | (n << 2) | (n >> 1); |
@@ -92,63 +89,52 @@ |
table3[i] = static_cast<uint8_t>(sqrtf(fi) * 255); |
} |
- SkColorFilter* colorFilters[] = { |
- SkTableColorFilter::Create(table1), |
- SkTableColorFilter::Create(table2), |
- SkTableColorFilter::Create(table3), |
+ sk_sp<SkColorFilter> colorFilters[] = { |
+ SkTableColorFilter::Make(table1), |
+ SkTableColorFilter::Make(table2), |
+ SkTableColorFilter::Make(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 SkColorFilter* make_brightness(float amount) { |
+static sk_sp<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 SkColorMatrixFilter::Create(matrix); |
+ return SkColorFilter::MakeMatrixFilterRowMajor255(matrix); |
} |
-static SkColorFilter* make_grayscale() { |
+static sk_sp<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 SkColorMatrixFilter::Create(matrix); |
+ return SkColorFilter::MakeMatrixFilterRowMajor255(matrix); |
} |
class MatrixCollapseBench: public BaseImageFilterCollapseBench { |
-public: |
- virtual ~MatrixCollapseBench() {} |
- |
protected: |
- virtual const char* onGetName() override { |
+ const char* onGetName() override { |
return "image_filter_collapse_matrix"; |
} |
- virtual void onDelayedSetup() override { |
- SkColorFilter* colorFilters[] = { |
+ void onDelayedSetup() override { |
+ sk_sp<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(); |
- } |
} |
}; |