Home | History | Annotate | Download | only in tests

Lines Matching refs:Reporter

48 static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA,
53 REPORTER_ASSERT(reporter, widthA == b->width());
54 REPORTER_ASSERT(reporter, heightA == b->height());
57 //REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
66 REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY));
67 REPORTER_ASSERT(reporter, b->readPixels(pmapB, 0, 0));
71 REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
157 static void test_encode(skiatest::Reporter* reporter, SkImage* image) {
160 REPORTER_ASSERT(reporter, origEncoded);
161 REPORTER_ASSERT(reporter, origEncoded->size() > 0);
165 ERRORF(reporter, "failed to decode image!");
168 REPORTER_ASSERT(reporter, decoded);
169 assert_equal(reporter, image, nullptr, decoded.get());
174 REPORTER_ASSERT(reporter, decoded);
175 assert_equal(reporter, image, &ir, decoded.get());
178 DEF_TEST(ImageEncode, reporter) {
179 test_encode(reporter, create_image().get());
183 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) {
184 test_encode(reporter, create_gpu_image(ctxInfo.grContext()).get());
188 DEF_TEST(Image_MakeFromRasterBitmap, reporter) {
204 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
206 REPORTER_ASSERT(reporter, rec.fExpectSameAsMutable == sameMutable);
207 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == sameMutable);
213 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
215 REPORTER_ASSERT(reporter, rec.fExpectSameAsImmutable == sameImmutable);
216 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == sameImmutable);
250 DEF_TEST(Image_Encode_Serializer, reporter) {
258 REPORTER_ASSERT(reporter, serializer.didEncode());
259 REPORTER_ASSERT(reporter, encoded);
260 REPORTER_ASSERT(reporter, encoded->size() > 0);
261 REPORTER_ASSERT(reporter, encoded->equals(reference.get()));
265 DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
269 REPORTER_ASSERT(reporter, image);
275 REPORTER_ASSERT(reporter, picture);
276 REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);
284 REPORTER_ASSERT(reporter, !serializers[i]->didEncode());
286 REPORTER_ASSERT(reporter, serializers[i]->didEncode());
290 REPORTER_ASSERT(reporter, deserialized);
291 REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
295 DEF_TEST(Image_NewRasterCopy, reporter) {
316 REPORTER_ASSERT(reporter, red == pixels[0]);
317 REPORTER_ASSERT(reporter, green == pixels[1]);
318 REPORTER_ASSERT(reporter, blue == pixels[2]);
319 REPORTER_ASSERT(reporter, 0 == pixels[3]);
325 DEF_TEST(Image_RetainSnapshot, reporter) {
338 REPORTER_ASSERT(reporter, image1->readPixels(dstInfo, pixels, dstRowBytes, 0, 0));
340 REPORTER_ASSERT(reporter, pixels[i] == green);
350 REPORTER_ASSERT(reporter, image2->readPixels(dstInfo, pixels, dstRowBytes, 0, 0));
351 REPORTER_ASSERT(reporter, pixels[0] == green);
352 REPORTER_ASSERT(reporter, pixels[1] == green);
353 REPORTER_ASSERT(reporter, pixels[2] == green);
354 REPORTER_ASSERT(reporter, pixels[3] == red);
368 DEF_TEST(image_newfrombitmap, reporter) {
387 REPORTER_ASSERT(reporter, sharedID == rec[i].fExpectSharedID);
390 REPORTER_ASSERT(reporter, peekSuccess == rec[i].fExpectPeekSuccess);
393 REPORTER_ASSERT(reporter, lazy == rec[i].fExpectLazy);
410 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) {
422 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
429 REPORTER_ASSERT(reporter, cachedBitmap.getGenerationID() == uniqueID);
430 REPORTER_ASSERT(reporter, cachedBitmap.isImmutable());
431 REPORTER_ASSERT(reporter, cachedBitmap.getPixels());
442 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
461 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextInfo) {
495 ERRORF(reporter, "Error creating image.");
504 ERRORF(reporter, "makeTextureImage failed.");
510 ERRORF(reporter, "makeTextureImage returned non-texture image.");
515 ERRORF(reporter, "makeTextureImage made unnecessary texture copy.");
519 ERRORF(reporter, "makeTextureImage changed the image size.");
522 ERRORF(reporter, "makeTextureImage changed image alpha type.");
528 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contextInfo) {
542 REPORTER_ASSERT(reporter, image->makeNonTextureImage().get() == image.get());
549 ERRORF(reporter, "makeNonTextureImage failed for texture-backed image.");
551 REPORTER_ASSERT(reporter, !rasterImage->isTextureBacked());
552 assert_equal(reporter, image.get(), nullptr, rasterImage.get());
556 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, contextInfo) {
585 DEF_TEST(ImageEmpty, reporter) {
588 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeRasterCopy(pmap));
589 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeRasterData(info, nullptr, 0));
590 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeFromRaster(pmap, nullptr, nullptr));
591 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeFromGenerator(
595 DEF_TEST(ImageDataRef, reporter) {
600 REPORTER_ASSERT(reporter, data->unique());
602 REPORTER_ASSERT(reporter, !data->unique());
604 REPORTER_ASSERT(reporter, data->unique());
616 static void image_test_read_pixels(skiatest::Reporter* reporter, SkImage* image) {
618 ERRORF(reporter, "Failed to create image!");
631 REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, 0));
635 REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, -w, 0));
636 REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, -h));
637 REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, image->width(), 0));
638 REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, image->height()));
642 REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, 0, 0));
643 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected));
647 REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes,
649 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected));
653 REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, -1, -1));
654 REPORTER_ASSERT(reporter, pixels[3] == expected);
655 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h - 1, notExpected));
659 REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes,
661 REPORTER_ASSERT(reporter, pixels[0] == expected);
662 REPORTER_ASSERT(reporter, has_pixels(&pixels[1], w*h - 1, notExpected));
664 DEF_TEST(ImageReadPixels, reporter) {
666 image_test_read_pixels(reporter, image.get());
669 image_test_read_pixels(reporter, image.get());
673 image_test_read_pixels(reporter, image.get());
675 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
678 image_test_read_pixels(reporter, image.get());
681 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageReadPixels_Gpu, reporter, ctxInfo) {
682 image_test_read_pixels(reporter, create_gpu_image(ctxInfo.grContext()).get());
686 static void check_legacy_bitmap(skiatest::Reporter* reporter, const SkImage* image,
688 REPORTER_ASSERT(reporter, image->width() == bitmap.width());
689 REPORTER_ASSERT(reporter, image->height() == bitmap.height());
690 REPORTER_ASSERT(reporter, image->alphaType() == bitmap.alphaType());
693 REPORTER_ASSERT(reporter, bitmap.isImmutable());
697 REPORTER_ASSERT(reporter, bitmap.getPixels());
701 REPORTER_ASSERT(reporter, image->readPixels(info, &imageColor, sizeof(SkPMColor), 0, 0));
702 REPORTER_ASSERT(reporter, imageColor == *bitmap.getAddr32(0, 0));
705 static void test_legacy_bitmap(skiatest::Reporter* reporter, const SkImage* image, SkImage::LegacyBitmapMode mode) {
707 ERRORF(reporter, "Failed to create image.");
711 REPORTER_ASSERT(reporter, image->asLegacyBitmap(&bitmap, mode));
712 check_legacy_bitmap(reporter, image, bitmap, mode);
716 REPORTER_ASSERT(reporter, bitmap.extractSubset(&tmp, SkIRect::MakeWH(image->width() / 2,
719 REPORTER_ASSERT(reporter, subsetImage.get());
722 REPORTER_ASSERT(reporter, subsetImage->asLegacyBitmap(&subsetBitmap, mode));
723 check_legacy_bitmap(reporter, subsetImage.get(), subsetBitmap, mode);
725 DEF_TEST(ImageLegacyBitmap, reporter) {
732 test_legacy_bitmap(reporter, image.get(), mode);
735 test_legacy_bitmap(reporter, image.get(), mode);
739 test_legacy_bitmap(reporter, image.get(), mode);
741 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
744 test_legacy_bitmap(reporter, image.get(), mode);
748 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) {
755 test_legacy_bitmap(reporter, image.get(), mode);
760 static void test_peek(skiatest::Reporter* reporter, SkImage* image, bool expectPeekSuccess) {
762 ERRORF(reporter, "Failed to create image!");
767 REPORTER_ASSERT(reporter, expectPeekSuccess == success);
770 REPORTER_ASSERT(reporter, 20 == info.width());
771 REPORTER_ASSERT(reporter, 20 == info.height());
772 REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType());
773 REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() ||
775 REPORTER_ASSERT(reporter, info.minRowBytes() <= pm.rowBytes());
776 REPORTER_ASSERT(reporter, SkPreMultiplyColor(SK_ColorWHITE) == *pm.addr32(0, 0));
779 DEF_TEST(ImagePeek, reporter) {
781 test_peek(reporter, image.get(), true);
784 test_peek(reporter, image.get(), true);
788 test_peek(reporter, image.get(), true);
790 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
793 test_peek(reporter, image.get(), false);
796 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImagePeek_Gpu, reporter, ctxInfo) {
798 test_peek(reporter, image.get(), false);
810 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, ctxInfo) {
834 ERRORF(reporter, "backend mismatch %d %d\n",
837 REPORTER_ASSERT(reporter, readBackHandle == backendDesc.fTextureHandle);
839 REPORTER_ASSERT(reporter, SkToBool(readBackHandle));
842 ERRORF(reporter, "origin mismatch %d %d\n", readBackOrigin, backendDesc.fOrigin);
844 REPORTER_ASSERT(reporter, readBackOrigin == backendDesc.fOrigin);
847 REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
849 REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
854 static void check_images_same(skiatest::Reporter* reporter, const SkImage* a, const SkImage* b) {
856 ERRORF(reporter, "Images must have the same size");
860 ERRORF(reporter, "Images must have the same alpha type");
872 ERRORF(reporter, "Could not read image a's pixels");
876 ERRORF(reporter, "Could not read image b's pixels");
885 ERRORF(reporter, "Expected image pixels to be the same. At %d,%d 0x%08x != 0x%08x",
893 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) {
903 REPORTER_ASSERT(reporter, proxy);
953 ERRORF(reporter, "Failed to create image!");
962 ERRORF(reporter, "This image was expected to %s but did not.",
971 ERRORF(reporter, "Should fail when buffer is misaligned.");
976 ERRORF(reporter, "deferred image size succeeded but creation failed.");
981 REPORTER_ASSERT(reporter, newImage != nullptr);
992 check_images_same(reporter, scaledImage.get(), newImage.get());
998 REPORTER_ASSERT(reporter, !newImage2);
1122 DEF_TEST(image_roundtrip_encode, reporter) {
1134 REPORTER_ASSERT(reporter, equal(bm0, bm1));
1137 DEF_TEST(image_roundtrip_premul, reporter) {
1149 REPORTER_ASSERT(reporter, equal(bm0, bm2));