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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 453723003: Revert of SkImage::NewFromGenerator(SkImageGenerator*), and a unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | « src/image/SkImage_Raster.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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCachingPixelRef.h" 9 #include "SkCachingPixelRef.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); 316 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
317 // Only acts differently from NULL on a platform that has a 317 // Only acts differently from NULL on a platform that has a
318 // default discardable memory implementation that differs from the 318 // default discardable memory implementation that differs from the
319 // global DM pool. 319 // global DM pool.
320 check_pixelref(TestImageGenerator::kFailGetPixels_TestType, 320 check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
321 reporter, kSkDiscardable_PixelRefType, globalPool); 321 reporter, kSkDiscardable_PixelRefType, globalPool);
322 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, 322 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
323 reporter, kSkDiscardable_PixelRefType, globalPool); 323 reporter, kSkDiscardable_PixelRefType, globalPool);
324 } 324 }
325
326 ////////////////////////////////////////////////////////////////////////////////
327
328 DEF_TEST(Image_NewFromGenerator, r) {
329 TestImageGenerator::TestType testTypes[] = {
330 TestImageGenerator::kFailGetInfo_TestType,
331 TestImageGenerator::kFailGetPixels_TestType,
332 TestImageGenerator::kSucceedGetPixels_TestType,
333 };
334 for (size_t i = 0; i < SK_ARRAY_COUNT(testTypes); ++i) {
335 TestImageGenerator::TestType test = testTypes[i];
336 SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r));
337 SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen));
338 if (TestImageGenerator::kFailGetInfo_TestType == test) {
339 REPORTER_ASSERT(r, NULL == image.get());
340 continue;
341 }
342 if (NULL == image.get()) {
343 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed ["
344 SK_SIZE_T_SPECIFIER "]", i);
345 continue;
346 }
347 REPORTER_ASSERT(r, TestImageGenerator::Width() == image->width());
348 REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height());
349
350 SkBitmap bitmap;
351 SkAssertResult(bitmap.allocN32Pixels(TestImageGenerator::Width(),
352 TestImageGenerator::Height()));
353 SkCanvas canvas(bitmap);
354 canvas.clear(SK_ColorMAGENTA);
355 image->draw(&canvas, 0, 0, NULL);
356 SkColor color = bitmap.getColor(0, 0);
357 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
358 REPORTER_ASSERT(r, TestImageGenerator::Color() == color);
359 } else {
360 REPORTER_ASSERT(r, SK_ColorMAGENTA == color);
361 }
362 }
363 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698