OLD | NEW |
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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
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_RENDERING_CONTEXTS(SkImage_newTextureImage, reporter, contextInf
o) { |
408 GrContext* context = contextInfo.grContext(); | 408 GrContext* context = contextInfo.grContext(); |
409 sk_gpu_test::GLTestContext* glContext = contextInfo.glContext(); | 409 sk_gpu_test::TestContext* testContext = contextInfo.testContext(); |
410 | 410 |
411 GrContextFactory otherFactory; | 411 GrContextFactory otherFactory; |
412 ContextInfo otherContextInfo = | 412 GrContextFactory::ContextType otherContextType = |
413 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType); | 413 GrContextFactory::NativeContextTypeForBackend(testContext->backend()
); |
414 glContext->makeCurrent(); | 414 ContextInfo otherContextInfo = otherFactory.getContextInfo(otherContextType)
; |
| 415 testContext->makeCurrent(); |
415 | 416 |
416 std::function<sk_sp<SkImage>()> imageFactories[] = { | 417 std::function<sk_sp<SkImage>()> imageFactories[] = { |
417 create_image, | 418 create_image, |
418 create_codec_image, | 419 create_codec_image, |
419 create_data_image, | 420 create_data_image, |
420 // Create an image from a picture. | 421 // Create an image from a picture. |
421 create_picture_image, | 422 create_picture_image, |
422 // Create a texture image. | 423 // Create a texture image. |
423 [context] { return create_gpu_image(context); }, | 424 [context] { return create_gpu_image(context); }, |
424 // Create a texture image in a another GrContext. | 425 // Create a texture image in a another GrContext. |
425 [glContext, otherContextInfo] { | 426 [testContext, otherContextInfo] { |
426 otherContextInfo.glContext()->makeCurrent(); | 427 otherContextInfo.testContext()->makeCurrent(); |
427 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo
.grContext()); | 428 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo
.grContext()); |
428 glContext->makeCurrent(); | 429 testContext->makeCurrent(); |
429 return otherContextImage; | 430 return otherContextImage; |
430 } | 431 } |
431 }; | 432 }; |
432 | 433 |
433 for (auto factory : imageFactories) { | 434 for (auto factory : imageFactories) { |
434 sk_sp<SkImage> image(factory()); | 435 sk_sp<SkImage> image(factory()); |
435 if (!image) { | 436 if (!image) { |
436 ERRORF(reporter, "Error creating image."); | 437 ERRORF(reporter, "Error creating image."); |
437 continue; | 438 continue; |
438 } | 439 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 SkBudgeted::k
No)); | 818 SkBudgeted::k
No)); |
818 if (!texImage) { | 819 if (!texImage) { |
819 ERRORF(reporter, "NewTextureFromPixmap failed."); | 820 ERRORF(reporter, "NewTextureFromPixmap failed."); |
820 } else { | 821 } else { |
821 check_images_same(reporter, image.get(), texImage.get()); | 822 check_images_same(reporter, image.get(), texImage.get()); |
822 } | 823 } |
823 } | 824 } |
824 } | 825 } |
825 } | 826 } |
826 | 827 |
827 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) { | 828 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) { |
828 GrContext* context = ctxInfo.grContext(); | 829 GrContext* context = ctxInfo.grContext(); |
829 sk_gpu_test::GLTestContext* glContext = ctxInfo.glContext(); | 830 sk_gpu_test::TestContext* testContext = ctxInfo.testContext(); |
830 SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy()); | 831 SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy()); |
831 | 832 |
832 GrContextFactory otherFactory; | 833 GrContextFactory otherFactory; |
833 ContextInfo otherContextInfo = | 834 ContextInfo otherContextInfo = |
834 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType); | 835 otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType); |
835 | 836 |
836 glContext->makeCurrent(); | 837 testContext->makeCurrent(); |
837 REPORTER_ASSERT(reporter, proxy); | 838 REPORTER_ASSERT(reporter, proxy); |
838 struct { | 839 struct { |
839 std::function<sk_sp<SkImage> ()> fImageFactory; | 840 std::function<sk_sp<SkImage> ()> fImageFactory; |
840 bool fExpectation; | 841 bool fExpectation; |
841 } testCases[] = { | 842 } testCases[] = { |
842 { create_image, true }, | 843 { create_image, true }, |
843 { create_codec_image, true }, | 844 { create_codec_image, true }, |
844 { create_data_image, true }, | 845 { create_data_image, true }, |
845 { create_picture_image, false }, | 846 { create_picture_image, false }, |
846 { [context] { return create_gpu_image(context); }, false }, | 847 { [context] { return create_gpu_image(context); }, false }, |
847 // Create a texture image in a another GrContext. | 848 // Create a texture image in a another GrContext. |
848 { [glContext, otherContextInfo] { | 849 { [testContext, otherContextInfo] { |
849 otherContextInfo.glContext()->makeCurrent(); | 850 otherContextInfo.testContext()->makeCurrent(); |
850 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo
.grContext()); | 851 sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo
.grContext()); |
851 glContext->makeCurrent(); | 852 testContext->makeCurrent(); |
852 return otherContextImage; | 853 return otherContextImage; |
853 }, false }, | 854 }, false }, |
854 }; | 855 }; |
855 | 856 |
856 | 857 |
857 for (auto testCase : testCases) { | 858 for (auto testCase : testCases) { |
858 sk_sp<SkImage> image(testCase.fImageFactory()); | 859 sk_sp<SkImage> image(testCase.fImageFactory()); |
859 | 860 |
860 // This isn't currently used in the implementation, just set any old val
ues. | 861 // This isn't currently used in the implementation, just set any old val
ues. |
861 SkImage::DeferredTextureImageUsageParams params; | 862 SkImage::DeferredTextureImageUsageParams params; |
(...skipping 21 matching lines...) Expand all Loading... |
883 SkImage::MakeFromDeferredTextureImageData(context, buffe
r, budgeted)); | 884 SkImage::MakeFromDeferredTextureImageData(context, buffe
r, budgeted)); |
884 REPORTER_ASSERT(reporter, newImage != nullptr); | 885 REPORTER_ASSERT(reporter, newImage != nullptr); |
885 if (newImage) { | 886 if (newImage) { |
886 check_images_same(reporter, image.get(), newImage.get())
; | 887 check_images_same(reporter, image.get(), newImage.get())
; |
887 } | 888 } |
888 // The other context should not be able to create images fro
m texture data | 889 // The other context should not be able to create images fro
m texture data |
889 // created by the original context. | 890 // created by the original context. |
890 sk_sp<SkImage> newImage2(SkImage::MakeFromDeferredTextureIma
geData( | 891 sk_sp<SkImage> newImage2(SkImage::MakeFromDeferredTextureIma
geData( |
891 otherContextInfo.grContext(), buffer, budgeted)); | 892 otherContextInfo.grContext(), buffer, budgeted)); |
892 REPORTER_ASSERT(reporter, !newImage2); | 893 REPORTER_ASSERT(reporter, !newImage2); |
893 glContext->makeCurrent(); | 894 testContext->makeCurrent(); |
894 } | 895 } |
895 } | 896 } |
896 sk_free(buffer); | 897 sk_free(buffer); |
897 } | 898 } |
898 } | 899 } |
899 } | 900 } |
900 #endif | 901 #endif |
OLD | NEW |