| 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 <vector> | 10 #include <vector> |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5}, | 910 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5}, |
| 911 {SkMatrix::I(), kMedium_SkFilterQuality, 4}}, | 911 {SkMatrix::I(), kMedium_SkFilterQuality, 4}}, |
| 912 kMedium_SkFilterQuality, 16, true}, | 912 kMedium_SkFilterQuality, 16, true}, |
| 913 }; | 913 }; |
| 914 | 914 |
| 915 | 915 |
| 916 for (auto testCase : testCases) { | 916 for (auto testCase : testCases) { |
| 917 sk_sp<SkImage> image(testCase.fImageFactory()); | 917 sk_sp<SkImage> image(testCase.fImageFactory()); |
| 918 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam
s.data(), | 918 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam
s.data(), |
| 919 static_cast<int>(testCa
se.fParams.size()), | 919 static_cast<int>(testCa
se.fParams.size()), |
| 920 nullptr); | 920 nullptr, SkSourceGammaT
reatment::kIgnore); |
| 921 | |
| 922 static const char *const kFS[] = { "fail", "succeed" }; | 921 static const char *const kFS[] = { "fail", "succeed" }; |
| 923 if (SkToBool(size) != testCase.fExpectation) { | 922 if (SkToBool(size) != testCase.fExpectation) { |
| 924 ERRORF(reporter, "This image was expected to %s but did not.", | 923 ERRORF(reporter, "This image was expected to %s but did not.", |
| 925 kFS[testCase.fExpectation]); | 924 kFS[testCase.fExpectation]); |
| 926 } | 925 } |
| 927 if (size) { | 926 if (size) { |
| 928 void* buffer = sk_malloc_throw(size); | 927 void* buffer = sk_malloc_throw(size); |
| 929 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t
>(buffer) + 3); | 928 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t
>(buffer) + 3); |
| 930 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data
(), | 929 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data
(), |
| 931 static_cast<int>(testCase.fPa
rams.size()), | 930 static_cast<int>(testCase.fPa
rams.size()), |
| 932 misaligned)) { | 931 misaligned, SkSourceGammaTrea
tment::kIgnore)) { |
| 933 ERRORF(reporter, "Should fail when buffer is misaligned."); | 932 ERRORF(reporter, "Should fail when buffer is misaligned."); |
| 934 } | 933 } |
| 935 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat
a(), | 934 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat
a(), |
| 936 static_cast<int>(testCase.fP
arams.size()), | 935 static_cast<int>(testCase.fP
arams.size()), |
| 937 buffer)) { | 936 buffer, SkSourceGammaTreatme
nt::kIgnore)) { |
| 938 ERRORF(reporter, "deferred image size succeeded but creation fai
led."); | 937 ERRORF(reporter, "deferred image size succeeded but creation fai
led."); |
| 939 } else { | 938 } else { |
| 940 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { | 939 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { |
| 941 sk_sp<SkImage> newImage( | 940 sk_sp<SkImage> newImage( |
| 942 SkImage::MakeFromDeferredTextureImageData(context, buffe
r, budgeted)); | 941 SkImage::MakeFromDeferredTextureImageData(context, buffe
r, budgeted)); |
| 943 REPORTER_ASSERT(reporter, newImage != nullptr); | 942 REPORTER_ASSERT(reporter, newImage != nullptr); |
| 944 if (newImage) { | 943 if (newImage) { |
| 945 // Scale the image in software for comparison. | 944 // Scale the image in software for comparison. |
| 946 SkImageInfo scaled_info = SkImageInfo::MakeN32( | 945 SkImageInfo scaled_info = SkImageInfo::MakeN32( |
| 947 image->width() / testCase.fExpectedScaleFactor, | 946 image->width() / testCase.fExpectedScaleFactor, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 959 otherContextInfo.grContext(), buffer, budgeted)); | 958 otherContextInfo.grContext(), buffer, budgeted)); |
| 960 REPORTER_ASSERT(reporter, !newImage2); | 959 REPORTER_ASSERT(reporter, !newImage2); |
| 961 testContext->makeCurrent(); | 960 testContext->makeCurrent(); |
| 962 } | 961 } |
| 963 } | 962 } |
| 964 sk_free(buffer); | 963 sk_free(buffer); |
| 965 } | 964 } |
| 966 } | 965 } |
| 967 } | 966 } |
| 968 #endif | 967 #endif |
| OLD | NEW |