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

Unified Diff: tests/ImageIsOpaqueTest.cpp

Issue 2196743002: Add SkColorSpace::Equals() API (Closed) Base URL: https://skia.googlesource.com/skia.git@cscleanup
Patch Set: Fix logic Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/ColorSpaceTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageIsOpaqueTest.cpp
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index 0660885a54529cdc2d7ed99993846794f9cd0761..4389a3d892669614e703bc27edaa5a7cd5436be9 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#include "Resources.h"
#include "Test.h"
#if SK_SUPPORT_GPU
@@ -17,13 +18,15 @@
#include "SkWriteBuffer.h"
static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) {
- // just need a safe amount of storage, but ensure that it is 4-byte aligned.
- int32_t storage[(sizeof(SkImageInfo)*2) / sizeof(int32_t)];
- SkBinaryWriteBuffer wb(storage, sizeof(storage));
+ // Need a safe amount of 4-byte aligned storage. Note that one of the test ICC profiles
+ // is ~7500 bytes.
+ const size_t storageBytes = 8000;
+ SkAutoTMalloc<uint32_t> storage(storageBytes / sizeof(uint32_t));
+ SkBinaryWriteBuffer wb(storage.get(), storageBytes);
info.flatten(wb);
- SkASSERT(wb.bytesWritten() < sizeof(storage));
+ SkASSERT(wb.bytesWritten() < storageBytes);
- SkReadBuffer rb(storage, wb.bytesWritten());
+ SkReadBuffer rb(storage.get(), wb.bytesWritten());
// pick a noisy byte pattern, so we ensure that unflatten sets all of our fields
SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlphaType) 0xB8);
@@ -35,10 +38,24 @@ static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info)
}
DEF_TEST(ImageInfo_flattening, reporter) {
+ sk_sp<SkData> data =
+ SkData::MakeFromFileName(GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str());
+ sk_sp<SkColorSpace> space0 = SkColorSpace::NewICC(data->data(), data->size());
+ data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str());
+ sk_sp<SkColorSpace> space1 = SkColorSpace::NewICC(data->data(), data->size());
+ data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str());
+ sk_sp<SkColorSpace> space2 = SkColorSpace::NewICC(data->data(), data->size());
+ data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str());
+ sk_sp<SkColorSpace> space3 = SkColorSpace::NewICC(data->data(), data->size());
+
sk_sp<SkColorSpace> spaces[] = {
nullptr,
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named),
SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named),
+ space0,
+ space1,
+ space2,
+ space3,
};
for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) {
« no previous file with comments | « tests/ColorSpaceTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698