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

Side by Side Diff: tests/ImageIsOpaqueTest.cpp

Issue 2000713003: Add SkColorSpace to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@public
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
« include/core/SkImageInfo.h ('K') | « src/core/SkMipMap.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 2014 Google Inc. 2 * Copyright 2014 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 "SkTypes.h" 8 #include "SkTypes.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
11 #if SK_SUPPORT_GPU 11 #if SK_SUPPORT_GPU
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #endif 13 #endif
14 #include "SkImage.h" 14 #include "SkImage.h"
15 #include "SkSurface.h" 15 #include "SkSurface.h"
16 #include "SkReadBuffer.h" 16 #include "SkReadBuffer.h"
17 #include "SkWriteBuffer.h" 17 #include "SkWriteBuffer.h"
18 18
19 static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) { 19 static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) {
20 // just need a safe amount of storage, but ensure that it is 4-byte aligned. 20 // just need a safe amount of storage, but ensure that it is 4-byte aligned.
21 int32_t storage[(sizeof(SkImageInfo)*2) / sizeof(int32_t)]; 21 int32_t storage[(sizeof(SkImageInfo)*2) / sizeof(int32_t)];
22 SkBinaryWriteBuffer wb(storage, sizeof(storage)); 22 SkBinaryWriteBuffer wb(storage, sizeof(storage));
23 info.flatten(wb); 23 info.flatten(wb);
24 SkASSERT(wb.bytesWritten() < sizeof(storage)); 24 SkASSERT(wb.bytesWritten() < sizeof(storage));
25 25
26 SkReadBuffer rb(storage, wb.bytesWritten()); 26 SkReadBuffer rb(storage, wb.bytesWritten());
27 SkImageInfo info2;
28 27
29 // pick a noisy byte pattern, so we ensure that unflatten sets all of our fi elds 28 // pick a noisy byte pattern, so we ensure that unflatten sets all of our fi elds
30 memset(&info2, 0xB8, sizeof(info2)); 29 SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlp haType) 0xB8,
30 (SkColorProfileType) 0xB8);
31 31
32 info2.unflatten(rb); 32 info2.unflatten(rb);
33 REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten()); 33 REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten());
34 REPORTER_ASSERT(reporter, info == info2); 34 REPORTER_ASSERT(reporter, info == info2);
35 } 35 }
36 36
37 DEF_TEST(ImageInfo_flattening, reporter) { 37 DEF_TEST(ImageInfo_flattening, reporter) {
38 for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) { 38 for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) {
39 for (int at = 0; at <= kLastEnum_SkAlphaType; ++at) { 39 for (int at = 0; at <= kLastEnum_SkAlphaType; ++at) {
40 for (int pt = 0; pt <= kLastEnum_SkColorProfileType; ++pt) { 40 for (int pt = 0; pt <= kLastEnum_SkColorProfileType; ++pt) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo , infoTransparent)); 72 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo , infoTransparent));
73 check_isopaque(reporter, surfaceTransparent, false); 73 check_isopaque(reporter, surfaceTransparent, false);
74 74
75 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); 75 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
76 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info Opaque)); 76 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info Opaque));
77 77
78 check_isopaque(reporter, surfaceOpaque, true); 78 check_isopaque(reporter, surfaceOpaque, true);
79 } 79 }
80 80
81 #endif 81 #endif
OLDNEW
« include/core/SkImageInfo.h ('K') | « src/core/SkMipMap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698