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

Side by Side Diff: tests/RecordTest.cpp

Issue 1824983003: SkRecord: infer return type for visit() and mutate(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « src/gpu/GrRecordReplaceDraw.cpp ('k') | tests/RecordTestUtils.h » ('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 "RecordTestUtils.h" 8 #include "RecordTestUtils.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkImageInfo.h" 10 #include "SkImageInfo.h"
(...skipping 11 matching lines...) Expand all
22 template <typename T> void operator()(const T&) { } 22 template <typename T> void operator()(const T&) { }
23 23
24 void operator()(const SkRecords::DrawRect& draw) { 24 void operator()(const SkRecords::DrawRect& draw) {
25 fArea += (int)(draw.rect.width() * draw.rect.height()); 25 fArea += (int)(draw.rect.width() * draw.rect.height());
26 } 26 }
27 27
28 int area() const { return fArea; } 28 int area() const { return fArea; }
29 29
30 void apply(const SkRecord& record) { 30 void apply(const SkRecord& record) {
31 for (int i = 0; i < record.count(); i++) { 31 for (int i = 0; i < record.count(); i++) {
32 record.visit<void>(i, *this); 32 record.visit(i, *this);
33 } 33 }
34 } 34 }
35 35
36 private: 36 private:
37 int fArea; 37 int fArea;
38 }; 38 };
39 39
40 // Scales out the bottom-right corner of any DrawRect command it sees by 2x. 40 // Scales out the bottom-right corner of any DrawRect command it sees by 2x.
41 struct Stretch { 41 struct Stretch {
42 template <typename T> void operator()(T*) {} 42 template <typename T> void operator()(T*) {}
43 void operator()(SkRecords::DrawRect* draw) { 43 void operator()(SkRecords::DrawRect* draw) {
44 draw->rect.fRight *= 2; 44 draw->rect.fRight *= 2;
45 draw->rect.fBottom *= 2; 45 draw->rect.fBottom *= 2;
46 } 46 }
47 47
48 void apply(SkRecord* record) { 48 void apply(SkRecord* record) {
49 for (int i = 0; i < record->count(); i++) { 49 for (int i = 0; i < record->count(); i++) {
50 record->mutate<void>(i, *this); 50 record->mutate(i, *this);
51 } 51 }
52 } 52 }
53 }; 53 };
54 54
55 #define APPEND(record, type, ...) new (record.append<type>()) type{__VA_ARGS__} 55 #define APPEND(record, type, ...) new (record.append<type>()) type{__VA_ARGS__}
56 56
57 // Basic tests for the low-level SkRecord code. 57 // Basic tests for the low-level SkRecord code.
58 DEF_TEST(Record, r) { 58 DEF_TEST(Record, r) {
59 SkRecord record; 59 SkRecord record;
60 60
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 REPORTER_ASSERT(r, is_aligned(record.alloc<uint32_t>())); 110 REPORTER_ASSERT(r, is_aligned(record.alloc<uint32_t>()));
111 REPORTER_ASSERT(r, is_aligned(record.alloc<void*>())); 111 REPORTER_ASSERT(r, is_aligned(record.alloc<void*>()));
112 112
113 // It's not clear if we care that 8-byte values are aligned on 32-bit machin es. 113 // It's not clear if we care that 8-byte values are aligned on 32-bit machin es.
114 if (sizeof(void*) == 8) { 114 if (sizeof(void*) == 8) {
115 REPORTER_ASSERT(r, is_aligned(record.alloc<double>())); 115 REPORTER_ASSERT(r, is_aligned(record.alloc<double>()));
116 REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>())); 116 REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
117 } 117 }
118 } 118 }
119 119
OLDNEW
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | tests/RecordTestUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698