OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) { | 105 static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) { |
106 SkScalar s = amount; | 106 SkScalar s = amount; |
107 SkScalar matrix[20] = { s, 0, 0, 0, 0, | 107 SkScalar matrix[20] = { s, 0, 0, 0, 0, |
108 0, s, 0, 0, 0, | 108 0, s, 0, 0, 0, |
109 0, 0, s, 0, 0, | 109 0, 0, s, 0, 0, |
110 0, 0, 0, s, 0 }; | 110 0, 0, 0, s, 0 }; |
111 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); | 111 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); |
112 return SkColorFilterImageFilter::Create(filter, input); | 112 return SkColorFilterImageFilter::Create(filter, input); |
113 } | 113 } |
114 | 114 |
115 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkImageF
ilter::CropRect* cropRect = NULL) { | 115 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkImageF
ilter::CropRect* cropRect = NULL) { |
116 SkScalar matrix[20]; | 116 SkScalar matrix[20]; |
117 memset(matrix, 0, 20 * sizeof(SkScalar)); | 117 memset(matrix, 0, 20 * sizeof(SkScalar)); |
118 matrix[0] = matrix[5] = matrix[10] = 0.2126f; | 118 matrix[0] = matrix[5] = matrix[10] = 0.2126f; |
119 matrix[1] = matrix[6] = matrix[11] = 0.7152f; | 119 matrix[1] = matrix[6] = matrix[11] = 0.7152f; |
120 matrix[2] = matrix[7] = matrix[12] = 0.0722f; | 120 matrix[2] = matrix[7] = matrix[12] = 0.0722f; |
121 matrix[18] = 1.0f; | 121 matrix[18] = 1.0f; |
122 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); | 122 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); |
123 return SkColorFilterImageFilter::Create(filter, input, cropRect); | 123 return SkColorFilterImageFilter::Create(filter, input, cropRect); |
124 } | 124 } |
125 | 125 |
126 DEF_TEST(ImageFilter, reporter) { | 126 DEF_TEST(ImageFilter, reporter) { |
127 { | 127 { |
128 // Check that two non-clipping color matrices concatenate into a single
filter. | 128 // Check that two non-clipping color matrices concatenate into a single
filter. |
129 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f)); | 129 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f)); |
130 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh
tness)); | 130 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh
tness)); |
131 REPORTER_ASSERT(reporter, NULL == quarterBrightness->getInput(0)); | 131 REPORTER_ASSERT(reporter, NULL == quarterBrightness->getInput(0)); |
132 } | 132 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 #if SK_SUPPORT_GPU | 296 #if SK_SUPPORT_GPU |
297 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 297 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |
298 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 298 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
299 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 299 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
300 SkImageInfo::MakeN32Pre
mul(100, 100), | 300 SkImageInfo::MakeN32Pre
mul(100, 100), |
301 0)); | 301 0)); |
302 test_crop_rects(device, reporter); | 302 test_crop_rects(device, reporter); |
303 } | 303 } |
304 #endif | 304 #endif |
OLD | NEW |