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 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 sk_sp<SkPicture> pic; | 71 sk_sp<SkPicture> pic; |
72 | 72 |
73 { | 73 { |
74 SkPictureRecorder recorder; | 74 SkPictureRecorder recorder; |
75 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT
oScalar(kHeight)); | 75 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT
oScalar(kHeight)); |
76 | 76 |
77 // We won't balance this, but GrRecordReplaceDraw will for us. | 77 // We won't balance this, but GrRecordReplaceDraw will for us. |
78 canvas->save(); | 78 canvas->save(); |
79 canvas->scale(2, 2); | 79 canvas->scale(2, 2); |
80 pic = recorder.finishRecordingAsPicture(); | 80 pic = recorder.finishRecordingAsPicture(); |
| 81 |
| 82 // we may have optimized everything away. If so, just return |
| 83 if (pic->approximateOpCount() == 0) { |
| 84 return; |
| 85 } |
81 } | 86 } |
82 | 87 |
83 SkRecord rerecord; | 88 SkRecord rerecord; |
84 SkRecorder canvas(&rerecord, kWidth, kHeight); | 89 SkRecorder canvas(&rerecord, kWidth, kHeight); |
85 | 90 |
86 GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*cal
lback*/); | 91 GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*cal
lback*/); |
87 | 92 |
88 // ensure rerecord is balanced (in this case by checking that the count is o
dd) | 93 // ensure rerecord is balanced (in this case by checking that the count is o
dd) |
89 REPORTER_ASSERT(r, (rerecord.count() & 1) == 1); | 94 REPORTER_ASSERT(r, (rerecord.count() & 1) == 1); |
90 } | 95 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 REPORTER_ASSERT(r, 1 == numLayers); | 150 REPORTER_ASSERT(r, 1 == numLayers); |
146 } | 151 } |
147 } | 152 } |
148 | 153 |
149 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RecordReplaceDraw, r, ctxInfo) { | 154 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RecordReplaceDraw, r, ctxInfo) { |
150 test_replacements(r, ctxInfo.grContext(), true); | 155 test_replacements(r, ctxInfo.grContext(), true); |
151 test_replacements(r, ctxInfo.grContext(), false); | 156 test_replacements(r, ctxInfo.grContext(), false); |
152 } | 157 } |
153 | 158 |
154 #endif | 159 #endif |
OLD | NEW |