| 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 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0); | 90 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0); |
| 91 REPORTER_ASSERT(r, setMatrix->matrix == translate); | 91 REPORTER_ASSERT(r, setMatrix->matrix == translate); |
| 92 | 92 |
| 93 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 2); | 93 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 2); |
| 94 SkMatrix expected = scale; | 94 SkMatrix expected = scale; |
| 95 expected.postConcat(translate); | 95 expected.postConcat(translate); |
| 96 REPORTER_ASSERT(r, setMatrix->matrix == expected); | 96 REPORTER_ASSERT(r, setMatrix->matrix == expected); |
| 97 } | 97 } |
| 98 | 98 |
| 99 struct TestBBH : public SkBBoxHierarchy { | 99 struct TestBBH : public SkBBoxHierarchy { |
| 100 virtual void insert(void* data, const SkIRect& bounds, bool defer) SK_OVERRI
DE { | 100 virtual void insert(void* data, const SkRect& bounds, bool defer) SK_OVERRID
E { |
| 101 Entry e = { (uintptr_t)data, bounds }; | 101 Entry e = { (uintptr_t)data, bounds }; |
| 102 entries.push(e); | 102 entries.push(e); |
| 103 } | 103 } |
| 104 virtual int getCount() const SK_OVERRIDE { return entries.count(); } | 104 virtual int getCount() const SK_OVERRIDE { return entries.count(); } |
| 105 | 105 |
| 106 virtual void flushDeferredInserts() SK_OVERRIDE {} | 106 virtual void flushDeferredInserts() SK_OVERRIDE {} |
| 107 | 107 |
| 108 virtual void search(const SkIRect& query, SkTDArray<void*>* results) const S
K_OVERRIDE {} | 108 virtual void search(const SkRect& query, SkTDArray<void*>* results) const SK
_OVERRIDE {} |
| 109 virtual void clear() SK_OVERRIDE {} | 109 virtual void clear() SK_OVERRIDE {} |
| 110 virtual void rewindInserts() SK_OVERRIDE {} | 110 virtual void rewindInserts() SK_OVERRIDE {} |
| 111 virtual int getDepth() const SK_OVERRIDE { return -1; } | 111 virtual int getDepth() const SK_OVERRIDE { return -1; } |
| 112 | 112 |
| 113 struct Entry { | 113 struct Entry { |
| 114 uintptr_t data; | 114 uintptr_t data; |
| 115 SkIRect bounds; | 115 SkRect bounds; |
| 116 }; | 116 }; |
| 117 SkTDArray<Entry> entries; | 117 SkTDArray<Entry> entries; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // This test is not meant to make total sense yet. It's testing the status quo | 120 // This test is not meant to make total sense yet. It's testing the status quo |
| 121 // of SkRecordFillBounds(), which itself doesn't make total sense yet. | 121 // of SkRecordFillBounds(), which itself doesn't make total sense yet. |
| 122 DEF_TEST(RecordDraw_BBH, r) { | 122 DEF_TEST(RecordDraw_BBH, r) { |
| 123 TestBBH bbh; | 123 TestBBH bbh; |
| 124 | 124 |
| 125 SkRecord record; | 125 SkRecord record; |
| 126 | 126 |
| 127 SkRecorder recorder(&record, W, H); | 127 SkRecorder recorder(&record, W, H); |
| 128 recorder.save(); | 128 recorder.save(); |
| 129 recorder.clipRect(SkRect::MakeWH(400, 500)); | 129 recorder.clipRect(SkRect::MakeWH(400, 500)); |
| 130 recorder.scale(2, 2); | 130 recorder.scale(2, 2); |
| 131 recorder.drawRect(SkRect::MakeWH(320, 240), SkPaint()); | 131 recorder.drawRect(SkRect::MakeWH(320, 240), SkPaint()); |
| 132 recorder.restore(); | 132 recorder.restore(); |
| 133 | 133 |
| 134 SkRecordFillBounds(record, &bbh); | 134 SkRecordFillBounds(record, &bbh); |
| 135 | 135 |
| 136 REPORTER_ASSERT(r, bbh.entries.count() == 5); | 136 REPORTER_ASSERT(r, bbh.entries.count() == 5); |
| 137 for (int i = 0; i < bbh.entries.count(); i++) { | 137 for (int i = 0; i < bbh.entries.count(); i++) { |
| 138 REPORTER_ASSERT(r, bbh.entries[i].data == (uintptr_t)i); | 138 REPORTER_ASSERT(r, bbh.entries[i].data == (uintptr_t)i); |
| 139 | 139 |
| 140 REPORTER_ASSERT(r, bbh.entries[i].bounds == SkIRect::MakeWH(400, 480)); | 140 REPORTER_ASSERT(r, bbh.entries[i].bounds == SkRect::MakeWH(400, 480)); |
| 141 } | 141 } |
| 142 } | 142 } |
| OLD | NEW |