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

Side by Side Diff: tests/BlurTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/BlitRowTest.cpp ('k') | tests/CTest.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurDrawLooper.h" 10 #include "SkBlurDrawLooper.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 int* result, int resultCount) { 164 int* result, int resultCount) {
165 SkMask src, dst; 165 SkMask src, dst;
166 166
167 src.fBounds.set(0, 0, width, height); 167 src.fBounds.set(0, 0, width, height);
168 src.fFormat = SkMask::kA8_Format; 168 src.fFormat = SkMask::kA8_Format;
169 src.fRowBytes = src.fBounds.width(); 169 src.fRowBytes = src.fBounds.width();
170 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); 170 src.fImage = SkMask::AllocImage(src.computeTotalImageSize());
171 171
172 memset(src.fImage, 0xff, src.computeTotalImageSize()); 172 memset(src.fImage, 0xff, src.computeTotalImageSize());
173 173
174 dst.fImage = NULL; 174 dst.fImage = nullptr;
175 SkBlurMask::BlurGroundTruth(sigma, &dst, src, kNormal_SkBlurStyle); 175 SkBlurMask::BlurGroundTruth(sigma, &dst, src, kNormal_SkBlurStyle);
176 176
177 int midX = dst.fBounds.centerX(); 177 int midX = dst.fBounds.centerX();
178 int midY = dst.fBounds.centerY(); 178 int midY = dst.fBounds.centerY();
179 uint8_t* bytes = dst.getAddr8(midX, midY); 179 uint8_t* bytes = dst.getAddr8(midX, midY);
180 int i; 180 int i;
181 for (i = 0; i < dst.fBounds.width()-(midX-dst.fBounds.fLeft); ++i) { 181 for (i = 0; i < dst.fBounds.width()-(midX-dst.fBounds.fLeft); ++i) {
182 if (i < resultCount) { 182 if (i < resultCount) {
183 result[i] = bytes[i]; 183 result[i] = bytes[i];
184 } 184 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 275
276 #if SK_SUPPORT_GPU 276 #if SK_SUPPORT_GPU
277 #if 0 277 #if 0
278 // temporary disable; see below for explanation 278 // temporary disable; see below for explanation
279 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path, 279 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path,
280 SkScalar gaussianSigma, 280 SkScalar gaussianSigma,
281 int* result, int resultCount) { 281 int* result, int resultCount) {
282 282
283 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ; 283 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ;
284 if (NULL == grContext) { 284 if (nullptr == grContext) {
285 return false; 285 return false;
286 } 286 }
287 287
288 GrSurfaceDesc desc; 288 GrSurfaceDesc desc;
289 desc.fConfig = kSkia8888_GrPixelConfig; 289 desc.fConfig = kSkia8888_GrPixelConfig;
290 desc.fFlags = kRenderTarget_GrSurfaceFlag; 290 desc.fFlags = kRenderTarget_GrSurfaceFlag;
291 desc.fWidth = resultCount; 291 desc.fWidth = resultCount;
292 desc.fHeight = 30; 292 desc.fHeight = 30;
293 desc.fSampleCnt = 0; 293 desc.fSampleCnt = 0;
294 294
295 SkAutoTUnref<GrTexture> texture(grContext->createTexture(desc, false, NULL, 0)); 295 SkAutoTUnref<GrTexture> texture(grContext->createTexture(desc, false, nullpt r, 0));
296 SkAutoTUnref<SkGpuDevice> device(new SkGpuDevice (grContext, texture.get()) ); 296 SkAutoTUnref<SkGpuDevice> device(new SkGpuDevice (grContext, texture.get()) );
297 SkCanvas canvas(device.get()); 297 SkCanvas canvas(device.get());
298 298
299 blur_path(&canvas, path, gaussianSigma); 299 blur_path(&canvas, path, gaussianSigma);
300 readback(&canvas, result, resultCount); 300 readback(&canvas, result, resultCount);
301 return true; 301 return true;
302 } 302 }
303 #endif 303 #endif
304 #endif 304 #endif
305 305
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 const SkScalar dx = 10; 423 const SkScalar dx = 10;
424 const SkScalar dy = -5; 424 const SkScalar dy = -5;
425 const SkBlurQuality quality = blurMaskFilterFlags_as_quality(blurMaskFilterF lags); 425 const SkBlurQuality quality = blurMaskFilterFlags_as_quality(blurMaskFilterF lags);
426 uint32_t flags = blurMaskFilterFlags_to_blurDrawLooperFlags(blurMaskFilterFl ags); 426 uint32_t flags = blurMaskFilterFlags_to_blurDrawLooperFlags(blurMaskFilterFl ags);
427 427
428 SkAutoTUnref<SkDrawLooper> lp(SkBlurDrawLooper::Create(color, sigma, dx, dy, flags)); 428 SkAutoTUnref<SkDrawLooper> lp(SkBlurDrawLooper::Create(color, sigma, dx, dy, flags));
429 429
430 const bool expectSuccess = sigma > 0 && 430 const bool expectSuccess = sigma > 0 &&
431 0 == (flags & SkBlurDrawLooper::kIgnoreTransform_ BlurFlag); 431 0 == (flags & SkBlurDrawLooper::kIgnoreTransform_ BlurFlag);
432 432
433 if (NULL == lp.get()) { 433 if (nullptr == lp.get()) {
434 REPORTER_ASSERT(reporter, sigma <= 0); 434 REPORTER_ASSERT(reporter, sigma <= 0);
435 } else { 435 } else {
436 SkDrawLooper::BlurShadowRec rec; 436 SkDrawLooper::BlurShadowRec rec;
437 bool success = lp->asABlurShadow(&rec); 437 bool success = lp->asABlurShadow(&rec);
438 REPORTER_ASSERT(reporter, success == expectSuccess); 438 REPORTER_ASSERT(reporter, success == expectSuccess);
439 if (success) { 439 if (success) {
440 REPORTER_ASSERT(reporter, rec.fSigma == sigma); 440 REPORTER_ASSERT(reporter, rec.fSigma == sigma);
441 REPORTER_ASSERT(reporter, rec.fOffset.x() == dx); 441 REPORTER_ASSERT(reporter, rec.fOffset.x() == dx);
442 REPORTER_ASSERT(reporter, rec.fOffset.y() == dy); 442 REPORTER_ASSERT(reporter, rec.fOffset.y() == dy);
443 REPORTER_ASSERT(reporter, rec.fColor == color); 443 REPORTER_ASSERT(reporter, rec.fColor == color);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // Test asABlur for SkBlurMaskFilter 519 // Test asABlur for SkBlurMaskFilter
520 // 520 //
521 for (size_t i = 0; i < SK_ARRAY_COUNT(styles); ++i) { 521 for (size_t i = 0; i < SK_ARRAY_COUNT(styles); ++i) {
522 const SkBlurStyle style = (SkBlurStyle)styles[i]; 522 const SkBlurStyle style = (SkBlurStyle)styles[i];
523 for (size_t j = 0; j < SK_ARRAY_COUNT(sigmas); ++j) { 523 for (size_t j = 0; j < SK_ARRAY_COUNT(sigmas); ++j) {
524 const SkScalar sigma = sigmas[j]; 524 const SkScalar sigma = sigmas[j];
525 for (int flags = 0; flags <= SkBlurMaskFilter::kAll_BlurFlag; ++flag s) { 525 for (int flags = 0; flags <= SkBlurMaskFilter::kAll_BlurFlag; ++flag s) {
526 const SkBlurQuality quality = blurMaskFilterFlags_as_quality(fla gs); 526 const SkBlurQuality quality = blurMaskFilterFlags_as_quality(fla gs);
527 527
528 SkAutoTUnref<SkMaskFilter> mf(SkBlurMaskFilter::Create(style, si gma, flags)); 528 SkAutoTUnref<SkMaskFilter> mf(SkBlurMaskFilter::Create(style, si gma, flags));
529 if (NULL == mf.get()) { 529 if (nullptr == mf.get()) {
530 REPORTER_ASSERT(reporter, sigma <= 0); 530 REPORTER_ASSERT(reporter, sigma <= 0);
531 } else { 531 } else {
532 REPORTER_ASSERT(reporter, sigma > 0); 532 REPORTER_ASSERT(reporter, sigma > 0);
533 SkMaskFilter::BlurRec rec; 533 SkMaskFilter::BlurRec rec;
534 bool success = mf->asABlur(&rec); 534 bool success = mf->asABlur(&rec);
535 if (flags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag) { 535 if (flags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag) {
536 REPORTER_ASSERT(reporter, !success); 536 REPORTER_ASSERT(reporter, !success);
537 } else { 537 } else {
538 REPORTER_ASSERT(reporter, success); 538 REPORTER_ASSERT(reporter, success);
539 REPORTER_ASSERT(reporter, rec.fSigma == sigma); 539 REPORTER_ASSERT(reporter, rec.fSigma == sigma);
(...skipping 25 matching lines...) Expand all
565 } 565 }
566 } 566 }
567 567
568 //////////////////////////////////////////////////////////////////////////////// /////////// 568 //////////////////////////////////////////////////////////////////////////////// ///////////
569 569
570 DEF_GPUTEST(Blur, reporter, factory) { 570 DEF_GPUTEST(Blur, reporter, factory) {
571 test_blur_drawing(reporter); 571 test_blur_drawing(reporter);
572 test_sigma_range(reporter, factory); 572 test_sigma_range(reporter, factory);
573 test_asABlur(reporter); 573 test_asABlur(reporter);
574 } 574 }
OLDNEW
« no previous file with comments | « tests/BlitRowTest.cpp ('k') | tests/CTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698