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 "Test.h" | 8 #include "Test.h" |
9 #include "RecordTestUtils.h" | 9 #include "RecordTestUtils.h" |
10 | 10 |
11 #include "SkDebugCanvas.h" | 11 #include "SkDebugCanvas.h" |
12 #include "SkDropShadowImageFilter.h" | 12 #include "SkDropShadowImageFilter.h" |
13 #include "SkImagePriv.h" | 13 #include "SkImagePriv.h" |
14 #include "SkRecord.h" | 14 #include "SkRecord.h" |
15 #include "SkRecordDraw.h" | 15 #include "SkRecordDraw.h" |
16 #include "SkRecordOpts.h" | 16 #include "SkRecordOpts.h" |
17 #include "SkRecorder.h" | 17 #include "SkRecorder.h" |
18 #include "SkRecords.h" | 18 #include "SkRecords.h" |
19 #include "SkSurface.h" | 19 #include "SkSurface.h" |
20 | 20 |
21 static const int W = 1920, H = 1080; | 21 static const int W = 1920, H = 1080; |
22 | 22 |
23 class JustOneDraw : public SkPicture::AbortCallback { | 23 class JustOneDraw : public SkPicture::AbortCallback { |
24 public: | 24 public: |
25 JustOneDraw() : fCalls(0) {} | 25 JustOneDraw() : fCalls(0) {} |
26 | 26 |
27 bool abort() SK_OVERRIDE { return fCalls++ > 0; } | 27 bool abort() override { return fCalls++ > 0; } |
28 private: | 28 private: |
29 int fCalls; | 29 int fCalls; |
30 }; | 30 }; |
31 | 31 |
32 DEF_TEST(RecordDraw_LazySaves, r) { | 32 DEF_TEST(RecordDraw_LazySaves, r) { |
33 // Record two commands. | 33 // Record two commands. |
34 SkRecord record; | 34 SkRecord record; |
35 SkRecorder recorder(&record, W, H); | 35 SkRecorder recorder(&record, W, H); |
36 | 36 |
37 REPORTER_ASSERT(r, 0 == record.count()); | 37 REPORTER_ASSERT(r, 0 == record.count()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0); | 116 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0); |
117 REPORTER_ASSERT(r, setMatrix->matrix == translate); | 117 REPORTER_ASSERT(r, setMatrix->matrix == translate); |
118 | 118 |
119 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 2); | 119 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 2); |
120 SkMatrix expected = scale; | 120 SkMatrix expected = scale; |
121 expected.postConcat(translate); | 121 expected.postConcat(translate); |
122 REPORTER_ASSERT(r, setMatrix->matrix == expected); | 122 REPORTER_ASSERT(r, setMatrix->matrix == expected); |
123 } | 123 } |
124 | 124 |
125 struct TestBBH : public SkBBoxHierarchy { | 125 struct TestBBH : public SkBBoxHierarchy { |
126 void insert(const SkRect boundsArray[], int N) SK_OVERRIDE { | 126 void insert(const SkRect boundsArray[], int N) override { |
127 fEntries.setCount(N); | 127 fEntries.setCount(N); |
128 for (int i = 0; i < N; i++) { | 128 for (int i = 0; i < N; i++) { |
129 Entry e = { (unsigned)i, boundsArray[i] }; | 129 Entry e = { (unsigned)i, boundsArray[i] }; |
130 fEntries[i] = e; | 130 fEntries[i] = e; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVER
RIDE {} | 134 void search(const SkRect& query, SkTDArray<unsigned>* results) const overrid
e {} |
135 size_t bytesUsed() const SK_OVERRIDE { return 0; } | 135 size_t bytesUsed() const override { return 0; } |
136 SkRect getRootBound() const SK_OVERRIDE { return SkRect::MakeEmpty(); } | 136 SkRect getRootBound() const override { return SkRect::MakeEmpty(); } |
137 | 137 |
138 struct Entry { | 138 struct Entry { |
139 unsigned opIndex; | 139 unsigned opIndex; |
140 SkRect bounds; | 140 SkRect bounds; |
141 }; | 141 }; |
142 SkTDArray<Entry> fEntries; | 142 SkTDArray<Entry> fEntries; |
143 }; | 143 }; |
144 | 144 |
145 // Like a==b, with a little slop recognizing that float equality can be weird. | 145 // Like a==b, with a little slop recognizing that float equality can be weird. |
146 static bool sloppy_rect_eq(SkRect a, SkRect b) { | 146 static bool sloppy_rect_eq(SkRect a, SkRect b) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 283 } |
284 | 284 |
285 DEF_TEST(RecordDraw_drawImage, r){ | 285 DEF_TEST(RecordDraw_drawImage, r){ |
286 class SkCanvasMock : public SkCanvas { | 286 class SkCanvasMock : public SkCanvas { |
287 public: | 287 public: |
288 SkCanvasMock(int width, int height) : SkCanvas(width, height) { | 288 SkCanvasMock(int width, int height) : SkCanvas(width, height) { |
289 this->resetTestValues(); | 289 this->resetTestValues(); |
290 } | 290 } |
291 | 291 |
292 void onDrawImage(const SkImage* image, SkScalar left, SkScalar top, | 292 void onDrawImage(const SkImage* image, SkScalar left, SkScalar top, |
293 const SkPaint* paint) SK_OVERRIDE { | 293 const SkPaint* paint) override { |
294 fDrawImageCalled = true; | 294 fDrawImageCalled = true; |
295 } | 295 } |
296 | 296 |
297 void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRe
ct& dst, | 297 void onDrawImageRect(const SkImage* image, const SkRect* src, const SkRe
ct& dst, |
298 const SkPaint* paint) SK_OVERRIDE { | 298 const SkPaint* paint) override { |
299 fDrawImageRectCalled = true; | 299 fDrawImageRectCalled = true; |
300 } | 300 } |
301 | 301 |
302 void resetTestValues() { | 302 void resetTestValues() { |
303 fDrawImageCalled = fDrawImageRectCalled = false; | 303 fDrawImageCalled = fDrawImageRectCalled = false; |
304 } | 304 } |
305 | 305 |
306 bool fDrawImageCalled; | 306 bool fDrawImageCalled; |
307 bool fDrawImageRectCalled; | 307 bool fDrawImageRectCalled; |
308 }; | 308 }; |
(...skipping 15 matching lines...) Expand all Loading... |
324 | 324 |
325 { | 325 { |
326 SkRecord record; | 326 SkRecord record; |
327 SkRecorder recorder(&record, 10, 10); | 327 SkRecorder recorder(&record, 10, 10); |
328 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); | 328 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); |
329 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0); | 329 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0); |
330 } | 330 } |
331 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); | 331 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); |
332 | 332 |
333 } | 333 } |
OLD | NEW |