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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); | 53 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); |
54 recorder.popCull(); | 54 recorder.popCull(); |
55 recorder.popCull(); | 55 recorder.popCull(); |
56 | 56 |
57 SkRecordAnnotateCullingPairs(&record); | 57 SkRecordAnnotateCullingPairs(&record); |
58 | 58 |
59 REPORTER_ASSERT(r, 6 == assert_type<SkRecords::PairedPushCull>(r, record, 1)
->skip); | 59 REPORTER_ASSERT(r, 6 == assert_type<SkRecords::PairedPushCull>(r, record, 1)
->skip); |
60 REPORTER_ASSERT(r, 2 == assert_type<SkRecords::PairedPushCull>(r, record, 4)
->skip); | 60 REPORTER_ASSERT(r, 2 == assert_type<SkRecords::PairedPushCull>(r, record, 4)
->skip); |
61 } | 61 } |
62 | 62 |
| 63 DEF_TEST(RecordOpts_NoopCulls, r) { |
| 64 SkRecord record; |
| 65 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, W, H); |
| 66 |
| 67 // All should be nooped. |
| 68 recorder.pushCull(SkRect::MakeWH(200, 200)); |
| 69 recorder.pushCull(SkRect::MakeWH(100, 100)); |
| 70 recorder.popCull(); |
| 71 recorder.popCull(); |
| 72 |
| 73 // Kept for now. We could peel off a layer of culling. |
| 74 recorder.pushCull(SkRect::MakeWH(5, 5)); |
| 75 recorder.pushCull(SkRect::MakeWH(5, 5)); |
| 76 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); |
| 77 recorder.popCull(); |
| 78 recorder.popCull(); |
| 79 |
| 80 SkRecordNoopCulls(&record); |
| 81 |
| 82 for (unsigned i = 0; i < 4; i++) { |
| 83 assert_type<SkRecords::NoOp>(r, record, i); |
| 84 } |
| 85 assert_type<SkRecords::PushCull>(r, record, 4); |
| 86 assert_type<SkRecords::PushCull>(r, record, 5); |
| 87 assert_type<SkRecords::DrawRect>(r, record, 6); |
| 88 assert_type<SkRecords::PopCull>(r, record, 7); |
| 89 assert_type<SkRecords::PopCull>(r, record, 8); |
| 90 } |
| 91 |
63 static void draw_pos_text(SkCanvas* canvas, const char* text, bool constantY) { | 92 static void draw_pos_text(SkCanvas* canvas, const char* text, bool constantY) { |
64 const size_t len = strlen(text); | 93 const size_t len = strlen(text); |
65 SkAutoTMalloc<SkPoint> pos(len); | 94 SkAutoTMalloc<SkPoint> pos(len); |
66 for (size_t i = 0; i < len; i++) { | 95 for (size_t i = 0; i < len; i++) { |
67 pos[i].fX = (SkScalar)i; | 96 pos[i].fX = (SkScalar)i; |
68 pos[i].fY = constantY ? SK_Scalar1 : (SkScalar)i; | 97 pos[i].fY = constantY ? SK_Scalar1 : (SkScalar)i; |
69 } | 98 } |
70 canvas->drawPosText(text, len, pos, SkPaint()); | 99 canvas->drawPosText(text, len, pos, SkPaint()); |
71 } | 100 } |
72 | 101 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // SaveLayer/Restore removed: we can fold in the alpha! | 260 // SaveLayer/Restore removed: we can fold in the alpha! |
232 recorder.saveLayer(NULL, &goodLayerPaint); | 261 recorder.saveLayer(NULL, &goodLayerPaint); |
233 recorder.drawRect(draw, goodDrawPaint); | 262 recorder.drawRect(draw, goodDrawPaint); |
234 recorder.restore(); | 263 recorder.restore(); |
235 assert_savelayer_restore(r, &record, 15, true); | 264 assert_savelayer_restore(r, &record, 15, true); |
236 | 265 |
237 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); | 266 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
cord, 16); |
238 REPORTER_ASSERT(r, drawRect != NULL); | 267 REPORTER_ASSERT(r, drawRect != NULL); |
239 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); | 268 REPORTER_ASSERT(r, drawRect->paint.getColor() == 0x03020202); |
240 } | 269 } |
OLD | NEW |