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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 59713010: Address some more valgrind issues (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkBicubicImageFilter.h" 10 #include "SkBicubicImageFilter.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 result.allocPixels(); 122 result.allocPixels();
123 123
124 { 124 {
125 // This tests for : 125 // This tests for :
126 // 1 ) location at (0,0,1) 126 // 1 ) location at (0,0,1)
127 SkPoint3 location(0, 0, SK_Scalar1); 127 SkPoint3 location(0, 0, SK_Scalar1);
128 // 2 ) location and target at same value 128 // 2 ) location and target at same value
129 SkPoint3 target(location.fX, location.fY, location.fZ); 129 SkPoint3 target(location.fX, location.fY, location.fZ);
130 // 3 ) large negative specular exponent value 130 // 3 ) large negative specular exponent value
131 SkScalar specularExponent = SkFloatToScalar(-1000); 131 SkScalar specularExponent = SkFloatToScalar(-1000);
132 132
robertphillips 2013/11/14 14:21:41 This addresses two problems like: 120 (112 direct
133 SkAutoTUnref<SkImageFilter> bmSrc(new SkBitmapSource(bitmap));
133 SkPaint paint; 134 SkPaint paint;
134 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecula r( 135 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecula r(
135 location, target, specularExponent, SkFloatToScalar(180) , 136 location, target, specularExponent, SkFloatToScalar(180) ,
136 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, 137 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1,
137 new SkBitmapSource(bitmap)))->unref(); 138 bmSrc))->unref();
138 SkCanvas canvas(result); 139 SkCanvas canvas(result);
139 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize), 140 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize),
140 SkIntToScalar(kBitmapSize)); 141 SkIntToScalar(kBitmapSize));
141 canvas.drawRect(r, paint); 142 canvas.drawRect(r, paint);
142 } 143 }
143 144
144 { 145 {
145 // This tests for scale bringing width to 0 146 // This tests for scale bringing width to 0
146 SkSize scale = SkSize::Make(SkFloatToScalar(-0.001f), SK_Scalar1 ); 147 SkSize scale = SkSize::Make(SkFloatToScalar(-0.001f), SK_Scalar1 );
148 SkAutoTUnref<SkImageFilter> bmSrc(new SkBitmapSource(bitmap));
147 SkAutoTUnref<SkBicubicImageFilter> bicubic( 149 SkAutoTUnref<SkBicubicImageFilter> bicubic(
148 SkBicubicImageFilter::CreateMitchell( 150 SkBicubicImageFilter::CreateMitchell(scale, bmSrc));
149 scale, new SkBitmapSource(bitmap)));
150 SkBitmapDevice device(bitmap); 151 SkBitmapDevice device(bitmap);
151 SkDeviceImageFilterProxy proxy(&device); 152 SkDeviceImageFilterProxy proxy(&device);
152 SkIPoint loc = SkIPoint::Make(0, 0); 153 SkIPoint loc = SkIPoint::Make(0, 0);
153 // An empty input should early return and return false 154 // An empty input should early return and return false
154 REPORTER_ASSERT(reporter, 155 REPORTER_ASSERT(reporter,
155 !bicubic->filterImage(&proxy, bitmap, SkMatrix::I(), &result , &loc)); 156 !bicubic->filterImage(&proxy, bitmap, SkMatrix::I(), &result , &loc));
156 } 157 }
157 } 158 }
158 } 159 }
159 }; 160 };
160 161
161 162
162 #include "TestClassDef.h" 163 #include "TestClassDef.h"
163 DEFINE_TESTCLASS("ImageFilterTest", ImageFilterTestClass, ImageFilterTest::Test) 164 DEFINE_TESTCLASS("ImageFilterTest", ImageFilterTestClass, ImageFilterTest::Test)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698