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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 175293002: Factory methods for heap-allocated SkColorFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
« no previous file with comments | « tests/GLProgramsTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « tests/GLProgramsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698