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

Side by Side Diff: tests/ImageTest.cpp

Issue 2083393002: Revert of Store mipmap levels in deferred texture image (Closed) Base URL: https://skia.googlesource.com/skia.git@pipe-mipmap-levels-to-creation
Patch Set: Created 4 years, 6 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 | « src/image/SkImage_Gpu.cpp ('k') | no next file » | 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 <vector> 10 #include <vector>
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5}, 887 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5},
888 {SkMatrix::I(), kMedium_SkFilterQuality, 4}}, 888 {SkMatrix::I(), kMedium_SkFilterQuality, 4}},
889 kMedium_SkFilterQuality, 16, true}, 889 kMedium_SkFilterQuality, 16, true},
890 }; 890 };
891 891
892 892
893 for (auto testCase : testCases) { 893 for (auto testCase : testCases) {
894 sk_sp<SkImage> image(testCase.fImageFactory()); 894 sk_sp<SkImage> image(testCase.fImageFactory());
895 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam s.data(), 895 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam s.data(),
896 static_cast<int>(testCa se.fParams.size()), 896 static_cast<int>(testCa se.fParams.size()),
897 nullptr, SkSourceGammaT reatment::kIgnore); 897 nullptr);
898
898 static const char *const kFS[] = { "fail", "succeed" }; 899 static const char *const kFS[] = { "fail", "succeed" };
899 if (SkToBool(size) != testCase.fExpectation) { 900 if (SkToBool(size) != testCase.fExpectation) {
900 ERRORF(reporter, "This image was expected to %s but did not.", 901 ERRORF(reporter, "This image was expected to %s but did not.",
901 kFS[testCase.fExpectation]); 902 kFS[testCase.fExpectation]);
902 } 903 }
903 if (size) { 904 if (size) {
904 void* buffer = sk_malloc_throw(size); 905 void* buffer = sk_malloc_throw(size);
905 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3); 906 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3);
906 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (), 907 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (),
907 static_cast<int>(testCase.fPa rams.size()), 908 static_cast<int>(testCase.fPa rams.size()),
908 misaligned, SkSourceGammaTrea tment::kIgnore)) { 909 misaligned)) {
909 ERRORF(reporter, "Should fail when buffer is misaligned."); 910 ERRORF(reporter, "Should fail when buffer is misaligned.");
910 } 911 }
911 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(), 912 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(),
912 static_cast<int>(testCase.fP arams.size()), 913 static_cast<int>(testCase.fP arams.size()),
913 buffer, SkSourceGammaTreatme nt::kIgnore)) { 914 buffer)) {
914 ERRORF(reporter, "deferred image size succeeded but creation fai led."); 915 ERRORF(reporter, "deferred image size succeeded but creation fai led.");
915 } else { 916 } else {
916 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { 917 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
917 sk_sp<SkImage> newImage( 918 sk_sp<SkImage> newImage(
918 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted)); 919 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted));
919 REPORTER_ASSERT(reporter, newImage != nullptr); 920 REPORTER_ASSERT(reporter, newImage != nullptr);
920 if (newImage) { 921 if (newImage) {
921 // Scale the image in software for comparison. 922 // Scale the image in software for comparison.
922 SkImageInfo scaled_info = SkImageInfo::MakeN32( 923 SkImageInfo scaled_info = SkImageInfo::MakeN32(
923 image->width() / testCase.fExpectedScaleFactor, 924 image->width() / testCase.fExpectedScaleFactor,
(...skipping 11 matching lines...) Expand all
935 otherContextInfo.grContext(), buffer, budgeted)); 936 otherContextInfo.grContext(), buffer, budgeted));
936 REPORTER_ASSERT(reporter, !newImage2); 937 REPORTER_ASSERT(reporter, !newImage2);
937 testContext->makeCurrent(); 938 testContext->makeCurrent();
938 } 939 }
939 } 940 }
940 sk_free(buffer); 941 sk_free(buffer);
941 } 942 }
942 } 943 }
943 } 944 }
944 #endif 945 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698