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

Side by Side Diff: tests/ImageTest.cpp

Issue 1966013002: Turn ContextInfos returned by GrContextFactory into structs. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Address comment Created 4 years, 7 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/ImageNewShaderTest.cpp ('k') | tests/PremulAlphaRoundTripTest.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 2015 Google Inc. 2 * Copyright 2015 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 <functional> 8 #include <functional>
9 #include <initializer_list> 9 #include <initializer_list>
10 #include "DMGpuSupport.h" 10 #include "DMGpuSupport.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 REPORTER_ASSERT(reporter, decoded); 170 REPORTER_ASSERT(reporter, decoded);
171 assert_equal(reporter, image, &ir, decoded.get()); 171 assert_equal(reporter, image, &ir, decoded.get());
172 } 172 }
173 173
174 DEF_TEST(ImageEncode, reporter) { 174 DEF_TEST(ImageEncode, reporter) {
175 test_encode(reporter, create_image().get()); 175 test_encode(reporter, create_image().get());
176 } 176 }
177 177
178 #if SK_SUPPORT_GPU 178 #if SK_SUPPORT_GPU
179 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) { 179 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageEncode_Gpu, reporter, ctxInfo) {
180 test_encode(reporter, create_gpu_image(ctxInfo.fGrContext).get()); 180 test_encode(reporter, create_gpu_image(ctxInfo.grContext()).get());
181 } 181 }
182 #endif 182 #endif
183 183
184 namespace { 184 namespace {
185 185
186 const char* kSerializedData = "serialized"; 186 const char* kSerializedData = "serialized";
187 187
188 class MockSerializer : public SkPixelSerializer { 188 class MockSerializer : public SkPixelSerializer {
189 public: 189 public:
190 MockSerializer(SkData* (*func)()) : fFunc(func), fDidEncode(false) { } 190 MockSerializer(SkData* (*func)()) : fFunc(func), fDidEncode(false) { }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 /* 364 /*
365 * This tests the caching (and preemptive purge) of the raster equivalent of a gpu-image. 365 * This tests the caching (and preemptive purge) of the raster equivalent of a gpu-image.
366 * We cache it for performance when drawing into a raster surface. 366 * We cache it for performance when drawing into a raster surface.
367 * 367 *
368 * A cleaner test would know if each drawImage call triggered a read-back from the gpu, 368 * A cleaner test would know if each drawImage call triggered a read-back from the gpu,
369 * but we don't have that facility (at the moment) so we use a little internal knowledge 369 * but we don't have that facility (at the moment) so we use a little internal knowledge
370 * of *how* the raster version is cached, and look for that. 370 * of *how* the raster version is cached, and look for that.
371 */ 371 */
372 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) { 372 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) {
373 SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); 373 SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
374 sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); 374 sk_sp<SkImage> image(create_gpu_image(ctxInfo.grContext()));
375 const uint32_t uniqueID = image->uniqueID(); 375 const uint32_t uniqueID = image->uniqueID();
376 376
377 auto surface(SkSurface::MakeRaster(info)); 377 auto surface(SkSurface::MakeRaster(info));
378 378
379 // now we can test drawing a gpu-backed image into a cpu-backed surface 379 // now we can test drawing a gpu-backed image into a cpu-backed surface
380 380
381 { 381 {
382 SkBitmap cachedBitmap; 382 SkBitmap cachedBitmap;
383 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap)) ; 383 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap)) ;
384 } 384 }
(...skipping 13 matching lines...) Expand all
398 } 398 }
399 399
400 image.reset(nullptr); 400 image.reset(nullptr);
401 { 401 {
402 SkBitmap cachedBitmap; 402 SkBitmap cachedBitmap;
403 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap)) ; 403 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap)) ;
404 } 404 }
405 } 405 }
406 406
407 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_newTextureImage, reporter, context Info) { 407 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_newTextureImage, reporter, context Info) {
408 GrContext* context = contextInfo.fGrContext; 408 GrContext* context = contextInfo.grContext();
409 sk_gpu_test::GLTestContext* glContext = contextInfo.fGLContext; 409 sk_gpu_test::GLTestContext* glContext = contextInfo.glContext();
410 410
411 GrContextFactory otherFactory; 411 GrContextFactory otherFactory;
412 ContextInfo otherContextInfo = 412 ContextInfo otherContextInfo =
413 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType); 413 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType);
414 glContext->makeCurrent(); 414 glContext->makeCurrent();
415 415
416 std::function<sk_sp<SkImage>()> imageFactories[] = { 416 std::function<sk_sp<SkImage>()> imageFactories[] = {
417 create_image, 417 create_image,
418 create_codec_image, 418 create_codec_image,
419 create_data_image, 419 create_data_image,
420 // Create an image from a picture. 420 // Create an image from a picture.
421 create_picture_image, 421 create_picture_image,
422 // Create a texture image. 422 // Create a texture image.
423 [context] { return create_gpu_image(context); }, 423 [context] { return create_gpu_image(context); },
424 // Create a texture image in a another GrContext. 424 // Create a texture image in a another GrContext.
425 [glContext, otherContextInfo] { 425 [glContext, otherContextInfo] {
426 otherContextInfo.fGLContext->makeCurrent(); 426 otherContextInfo.glContext()->makeCurrent();
427 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo .fGrContext); 427 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo .grContext());
428 glContext->makeCurrent(); 428 glContext->makeCurrent();
429 return otherContextImage; 429 return otherContextImage;
430 } 430 }
431 }; 431 };
432 432
433 for (auto factory : imageFactories) { 433 for (auto factory : imageFactories) {
434 sk_sp<SkImage> image(factory()); 434 sk_sp<SkImage> image(factory());
435 if (!image) { 435 if (!image) {
436 ERRORF(reporter, "Error creating image."); 436 ERRORF(reporter, "Error creating image.");
437 continue; 437 continue;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 image = create_rasterproc_image(&dataHolder); 571 image = create_rasterproc_image(&dataHolder);
572 test_read_pixels(reporter, image.get()); 572 test_read_pixels(reporter, image.get());
573 image.reset(); 573 image.reset();
574 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount); 574 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
575 575
576 image = create_codec_image(); 576 image = create_codec_image();
577 test_read_pixels(reporter, image.get()); 577 test_read_pixels(reporter, image.get());
578 } 578 }
579 #if SK_SUPPORT_GPU 579 #if SK_SUPPORT_GPU
580 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageReadPixels_Gpu, reporter, ctxInfo) { 580 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageReadPixels_Gpu, reporter, ctxInfo) {
581 test_read_pixels(reporter, create_gpu_image(ctxInfo.fGrContext).get()); 581 test_read_pixels(reporter, create_gpu_image(ctxInfo.grContext()).get());
582 } 582 }
583 #endif 583 #endif
584 584
585 static void check_legacy_bitmap(skiatest::Reporter* reporter, const SkImage* ima ge, 585 static void check_legacy_bitmap(skiatest::Reporter* reporter, const SkImage* ima ge,
586 const SkBitmap& bitmap, SkImage::LegacyBitmapMod e mode) { 586 const SkBitmap& bitmap, SkImage::LegacyBitmapMod e mode) {
587 REPORTER_ASSERT(reporter, image->width() == bitmap.width()); 587 REPORTER_ASSERT(reporter, image->width() == bitmap.width());
588 REPORTER_ASSERT(reporter, image->height() == bitmap.height()); 588 REPORTER_ASSERT(reporter, image->height() == bitmap.height());
589 REPORTER_ASSERT(reporter, image->isOpaque() == bitmap.isOpaque()); 589 REPORTER_ASSERT(reporter, image->isOpaque() == bitmap.isOpaque());
590 590
591 if (SkImage::kRO_LegacyBitmapMode == mode) { 591 if (SkImage::kRO_LegacyBitmapMode == mode) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 test_legacy_bitmap(reporter, image.get(), mode); 639 test_legacy_bitmap(reporter, image.get(), mode);
640 } 640 }
641 } 641 }
642 #if SK_SUPPORT_GPU 642 #if SK_SUPPORT_GPU
643 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) { 643 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageLegacyBitmap_Gpu, reporter, ctxInfo) {
644 const SkImage::LegacyBitmapMode modes[] = { 644 const SkImage::LegacyBitmapMode modes[] = {
645 SkImage::kRO_LegacyBitmapMode, 645 SkImage::kRO_LegacyBitmapMode,
646 SkImage::kRW_LegacyBitmapMode, 646 SkImage::kRW_LegacyBitmapMode,
647 }; 647 };
648 for (auto& mode : modes) { 648 for (auto& mode : modes) {
649 sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); 649 sk_sp<SkImage> image(create_gpu_image(ctxInfo.grContext()));
650 test_legacy_bitmap(reporter, image.get(), mode); 650 test_legacy_bitmap(reporter, image.get(), mode);
651 } 651 }
652 } 652 }
653 #endif 653 #endif
654 654
655 static void test_peek(skiatest::Reporter* reporter, SkImage* image, bool expectP eekSuccess) { 655 static void test_peek(skiatest::Reporter* reporter, SkImage* image, bool expectP eekSuccess) {
656 SkPixmap pm; 656 SkPixmap pm;
657 bool success = image->peekPixels(&pm); 657 bool success = image->peekPixels(&pm);
658 REPORTER_ASSERT(reporter, expectPeekSuccess == success); 658 REPORTER_ASSERT(reporter, expectPeekSuccess == success);
659 if (success) { 659 if (success) {
(...skipping 18 matching lines...) Expand all
678 image = create_rasterproc_image(&dataHolder); 678 image = create_rasterproc_image(&dataHolder);
679 test_peek(reporter, image.get(), true); 679 test_peek(reporter, image.get(), true);
680 image.reset(); 680 image.reset();
681 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount); 681 REPORTER_ASSERT(reporter, 1 == dataHolder.fReleaseCount);
682 682
683 image = create_codec_image(); 683 image = create_codec_image();
684 test_peek(reporter, image.get(), false); 684 test_peek(reporter, image.get(), false);
685 } 685 }
686 #if SK_SUPPORT_GPU 686 #if SK_SUPPORT_GPU
687 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImagePeek_Gpu, reporter, ctxInfo) { 687 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImagePeek_Gpu, reporter, ctxInfo) {
688 sk_sp<SkImage> image(create_gpu_image(ctxInfo.fGrContext)); 688 sk_sp<SkImage> image(create_gpu_image(ctxInfo.grContext()));
689 test_peek(reporter, image.get(), false); 689 test_peek(reporter, image.get(), false);
690 } 690 }
691 #endif 691 #endif
692 692
693 #if SK_SUPPORT_GPU 693 #if SK_SUPPORT_GPU
694 struct TextureReleaseChecker { 694 struct TextureReleaseChecker {
695 TextureReleaseChecker() : fReleaseCount(0) {} 695 TextureReleaseChecker() : fReleaseCount(0) {}
696 int fReleaseCount; 696 int fReleaseCount;
697 static void Release(void* self) { 697 static void Release(void* self) {
698 static_cast<TextureReleaseChecker*>(self)->fReleaseCount++; 698 static_cast<TextureReleaseChecker*>(self)->fReleaseCount++;
699 } 699 }
700 }; 700 };
701 static void check_image_color(skiatest::Reporter* reporter, SkImage* image, SkPM Color expected) { 701 static void check_image_color(skiatest::Reporter* reporter, SkImage* image, SkPM Color expected) {
702 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); 702 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
703 SkPMColor pixel; 703 SkPMColor pixel;
704 REPORTER_ASSERT(reporter, image->readPixels(info, &pixel, sizeof(pixel), 0, 0)); 704 REPORTER_ASSERT(reporter, image->readPixels(info, &pixel, sizeof(pixel), 0, 0));
705 REPORTER_ASSERT(reporter, pixel == expected); 705 REPORTER_ASSERT(reporter, pixel == expected);
706 } 706 }
707 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTexture, reporter, ctxInfo) { 707 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTexture, reporter, ctxInfo) {
708 GrTextureProvider* provider = ctxInfo.fGrContext->textureProvider(); 708 GrTextureProvider* provider = ctxInfo.grContext()->textureProvider();
709 const int w = 10; 709 const int w = 10;
710 const int h = 10; 710 const int h = 10;
711 SkPMColor storage[w * h]; 711 SkPMColor storage[w * h];
712 const SkPMColor expected0 = SkPreMultiplyColor(SK_ColorRED); 712 const SkPMColor expected0 = SkPreMultiplyColor(SK_ColorRED);
713 sk_memset32(storage, expected0, w * h); 713 sk_memset32(storage, expected0, w * h);
714 GrSurfaceDesc desc; 714 GrSurfaceDesc desc;
715 desc.fFlags = kRenderTarget_GrSurfaceFlag; // needs to be a rendertarget fo r readpixels(); 715 desc.fFlags = kRenderTarget_GrSurfaceFlag; // needs to be a rendertarget fo r readpixels();
716 desc.fOrigin = kDefault_GrSurfaceOrigin; 716 desc.fOrigin = kDefault_GrSurfaceOrigin;
717 desc.fWidth = w; 717 desc.fWidth = w;
718 desc.fHeight = h; 718 desc.fHeight = h;
719 desc.fConfig = kSkia8888_GrPixelConfig; 719 desc.fConfig = kSkia8888_GrPixelConfig;
720 desc.fSampleCnt = 0; 720 desc.fSampleCnt = 0;
721 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, SkBudgeted::kNo, s torage, w * 4)); 721 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, SkBudgeted::kNo, s torage, w * 4));
722 if (!tex) { 722 if (!tex) {
723 REPORTER_ASSERT(reporter, false); 723 REPORTER_ASSERT(reporter, false);
724 return; 724 return;
725 } 725 }
726 726
727 GrBackendTextureDesc backendDesc; 727 GrBackendTextureDesc backendDesc;
728 backendDesc.fConfig = kSkia8888_GrPixelConfig; 728 backendDesc.fConfig = kSkia8888_GrPixelConfig;
729 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; 729 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
730 backendDesc.fWidth = w; 730 backendDesc.fWidth = w;
731 backendDesc.fHeight = h; 731 backendDesc.fHeight = h;
732 backendDesc.fSampleCnt = 0; 732 backendDesc.fSampleCnt = 0;
733 backendDesc.fTextureHandle = tex->getTextureHandle(); 733 backendDesc.fTextureHandle = tex->getTextureHandle();
734 TextureReleaseChecker releaseChecker; 734 TextureReleaseChecker releaseChecker;
735 sk_sp<SkImage> refImg( 735 sk_sp<SkImage> refImg(
736 SkImage::MakeFromTexture(ctxInfo.fGrContext, backendDesc, kPremul_SkAlph aType, 736 SkImage::MakeFromTexture(ctxInfo.grContext(), backendDesc, kPremul_SkAlp haType,
737 TextureReleaseChecker::Release, &releaseChecker )); 737 TextureReleaseChecker::Release, &releaseChecker ));
738 sk_sp<SkImage> cpyImg(SkImage::MakeFromTextureCopy(ctxInfo.fGrContext, backe ndDesc, 738 sk_sp<SkImage> cpyImg(SkImage::MakeFromTextureCopy(ctxInfo.grContext(), back endDesc,
739 kPremul_SkAlphaType)); 739 kPremul_SkAlphaType));
740 740
741 check_image_color(reporter, refImg.get(), expected0); 741 check_image_color(reporter, refImg.get(), expected0);
742 check_image_color(reporter, cpyImg.get(), expected0); 742 check_image_color(reporter, cpyImg.get(), expected0);
743 743
744 // Now lets jam new colors into our "external" texture, and see if the image s notice 744 // Now lets jam new colors into our "external" texture, and see if the image s notice
745 const SkPMColor expected1 = SkPreMultiplyColor(SK_ColorBLUE); 745 const SkPMColor expected1 = SkPreMultiplyColor(SK_ColorBLUE);
746 sk_memset32(storage, expected1, w * h); 746 sk_memset32(storage, expected1, w * h);
747 tex->writePixels(0, 0, w, h, kSkia8888_GrPixelConfig, storage, GrContext::kF lushWrites_PixelOp); 747 tex->writePixels(0, 0, w, h, kSkia8888_GrPixelConfig, storage, GrContext::kF lushWrites_PixelOp);
748 748
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 sk_sp<SkImage> image((*create)()); 806 sk_sp<SkImage> image((*create)());
807 if (!image) { 807 if (!image) {
808 ERRORF(reporter, "Could not create image"); 808 ERRORF(reporter, "Could not create image");
809 return; 809 return;
810 } 810 }
811 811
812 SkPixmap pixmap; 812 SkPixmap pixmap;
813 if (!image->peekPixels(&pixmap)) { 813 if (!image->peekPixels(&pixmap)) {
814 ERRORF(reporter, "peek failed"); 814 ERRORF(reporter, "peek failed");
815 } else { 815 } else {
816 sk_sp<SkImage> texImage(SkImage::MakeTextureFromPixmap(ctxInfo.fGrCo ntext, pixmap, 816 sk_sp<SkImage> texImage(SkImage::MakeTextureFromPixmap(ctxInfo.grCon text(), pixmap,
817 SkBudgeted::k No)); 817 SkBudgeted::k No));
818 if (!texImage) { 818 if (!texImage) {
819 ERRORF(reporter, "NewTextureFromPixmap failed."); 819 ERRORF(reporter, "NewTextureFromPixmap failed.");
820 } else { 820 } else {
821 check_images_same(reporter, image.get(), texImage.get()); 821 check_images_same(reporter, image.get(), texImage.get());
822 } 822 }
823 } 823 }
824 } 824 }
825 } 825 }
826 826
827 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) { 827 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) {
828 GrContext* context = ctxInfo.fGrContext; 828 GrContext* context = ctxInfo.grContext();
829 sk_gpu_test::GLTestContext* glContext = ctxInfo.fGLContext; 829 sk_gpu_test::GLTestContext* glContext = ctxInfo.glContext();
830 SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy()); 830 SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
831 831
832 GrContextFactory otherFactory; 832 GrContextFactory otherFactory;
833 ContextInfo otherContextInfo = 833 ContextInfo otherContextInfo =
834 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType); 834 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType);
835 835
836 glContext->makeCurrent(); 836 glContext->makeCurrent();
837 REPORTER_ASSERT(reporter, proxy); 837 REPORTER_ASSERT(reporter, proxy);
838 struct { 838 struct {
839 std::function<sk_sp<SkImage> ()> fImageFactory; 839 std::function<sk_sp<SkImage> ()> fImageFactory;
840 bool fExpectation; 840 bool fExpectation;
841 } testCases[] = { 841 } testCases[] = {
842 { create_image, true }, 842 { create_image, true },
843 { create_codec_image, true }, 843 { create_codec_image, true },
844 { create_data_image, true }, 844 { create_data_image, true },
845 { create_picture_image, false }, 845 { create_picture_image, false },
846 { [context] { return create_gpu_image(context); }, false }, 846 { [context] { return create_gpu_image(context); }, false },
847 // Create a texture image in a another GrContext. 847 // Create a texture image in a another GrContext.
848 { [glContext, otherContextInfo] { 848 { [glContext, otherContextInfo] {
849 otherContextInfo.fGLContext->makeCurrent(); 849 otherContextInfo.glContext()->makeCurrent();
850 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo .fGrContext); 850 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo .grContext());
851 glContext->makeCurrent(); 851 glContext->makeCurrent();
852 return otherContextImage; 852 return otherContextImage;
853 }, false }, 853 }, false },
854 }; 854 };
855 855
856 856
857 for (auto testCase : testCases) { 857 for (auto testCase : testCases) {
858 sk_sp<SkImage> image(testCase.fImageFactory()); 858 sk_sp<SkImage> image(testCase.fImageFactory());
859 859
860 // This isn't currently used in the implementation, just set any old val ues. 860 // This isn't currently used in the implementation, just set any old val ues.
(...skipping 20 matching lines...) Expand all
881 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { 881 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
882 sk_sp<SkImage> newImage( 882 sk_sp<SkImage> newImage(
883 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted)); 883 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted));
884 REPORTER_ASSERT(reporter, newImage != nullptr); 884 REPORTER_ASSERT(reporter, newImage != nullptr);
885 if (newImage) { 885 if (newImage) {
886 check_images_same(reporter, image.get(), newImage.get()) ; 886 check_images_same(reporter, image.get(), newImage.get()) ;
887 } 887 }
888 // The other context should not be able to create images fro m texture data 888 // The other context should not be able to create images fro m texture data
889 // created by the original context. 889 // created by the original context.
890 sk_sp<SkImage> newImage2(SkImage::MakeFromDeferredTextureIma geData( 890 sk_sp<SkImage> newImage2(SkImage::MakeFromDeferredTextureIma geData(
891 otherContextInfo.fGrContext, buffer, budgeted)); 891 otherContextInfo.grContext(), buffer, budgeted));
892 REPORTER_ASSERT(reporter, !newImage2); 892 REPORTER_ASSERT(reporter, !newImage2);
893 glContext->makeCurrent(); 893 glContext->makeCurrent();
894 } 894 }
895 } 895 }
896 sk_free(buffer); 896 sk_free(buffer);
897 } 897 }
898 } 898 }
899 } 899 }
900 #endif 900 #endif
OLDNEW
« no previous file with comments | « tests/ImageNewShaderTest.cpp ('k') | tests/PremulAlphaRoundTripTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698