| OLD | NEW |
| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 | 27 |
| 28 // 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 |
| 29 SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlp
haType) 0xB8, | 29 SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlp
haType) 0xB8, |
| 30 (SkColorProfileType) 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 |
| 35 // FIXME (msarett): |
| 36 // Support flatten/unflatten of SkColorSpace objects. |
| 37 REPORTER_ASSERT(reporter, info.makeColorSpace(nullptr) == info2.makeColorSpa
ce(nullptr)); |
| 35 } | 38 } |
| 36 | 39 |
| 37 DEF_TEST(ImageInfo_flattening, reporter) { | 40 DEF_TEST(ImageInfo_flattening, reporter) { |
| 38 for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) { | 41 for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) { |
| 39 for (int at = 0; at <= kLastEnum_SkAlphaType; ++at) { | 42 for (int at = 0; at <= kLastEnum_SkAlphaType; ++at) { |
| 40 for (int pt = 0; pt <= kLastEnum_SkColorProfileType; ++pt) { | 43 for (int pt = 0; pt <= kLastEnum_SkColorProfileType; ++pt) { |
| 41 SkImageInfo info = SkImageInfo::Make(100, 200, | 44 SkImageInfo info = SkImageInfo::Make(100, 200, |
| 42 static_cast<SkColorType>(ct
), | 45 static_cast<SkColorType>(ct
), |
| 43 static_cast<SkAlphaType>(at
), | 46 static_cast<SkAlphaType>(at
), |
| 44 static_cast<SkColorProfileT
ype>(pt)); | 47 static_cast<SkColorProfileT
ype>(pt)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo
, infoTransparent)); | 75 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo
, infoTransparent)); |
| 73 check_isopaque(reporter, surfaceTransparent, false); | 76 check_isopaque(reporter, surfaceTransparent, false); |
| 74 | 77 |
| 75 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); | 78 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); |
| 76 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info
Opaque)); | 79 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info
Opaque)); |
| 77 | 80 |
| 78 check_isopaque(reporter, surfaceOpaque, true); | 81 check_isopaque(reporter, surfaceOpaque, true); |
| 79 } | 82 } |
| 80 | 83 |
| 81 #endif | 84 #endif |
| OLD | NEW |