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

Side by Side Diff: tests/ImageIsOpaqueTest.cpp

Issue 805803002: ensure 4-byte alignment for storage, as SkWriterBuffer requires it (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | 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 "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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698