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 #if SK_SUPPORT_GPU | 8 #if SK_SUPPORT_GPU |
9 | 9 |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 recorder.restore(); | 90 recorder.restore(); |
91 recorder.drawRect(SkRect::MakeWH(SkIntToScalar(kWidth/2), SkIntToScalar(kHei
ght/2)), | 91 recorder.drawRect(SkRect::MakeWH(SkIntToScalar(kWidth/2), SkIntToScalar(kHei
ght/2)), |
92 SkPaint()); | 92 SkPaint()); |
93 | 93 |
94 GrReplacements replacements; | 94 GrReplacements replacements; |
95 GrReplacements::ReplacementInfo* ri = replacements.push(); | 95 GrReplacements::ReplacementInfo* ri = replacements.push(); |
96 ri->fStart = 0; | 96 ri->fStart = 0; |
97 ri->fStop = 2; | 97 ri->fStop = 2; |
98 ri->fPos.set(0, 0); | 98 ri->fPos.set(0, 0); |
99 ri->fImage = make_image(SK_ColorRED); | 99 ri->fImage = make_image(SK_ColorRED); |
100 ri->fPaint = paint; | 100 ri->fPaint = SkNEW(SkPaint); |
101 ri->fSrcRect = SkIRect::MakeWH(kWidth, kHeight); | 101 ri->fSrcRect = SkIRect::MakeWH(kWidth, kHeight); |
102 | 102 |
103 SkAutoTUnref<SkBBoxHierarchy> bbh; | 103 SkAutoTUnref<SkBBoxHierarchy> bbh; |
104 | 104 |
105 if (useBBH) { | 105 if (useBBH) { |
106 SkRTreeFactory factory; | 106 SkRTreeFactory factory; |
107 bbh.reset((factory)(kWidth, kHeight)); | 107 bbh.reset((factory)(kWidth, kHeight)); |
108 SkRecordFillBounds(record, bbh); | 108 SkRecordFillBounds(record, bbh); |
109 } | 109 } |
110 | 110 |
111 SkRecord rerecord; | 111 SkRecord rerecord; |
112 SkRecorder canvas(&rerecord, kWidth, kHeight); | 112 SkRecorder canvas(&rerecord, kWidth, kHeight); |
113 GrRecordReplaceDraw(record, &canvas, bbh, &replacements, NULL/*callback*/); | 113 GrRecordReplaceDraw(record, &canvas, bbh, &replacements, NULL/*callback*/); |
114 | 114 |
115 REPORTER_ASSERT(r, 7 == rerecord.count()); | 115 REPORTER_ASSERT(r, 7 == rerecord.count()); |
116 assert_type<SkRecords::Save>(r, rerecord, 0); | 116 assert_type<SkRecords::Save>(r, rerecord, 0); |
117 assert_type<SkRecords::Save>(r, rerecord, 1); | 117 assert_type<SkRecords::Save>(r, rerecord, 1); |
118 assert_type<SkRecords::SetMatrix>(r, rerecord, 2); | 118 assert_type<SkRecords::SetMatrix>(r, rerecord, 2); |
119 assert_type<SkRecords::DrawBitmapRectToRect>(r, rerecord, 3); | 119 assert_type<SkRecords::DrawBitmapRectToRect>(r, rerecord, 3); |
120 assert_type<SkRecords::Restore>(r, rerecord, 4); | 120 assert_type<SkRecords::Restore>(r, rerecord, 4); |
121 assert_type<SkRecords::DrawRect>(r, rerecord, 5); | 121 assert_type<SkRecords::DrawRect>(r, rerecord, 5); |
122 assert_type<SkRecords::Restore>(r, rerecord, 6); | 122 assert_type<SkRecords::Restore>(r, rerecord, 6); |
123 } | 123 } |
124 | 124 |
125 DEF_TEST(RecordReplaceDraw_Replace, r) { test_replacements(r, false); } | 125 DEF_TEST(RecordReplaceDraw_Replace, r) { test_replacements(r, false); } |
126 DEF_TEST(RecordReplaceDraw_ReplaceWithBBH, r) { test_replacements(r, true); } | 126 DEF_TEST(RecordReplaceDraw_ReplaceWithBBH, r) { test_replacements(r, true); } |
127 | 127 |
128 #endif | 128 #endif |
OLD | NEW |