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

Side by Side Diff: tests/ImageIsOpaqueTest.cpp

Issue 1920423002: Prototype code that turns any/every flattenable into JSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix copyright dates in new files Created 4 years, 7 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
« no previous file with comments | « tests/FlattenableCustomFactory.cpp ('k') | tests/PaintTest.cpp » ('j') | 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 SkWriteBuffer 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; 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
32 info2.unflatten(rb); 32 info2.unflatten(rb);
(...skipping 39 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
« no previous file with comments | « tests/FlattenableCustomFactory.cpp ('k') | tests/PaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698