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

Side by Side Diff: tests/ImageTest.cpp

Issue 2034933003: Store mipmap levels in deferred texture image (Closed) Base URL: https://skia.googlesource.com/skia.git@pipe-mipmap-levels-to-creation
Patch Set: Using scaled size. 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); 897 nullptr, SkSourceGammaT reatment::kIgnore);
898
899 static const char *const kFS[] = { "fail", "succeed" }; 898 static const char *const kFS[] = { "fail", "succeed" };
900 if (SkToBool(size) != testCase.fExpectation) { 899 if (SkToBool(size) != testCase.fExpectation) {
901 ERRORF(reporter, "This image was expected to %s but did not.", 900 ERRORF(reporter, "This image was expected to %s but did not.",
902 kFS[testCase.fExpectation]); 901 kFS[testCase.fExpectation]);
903 } 902 }
904 if (size) { 903 if (size) {
905 void* buffer = sk_malloc_throw(size); 904 void* buffer = sk_malloc_throw(size);
906 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3); 905 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3);
907 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (), 906 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (),
908 static_cast<int>(testCase.fPa rams.size()), 907 static_cast<int>(testCase.fPa rams.size()),
909 misaligned)) { 908 misaligned, SkSourceGammaTrea tment::kIgnore)) {
910 ERRORF(reporter, "Should fail when buffer is misaligned."); 909 ERRORF(reporter, "Should fail when buffer is misaligned.");
911 } 910 }
912 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(), 911 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(),
913 static_cast<int>(testCase.fP arams.size()), 912 static_cast<int>(testCase.fP arams.size()),
914 buffer)) { 913 buffer, SkSourceGammaTreatme nt::kIgnore)) {
915 ERRORF(reporter, "deferred image size succeeded but creation fai led."); 914 ERRORF(reporter, "deferred image size succeeded but creation fai led.");
916 } else { 915 } else {
917 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { 916 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
918 sk_sp<SkImage> newImage( 917 sk_sp<SkImage> newImage(
919 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted)); 918 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted));
920 REPORTER_ASSERT(reporter, newImage != nullptr); 919 REPORTER_ASSERT(reporter, newImage != nullptr);
921 if (newImage) { 920 if (newImage) {
922 // Scale the image in software for comparison. 921 // Scale the image in software for comparison.
923 SkImageInfo scaled_info = SkImageInfo::MakeN32( 922 SkImageInfo scaled_info = SkImageInfo::MakeN32(
924 image->width() / testCase.fExpectedScaleFactor, 923 image->width() / testCase.fExpectedScaleFactor,
(...skipping 11 matching lines...) Expand all
936 otherContextInfo.grContext(), buffer, budgeted)); 935 otherContextInfo.grContext(), buffer, budgeted));
937 REPORTER_ASSERT(reporter, !newImage2); 936 REPORTER_ASSERT(reporter, !newImage2);
938 testContext->makeCurrent(); 937 testContext->makeCurrent();
939 } 938 }
940 } 939 }
941 sk_free(buffer); 940 sk_free(buffer);
942 } 941 }
943 } 942 }
944 } 943 }
945 #endif 944 #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