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

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: Storing the gamma treatment in the deferred texture image. 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
« src/image/SkImage_Gpu.cpp ('K') | « 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5}, 877 { create_image_large, {{SkMatrix::I(), kMedium_SkFilterQuality, 5},
878 {SkMatrix::I(), kMedium_SkFilterQuality, 4}}, 878 {SkMatrix::I(), kMedium_SkFilterQuality, 4}},
879 kMedium_SkFilterQuality, 16, true}, 879 kMedium_SkFilterQuality, 16, true},
880 }; 880 };
881 881
882 882
883 for (auto testCase : testCases) { 883 for (auto testCase : testCases) {
884 sk_sp<SkImage> image(testCase.fImageFactory()); 884 sk_sp<SkImage> image(testCase.fImageFactory());
885 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam s.data(), 885 size_t size = image->getDeferredTextureImageData(*proxy, testCase.fParam s.data(),
886 static_cast<int>(testCa se.fParams.size()), 886 static_cast<int>(testCa se.fParams.size()),
887 nullptr); 887 nullptr, SkSourceGammaT reatment::kIgnore);
888
889 static const char *const kFS[] = { "fail", "succeed" }; 888 static const char *const kFS[] = { "fail", "succeed" };
890 if (SkToBool(size) != testCase.fExpectation) { 889 if (SkToBool(size) != testCase.fExpectation) {
891 ERRORF(reporter, "This image was expected to %s but did not.", 890 ERRORF(reporter, "This image was expected to %s but did not.",
892 kFS[testCase.fExpectation]); 891 kFS[testCase.fExpectation]);
893 } 892 }
894 if (size) { 893 if (size) {
895 void* buffer = sk_malloc_throw(size); 894 void* buffer = sk_malloc_throw(size);
896 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3); 895 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3);
897 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (), 896 if (image->getDeferredTextureImageData(*proxy, testCase.fParams.data (),
898 static_cast<int>(testCase.fPa rams.size()), 897 static_cast<int>(testCase.fPa rams.size()),
899 misaligned)) { 898 misaligned, SkSourceGammaTrea tment::kIgnore)) {
900 ERRORF(reporter, "Should fail when buffer is misaligned."); 899 ERRORF(reporter, "Should fail when buffer is misaligned.");
901 } 900 }
902 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(), 901 if (!image->getDeferredTextureImageData(*proxy, testCase.fParams.dat a(),
903 static_cast<int>(testCase.fP arams.size()), 902 static_cast<int>(testCase.fP arams.size()),
904 buffer)) { 903 buffer, SkSourceGammaTreatme nt::kIgnore)) {
905 ERRORF(reporter, "deferred image size succeeded but creation fai led."); 904 ERRORF(reporter, "deferred image size succeeded but creation fai led.");
906 } else { 905 } else {
907 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { 906 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
908 sk_sp<SkImage> newImage( 907 sk_sp<SkImage> newImage(
909 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted)); 908 SkImage::MakeFromDeferredTextureImageData(context, buffe r, budgeted));
910 REPORTER_ASSERT(reporter, newImage != nullptr); 909 REPORTER_ASSERT(reporter, newImage != nullptr);
911 if (newImage) { 910 if (newImage) {
912 // Scale the image in software for comparison. 911 // Scale the image in software for comparison.
913 SkImageInfo scaled_info = SkImageInfo::MakeN32( 912 SkImageInfo scaled_info = SkImageInfo::MakeN32(
914 image->width() / testCase.fExpectedScaleFactor, 913 image->width() / testCase.fExpectedScaleFactor,
(...skipping 11 matching lines...) Expand all
926 otherContextInfo.grContext(), buffer, budgeted)); 925 otherContextInfo.grContext(), buffer, budgeted));
927 REPORTER_ASSERT(reporter, !newImage2); 926 REPORTER_ASSERT(reporter, !newImage2);
928 testContext->makeCurrent(); 927 testContext->makeCurrent();
929 } 928 }
930 } 929 }
931 sk_free(buffer); 930 sk_free(buffer);
932 } 931 }
933 } 932 }
934 } 933 }
935 #endif 934 #endif
OLDNEW
« src/image/SkImage_Gpu.cpp ('K') | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698