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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 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/CachedDataTest.cpp ('k') | tests/CanvasTest.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 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCachingPixelRef.h" 9 #include "SkCachingPixelRef.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 kSkCaching_PixelRefType, 232 kSkCaching_PixelRefType,
233 kSkDiscardable_PixelRefType, 233 kSkDiscardable_PixelRefType,
234 kLast_PixelRefType = kSkDiscardable_PixelRefType 234 kLast_PixelRefType = kSkDiscardable_PixelRefType
235 }; 235 };
236 236
237 static void check_pixelref(TestImageGenerator::TestType type, 237 static void check_pixelref(TestImageGenerator::TestType type,
238 skiatest::Reporter* reporter, 238 skiatest::Reporter* reporter,
239 PixelRefType pixelRefType, 239 PixelRefType pixelRefType,
240 SkDiscardableMemory::Factory* factory) { 240 SkDiscardableMemory::Factory* factory) {
241 SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType)); 241 SkASSERT((pixelRefType >= 0) && (pixelRefType <= kLast_PixelRefType));
242 SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(TestImageGenerator, 242 SkAutoTDelete<SkImageGenerator> gen(new TestImageGenerator(type, reporter));
243 (type, reporter)));
244 REPORTER_ASSERT(reporter, gen.get() != NULL); 243 REPORTER_ASSERT(reporter, gen.get() != NULL);
245 SkBitmap lazy; 244 SkBitmap lazy;
246 bool success; 245 bool success;
247 if (kSkCaching_PixelRefType == pixelRefType) { 246 if (kSkCaching_PixelRefType == pixelRefType) {
248 // Ignore factory; use global cache. 247 // Ignore factory; use global cache.
249 success = SkCachingPixelRef::Install(gen.detach(), &lazy); 248 success = SkCachingPixelRef::Install(gen.detach(), &lazy);
250 } else { 249 } else {
251 success = SkInstallDiscardablePixelRef(gen.detach(), NULL, &lazy, factor y); 250 success = SkInstallDiscardablePixelRef(gen.detach(), NULL, &lazy, factor y);
252 } 251 }
253 REPORTER_ASSERT(reporter, success); 252 REPORTER_ASSERT(reporter, success);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 309
311 //////////////////////////////////////////////////////////////////////////////// 310 ////////////////////////////////////////////////////////////////////////////////
312 311
313 DEF_TEST(Image_NewFromGenerator, r) { 312 DEF_TEST(Image_NewFromGenerator, r) {
314 TestImageGenerator::TestType testTypes[] = { 313 TestImageGenerator::TestType testTypes[] = {
315 TestImageGenerator::kFailGetPixels_TestType, 314 TestImageGenerator::kFailGetPixels_TestType,
316 TestImageGenerator::kSucceedGetPixels_TestType, 315 TestImageGenerator::kSucceedGetPixels_TestType,
317 }; 316 };
318 for (size_t i = 0; i < SK_ARRAY_COUNT(testTypes); ++i) { 317 for (size_t i = 0; i < SK_ARRAY_COUNT(testTypes); ++i) {
319 TestImageGenerator::TestType test = testTypes[i]; 318 TestImageGenerator::TestType test = testTypes[i];
320 SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r)); 319 SkImageGenerator* gen = new TestImageGenerator(test, r);
321 SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen)); 320 SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen));
322 if (NULL == image.get()) { 321 if (NULL == image.get()) {
323 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed [" 322 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed ["
324 SK_SIZE_T_SPECIFIER "]", i); 323 SK_SIZE_T_SPECIFIER "]", i);
325 continue; 324 continue;
326 } 325 }
327 REPORTER_ASSERT(r, TestImageGenerator::Width() == image->width()); 326 REPORTER_ASSERT(r, TestImageGenerator::Width() == image->width());
328 REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height()); 327 REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height());
329 REPORTER_ASSERT(r, image->isLazyGenerated()); 328 REPORTER_ASSERT(r, image->isLazyGenerated());
330 329
331 SkBitmap bitmap; 330 SkBitmap bitmap;
332 bitmap.allocN32Pixels(TestImageGenerator::Width(), TestImageGenerator::H eight()); 331 bitmap.allocN32Pixels(TestImageGenerator::Width(), TestImageGenerator::H eight());
333 SkCanvas canvas(bitmap); 332 SkCanvas canvas(bitmap);
334 const SkColor kDefaultColor = 0xffabcdef; 333 const SkColor kDefaultColor = 0xffabcdef;
335 canvas.clear(kDefaultColor); 334 canvas.clear(kDefaultColor);
336 canvas.drawImage(image, 0, 0, NULL); 335 canvas.drawImage(image, 0, 0, NULL);
337 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 336 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
338 REPORTER_ASSERT( 337 REPORTER_ASSERT(
339 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); 338 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0));
340 } else { 339 } else {
341 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); 340 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0));
342 } 341 }
343 } 342 }
344 } 343 }
OLDNEW
« no previous file with comments | « tests/CachedDataTest.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698