Lines Matching defs:reporter

55 static void assert_equal(skiatest::Reporter* reporter, GrDirectContext* dContextA, SkImage* a,
60 REPORTER_ASSERT(reporter, widthA == b->width());
61 REPORTER_ASSERT(reporter, heightA == b->height());
64 //REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
73 REPORTER_ASSERT(reporter, a->readPixels(dContextA, pmapA, srcX, srcY));
74 REPORTER_ASSERT(reporter, b->readPixels(nullptr, pmapB, 0, 0));
78 REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes));
163 static void test_encode(skiatest::Reporter* reporter, GrDirectContext* dContext, SkImage* image) {
166 REPORTER_ASSERT(reporter, origEncoded);
167 REPORTER_ASSERT(reporter, origEncoded->size() > 0);
171 ERRORF(reporter, "failed to decode image!");
174 REPORTER_ASSERT(reporter, decoded);
175 assert_equal(reporter, dContext, image, nullptr, decoded.get());
180 REPORTER_ASSERT(reporter, decoded);
181 assert_equal(reporter, dContext, image, &ir, decoded.get());
184 DEF_TEST(ImageEncode, reporter) {
185 test_encode(reporter, nullptr, create_image().get());
188 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) {
190 test_encode(reporter, dContext, create_gpu_image(dContext).get());
193 DEF_TEST(Image_MakeFromRasterBitmap, reporter) {
209 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
211 REPORTER_ASSERT(reporter, rec.fExpectSameAsMutable == sameMutable);
212 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == sameMutable);
218 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
220 REPORTER_ASSERT(reporter, rec.fExpectSameAsImmutable == sameImmutable);
221 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == sameImmutable);
226 DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
230 REPORTER_ASSERT(reporter, image);
236 REPORTER_ASSERT(reporter, picture);
237 REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);
247 REPORTER_ASSERT(reporter, !was_called);
249 REPORTER_ASSERT(reporter, was_called);
250 REPORTER_ASSERT(reporter, data && data->size() > 0);
253 REPORTER_ASSERT(reporter, deserialized);
254 REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
260 DEF_TEST(Image_RetainSnapshot, reporter) {
273 REPORTER_ASSERT(reporter, image1->readPixels(nullptr, dstInfo, pixels, dstRowBytes, 0, 0));
275 REPORTER_ASSERT(reporter, pixels[i] == green);
285 REPORTER_ASSERT(reporter, image2->readPixels(nullptr, dstInfo, pixels, dstRowBytes, 0, 0));
286 REPORTER_ASSERT(reporter, pixels[0] == green);
287 REPORTER_ASSERT(reporter, pixels[1] == green);
288 REPORTER_ASSERT(reporter, pixels[2] == green);
289 REPORTER_ASSERT(reporter, pixels[3] == red);
303 DEF_TEST(image_newfrombitmap, reporter) {
322 REPORTER_ASSERT(reporter, sharedID == rec[i].fExpectSharedID);
325 REPORTER_ASSERT(reporter, peekSuccess == rec[i].fExpectPeekSuccess);
328 REPORTER_ASSERT(reporter, lazy == rec[i].fExpectLazy);
344 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_Gpu2Cpu, reporter, ctxInfo) {
355 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
362 REPORTER_ASSERT(reporter, cachedBitmap.isImmutable());
363 REPORTER_ASSERT(reporter, cachedBitmap.getPixels());
374 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
378 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextInfo) {
402 ERRORF(reporter, "Error creating image.");
409 REPORTER_ASSERT(reporter, (origProxy->mipmapped() == GrMipmapped::kYes) ==
419 ERRORF(reporter, "makeTextureImage failed.");
424 ERRORF(reporter, "makeTextureImage returned non-texture image.");
436 REPORTER_ASSERT(reporter, shouldBeMipped == texImage->hasMipmaps());
437 REPORTER_ASSERT(reporter,
444 ERRORF(reporter, "makeTextureImage made unnecessary texture copy.");
449 REPORTER_ASSERT(reporter, !texProxy->getUniqueKey().isValid());
450 REPORTER_ASSERT(reporter, texProxy->isBudgeted() == budgeted);
453 ERRORF(reporter, "makeTextureImage changed the image size.");
456 ERRORF(reporter, "makeTextureImage changed image alpha type.");
464 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contextInfo) {
477 REPORTER_ASSERT(reporter, image->makeNonTextureImage().get() == image.get());
484 ERRORF(reporter, "makeNonTextureImage failed for texture-backed image.");
486 REPORTER_ASSERT(reporter, !rasterImage->isTextureBacked());
487 assert_equal(reporter, dContext, image.get(), nullptr, rasterImage.get());
491 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter, ctxInfo) {
507 REPORTER_ASSERT(reporter, can == SkToBool(img),
513 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UnpremulTextureImage, reporter, ctxInfo) {
526 ERRORF(reporter, "Failed to make unpremul texture image.");
534 ERRORF(reporter, "Unpremul readback failed.");
540 ERRORF(reporter, "unpremul(0x%08x)->unpremul(0x%08x) at %d, %d.",
551 ERRORF(reporter, "Unpremul readback failed.");
573 ERRORF(reporter, "unpremul(0x%08x)->premul(0x%08x) expected(0x%08x) at %d, %d.",
581 DEF_GPUTEST(AbandonedContextImage, reporter, options) {
603 REPORTER_ASSERT(reporter, img->isValid(factory->get(type)));
604 REPORTER_ASSERT(reporter, img->isValid(rsurf->getCanvas()->recordingContext()));
607 REPORTER_ASSERT(reporter, !img->isValid(factory->get(type)));
608 REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->recordingContext()));
614 REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->recordingContext()));
625 DEF_TEST(ImageEmpty, reporter) {
628 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeRasterCopy(pmap));
629 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeRasterData(info, nullptr, 0));
630 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeFromRaster(pmap, nullptr, nullptr));
631 REPORTER_ASSERT(reporter, nullptr == SkImage::MakeFromGenerator(
635 DEF_TEST(ImageDataRef, reporter) {
640 REPORTER_ASSERT(reporter, data->unique());
642 REPORTER_ASSERT(reporter, !data->unique());
644 REPORTER_ASSERT(reporter, data->unique());
656 static void image_test_read_pixels(GrDirectContext* dContext, skiatest::Reporter* reporter,
659 ERRORF(reporter, "Failed to create image!");
672 REPORTER_ASSERT(reporter, !image->readPixels(dContext, info, pixels, rowBytes, 0, 0));
676 REPORTER_ASSERT(reporter, !image->readPixels(dContext, info, pixels, rowBytes, -w, 0));
677 REPORTER_ASSERT(reporter, !image->readPixels(dContext, info, pixels, rowBytes, 0, -h));
678 REPORTER_ASSERT(reporter, !image->readPixels(dContext, info, pixels, rowBytes,
680 REPORTER_ASSERT(reporter, !image->readPixels(dContext, info, pixels, rowBytes,
685 REPORTER_ASSERT(reporter, image->readPixels(dContext, info, pixels, rowBytes, 0, 0));
686 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected));
690 REPORTER_ASSERT(reporter, image->readPixels(dContext, info, pixels, rowBytes,
692 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected));
696 REPORTER_ASSERT(reporter, image->readPixels(dContext, info, pixels, rowBytes, -1, -1));
697 REPORTER_ASSERT(reporter, pixels[3] == expected);
698 REPORTER_ASSERT(reporter, has_pixels(pixels, w*h - 1, notExpected));
702 REPORTER_ASSERT(reporter, image->readPixels(dContext, info, pixels, rowBytes,
704 REPORTER_ASSERT(reporter, pixels[0] == expected);
705 REPORTER_ASSERT(reporter, has_pixels(&pixels[1], w*h - 1, notExpected));
707 DEF_TEST(ImageReadPixels, reporter) {
709 image_test_read_pixels(nullptr, reporter, image.get());
712 image_test_read_pixels(nullptr, reporter, image.get());
716 image_test_read_pixels(nullptr, reporter, image.get());
718 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
721 image_test_read_pixels(nullptr, reporter, image.get());
723 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageReadPixels_Gpu, reporter, ctxInfo) {
725 image_test_read_pixels(dContext, reporter, create_gpu_image(dContext).get());
728 static void check_legacy_bitmap(skiatest::Reporter* reporter, GrDirectContext* dContext,
730 REPORTER_ASSERT(reporter, image->width() == bitmap.width());
731 REPORTER_ASSERT(reporter, image->height() == bitmap.height());
732 REPORTER_ASSERT(reporter, image->alphaType() == bitmap.alphaType());
734 REPORTER_ASSERT(reporter, bitmap.isImmutable());
736 REPORTER_ASSERT(reporter, bitmap.getPixels());
740 REPORTER_ASSERT(reporter, image->readPixels(dContext, info, &imageColor, sizeof(SkPMColor),
742 REPORTER_ASSERT(reporter, imageColor == *bitmap.getAddr32(0, 0));
745 static void test_legacy_bitmap(skiatest::Reporter* reporter, GrDirectContext* dContext,
748 ERRORF(reporter, "Failed to create image.");
752 REPORTER_ASSERT(reporter, image->asLegacyBitmap(&bitmap));
753 check_legacy_bitmap(reporter, dContext, image, bitmap);
757 REPORTER_ASSERT(reporter, bitmap.extractSubset(&tmp, SkIRect::MakeWH(image->width() / 2,
760 REPORTER_ASSERT(reporter, subsetImage.get());
763 REPORTER_ASSERT(reporter, subsetImage->asLegacyBitmap(&subsetBitmap));
764 check_legacy_bitmap(reporter, nullptr, subsetImage.get(), subsetBitmap);
766 DEF_TEST(ImageLegacyBitmap, reporter) {
768 test_legacy_bitmap(reporter, nullptr, image.get());
771 test_legacy_bitmap(reporter, nullptr, image.get());
775 test_legacy_bitmap(reporter, nullptr, image.get());
777 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
780 test_legacy_bitmap(reporter, nullptr, image.get());
782 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) {
785 test_legacy_bitmap(reporter, dContext, image.get());
788 static void test_peek(skiatest::Reporter* reporter, SkImage* image, bool expectPeekSuccess) {
790 ERRORF(reporter, "Failed to create image!");
795 REPORTER_ASSERT(reporter, expectPeekSuccess == success);
798 REPORTER_ASSERT(reporter, 20 == info.width());
799 REPORTER_ASSERT(reporter, 20 == info.height());
800 REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType());
801 REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() ||
803 REPORTER_ASSERT(reporter, info.minRowBytes() <= pm.rowBytes());
804 REPORTER_ASSERT(reporter, SkPreMultiplyColor(SK_ColorWHITE) == *pm.addr32(0, 0));
807 DEF_TEST(ImagePeek, reporter) {
809 test_peek(reporter, image.get(), true);
812 test_peek(reporter, image.get(), true);
816 test_peek(reporter, image.get(), true);
818 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
821 test_peek(reporter, image.get(), false);
823 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImagePeek_Gpu, reporter, ctxInfo) {
825 test_peek(reporter, image.get(), false);
836 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, ctxInfo) {
850 ERRORF(reporter, "couldn't create backend texture\n");
869 ERRORF(reporter, "backend mismatch\n");
871 REPORTER_ASSERT(reporter,
874 ERRORF(reporter, "origin mismatch %d %d\n", readBackOrigin, texOrigin);
876 REPORTER_ASSERT(reporter, readBackOrigin == texOrigin);
879 REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
881 REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
884 static void test_cross_context_image(skiatest::Reporter* reporter, const GrContextOptions& options,
920 ERRORF(reporter, "SkSurface::MakeRenderTarget failed for %s.", testName);
1002 REPORTER_ASSERT(reporter, view);
1007 REPORTER_ASSERT(reporter, !otherView);
1013 REPORTER_ASSERT(reporter, viewSecondRef);
1022 REPORTER_ASSERT(reporter, !otherView);
1031 REPORTER_ASSERT(reporter, otherView);
1040 DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, options) {
1044 ERRORF(reporter, "missing resource");
1047 test_cross_context_image(reporter, options, "SkImage_MakeCrossContextFromPixmapRelease",
1053 DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) {
1069 REPORTER_ASSERT(reporter, image);
1072 REPORTER_ASSERT(reporter, view);
1073 REPORTER_ASSERT(reporter, GrColorTypeToSkColorType(viewCT) == ct);
1077 REPORTER_ASSERT(reporter, expectAlpha == GrColorTypeIsAlphaOnly(grCT));
1082 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
1091 REPORTER_ASSERT(reporter, proxy);
1120 ERRORF(reporter, "Failed to create image!");
1135 ERRORF(reporter, "This image was expected to %s but did not.",
1146 ERRORF(reporter, "This backend texture was %s to be taken directly.",
1154 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageBackendAccessAbandoned_Gpu, reporter, ctxInfo) {
1162 REPORTER_ASSERT(reporter, beTex.isValid());
1168 REPORTER_ASSERT(reporter, !beTex.isValid());
1280 DEF_TEST(image_roundtrip_encode, reporter) {
1292 REPORTER_ASSERT(reporter, equal(bm0, bm1));
1295 DEF_TEST(image_roundtrip_premul, reporter) {
1307 REPORTER_ASSERT(reporter, equal(bm0, bm2));
1312 static void check_scaled_pixels(skiatest::Reporter* reporter, SkPixmap* pmap, uint32_t expected) {
1318 ERRORF(reporter, "Expected scaled pixels to be the same. At %d,%d 0x%08x != 0x%08x",
1326 static void test_scale_pixels(skiatest::Reporter* reporter, const SkImage* image,
1335 ERRORF(reporter, "Failed to scale image");
1339 check_scaled_pixels(reporter, &scaled, expected);
1343 DEF_TEST(ImageScalePixels, reporter) {
1352 test_scale_pixels(reporter, rasterImage.get(), pmRed);
1357 test_scale_pixels(reporter, codecImage.get(), pmRed);
1360 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageScalePixels_Gpu, reporter, ctxInfo) {
1369 test_scale_pixels(reporter, gpuImage.get(), pmRed);
1376 DEF_TEST(Image_nonfinite_dst, reporter) {
1393 REPORTER_ASSERT(reporter, *(SkPMColor*)addr == 0);
1412 DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
1441 REPORTER_ASSERT(reporter, numSubmits() == 3);
1446 REPORTER_ASSERT(reporter, numSubmits() == 1);
1449 REPORTER_ASSERT(reporter, numSubmits() == 1);
1452 REPORTER_ASSERT(reporter, numSubmits() == 1);
1458 REPORTER_ASSERT(reporter, numSubmits() == 1);
1461 REPORTER_ASSERT(reporter, numSubmits() == 1);
1464 REPORTER_ASSERT(reporter, numSubmits() == 1);
1470 REPORTER_ASSERT(reporter, numSubmits() == 1);
1473 REPORTER_ASSERT(reporter, numSubmits() == 1);
1476 REPORTER_ASSERT(reporter, numSubmits() == 1);
1477 REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
1481 REPORTER_ASSERT(reporter, numSubmits() == 1);
1484 REPORTER_ASSERT(reporter, numSubmits() == 1);
1487 REPORTER_ASSERT(reporter, numSubmits() == 1);
1504 DEF_TEST(image_cubicresampler, reporter) {
1505 auto diff = [reporter](const SkM44& a, const SkM44& b) {
1510 REPORTER_ASSERT(reporter, d <= tolerance);
1520 DEF_TEST(image_subset_encode_skbug_7752, reporter) {
1527 REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img.get(), img2.get()));