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 |
11 #if SK_SUPPORT_GPU | 11 #if SK_SUPPORT_GPU |
12 #include "GrContextFactory.h" | 12 #include "GrContextFactory.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 | 20 // just need a safe amount of storage, but ensure that it is 4-byte aligned. |
21 char storage[sizeof(SkImageInfo)*2]; | 21 int32_t storage[(sizeof(SkImageInfo)*2) / sizeof(int32_t)]; |
22 SkWriteBuffer wb(storage, sizeof(storage)); | 22 SkWriteBuffer 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; | 27 SkImageInfo info2; |
28 | 28 |
29 // pick a noisy byte pattern, so we ensure that unflatten sets all of our fi
elds | 29 // pick a noisy byte pattern, so we ensure that unflatten sets all of our fi
elds |
30 memset(&info2, 0xB8, sizeof(info2)); | 30 memset(&info2, 0xB8, sizeof(info2)); |
31 | 31 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType)
; | 86 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType)
; |
87 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context
, infoOpaque)); | 87 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context
, infoOpaque)); |
88 #if 0 | 88 #if 0 |
89 // this is failing right now : TODO fix me | 89 // this is failing right now : TODO fix me |
90 check_isopaque(reporter, surfaceOpaque, true); | 90 check_isopaque(reporter, surfaceOpaque, true); |
91 #endif | 91 #endif |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 #endif | 95 #endif |
OLD | NEW |