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 "SKPBench.h" | 8 #include "SKPBench.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkMultiPictureDraw.h" | 10 #include "SkMultiPictureDraw.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 for (int j = 0; j < fTileRects.count(); ++j) { | 148 for (int j = 0; j < fTileRects.count(); ++j) { |
149 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, | 149 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, |
150 -fTileRects[j].fTop / fScale)
; | 150 -fTileRects[j].fTop / fScale)
; |
151 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr); | 151 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr); |
152 } | 152 } |
153 | 153 |
154 for (int j = 0; j < fTileRects.count(); ++j) { | 154 for (int j = 0; j < fTileRects.count(); ++j) { |
155 fSurfaces[j]->getCanvas()->flush(); | 155 fSurfaces[j]->getCanvas()->flush(); |
156 } | 156 } |
157 } | 157 } |
| 158 |
| 159 #if SK_SUPPORT_GPU |
| 160 static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPic
ture* picture, |
| 161 SkTArray<SkString>* keys, SkTArray<double>* value
s, |
| 162 const char* tag) { |
| 163 context->resetGpuStats(); |
| 164 canvas->drawPicture(picture); |
| 165 canvas->flush(); |
| 166 |
| 167 int offset = keys->count(); |
| 168 context->dumpGpuStatsKeyValuePairs(keys, values); |
| 169 |
| 170 // append tag, but only to new tags |
| 171 for (int i = offset; i < keys->count(); i++, offset++) { |
| 172 (*keys)[i].appendf("_%s", tag); |
| 173 } |
| 174 } |
| 175 #endif |
| 176 |
| 177 void SKPBench::getGpuStats(SkCanvas* canvas, SkTArray<SkString>* keys, SkTArray<
double>* values) { |
| 178 #if SK_SUPPORT_GPU |
| 179 // we do a special single draw and then dump the key / value pairs |
| 180 GrContext* context = canvas->getGrContext(); |
| 181 if (!context) { |
| 182 return; |
| 183 } |
| 184 |
| 185 // TODO refactor this out if we want to test other subclasses of skpbench |
| 186 context->flush(); |
| 187 context->freeGpuResources(); |
| 188 context->resetContext(); |
| 189 draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame"); |
| 190 |
| 191 // draw second frame |
| 192 draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame"); |
| 193 |
| 194 #endif |
| 195 } |
OLD | NEW |