OLD | NEW |
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 TestImageGenerator::TestType test = testTypes[i]; | 319 TestImageGenerator::TestType test = testTypes[i]; |
320 SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r)); | 320 SkImageGenerator* gen = SkNEW_ARGS(TestImageGenerator, (test, r)); |
321 SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen)); | 321 SkAutoTUnref<SkImage> image(SkImage::NewFromGenerator(gen)); |
322 if (NULL == image.get()) { | 322 if (NULL == image.get()) { |
323 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed [" | 323 ERRORF(r, "SkImage::NewFromGenerator unexpecedly failed [" |
324 SK_SIZE_T_SPECIFIER "]", i); | 324 SK_SIZE_T_SPECIFIER "]", i); |
325 continue; | 325 continue; |
326 } | 326 } |
327 REPORTER_ASSERT(r, TestImageGenerator::Width() == image->width()); | 327 REPORTER_ASSERT(r, TestImageGenerator::Width() == image->width()); |
328 REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height()); | 328 REPORTER_ASSERT(r, TestImageGenerator::Height() == image->height()); |
| 329 REPORTER_ASSERT(r, image->isLazyGenerated()); |
329 | 330 |
330 SkBitmap bitmap; | 331 SkBitmap bitmap; |
331 bitmap.allocN32Pixels(TestImageGenerator::Width(), TestImageGenerator::H
eight()); | 332 bitmap.allocN32Pixels(TestImageGenerator::Width(), TestImageGenerator::H
eight()); |
332 SkCanvas canvas(bitmap); | 333 SkCanvas canvas(bitmap); |
333 const SkColor kDefaultColor = 0xffabcdef; | 334 const SkColor kDefaultColor = 0xffabcdef; |
334 canvas.clear(kDefaultColor); | 335 canvas.clear(kDefaultColor); |
335 canvas.drawImage(image, 0, 0, NULL); | 336 canvas.drawImage(image, 0, 0, NULL); |
336 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { | 337 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { |
337 REPORTER_ASSERT( | 338 REPORTER_ASSERT( |
338 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); | 339 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); |
339 } else { | 340 } else { |
340 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); | 341 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); |
341 } | 342 } |
342 } | 343 } |
343 } | 344 } |
OLD | NEW |