| 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 | 9 |
| 10 #include "SkRecord.h" | 10 #include "SkRecord.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 void operator()(const T&) { *ptr = NULL; type = U::kType; } | 30 void operator()(const T&) { *ptr = NULL; type = U::kType; } |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // Assert that the ith command in record is of type T, and return it. | 33 // Assert that the ith command in record is of type T, and return it. |
| 34 template <typename T> | 34 template <typename T> |
| 35 static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsig
ned index) { | 35 static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsig
ned index) { |
| 36 const T* ptr = NULL; | 36 const T* ptr = NULL; |
| 37 ReadAs<T> reader(&ptr); | 37 ReadAs<T> reader(&ptr); |
| 38 record.visit(index, reader); | 38 record.visit(index, reader); |
| 39 REPORTER_ASSERT(r, T::kType == reader.type); | 39 REPORTER_ASSERT(r, T::kType == reader.type); |
| 40 REPORTER_ASSERT(r, ptr != NULL); | |
| 41 return ptr; | 40 return ptr; |
| 42 } | 41 } |
| 43 | 42 |
| 44 DEF_TEST(RecordOpts_Culling, r) { | 43 DEF_TEST(RecordOpts_Culling, r) { |
| 45 SkRecord record; | 44 SkRecord record; |
| 46 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); | 45 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); |
| 47 | 46 |
| 48 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); | 47 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); |
| 49 | 48 |
| 50 recorder.pushCull(SkRect::MakeWH(100, 100)); | 49 recorder.pushCull(SkRect::MakeWH(100, 100)); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // SaveLayer/Restore removed: we can fold in the alpha! | 218 // SaveLayer/Restore removed: we can fold in the alpha! |
| 220 recorder.saveLayer(NULL, &goodLayerPaint); | 219 recorder.saveLayer(NULL, &goodLayerPaint); |
| 221 recorder.drawRect(draw, goodDrawPaint); | 220 recorder.drawRect(draw, goodDrawPaint); |
| 222 recorder.restore(); | 221 recorder.restore(); |
| 223 assert_savelayer_restore(r, &record, 15, true); | 222 assert_savelayer_restore(r, &record, 15, true); |
| 224 | 223 |
| 225 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); | 224 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); |
| 226 REPORTER_ASSERT(r, drawRect != NULL); | 225 REPORTER_ASSERT(r, drawRect != NULL); |
| 227 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); | 226 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); |
| 228 } | 227 } |
| OLD | NEW |