Chromium Code Reviews| 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 static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPic ture* picture, | |
|
bsalomon
2015/12/02 15:58:10
might need to protect this by a SK_SUPPORT_GPU
| |
| 160 SkTArray<SkString>* keys, SkTArray<double>* value s, | |
| 161 const char* tag) { | |
| 162 context->resetGpuStats(); | |
| 163 canvas->drawPicture(picture); | |
| 164 canvas->flush(); | |
| 165 | |
| 166 int offset = keys->count(); | |
| 167 context->dumpGpuStatsKeyValuePairs(keys, values); | |
| 168 | |
| 169 // append tag, but only to new tags | |
| 170 for (int i = offset; i < keys->count(); i++, offset++) { | |
| 171 (*keys)[i].appendf("_%s", tag); | |
| 172 } | |
| 173 } | |
| 174 | |
| 175 void SKPBench::getGpuStats(SkCanvas* canvas, SkTArray<SkString>* keys, SkTArray< double>* values) { | |
| 176 #if SK_SUPPORT_GPU | |
| 177 // we do a special single draw and then dump the key / value pairs | |
| 178 GrContext* context = canvas->getGrContext(); | |
| 179 if (!context) { | |
| 180 return; | |
| 181 } | |
| 182 | |
| 183 // TODO refactor this out if we want to test other subclasses of skpbench | |
| 184 context->flush(); | |
| 185 context->freeGpuResources(); | |
| 186 context->resetContext(); | |
| 187 draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame"); | |
| 188 | |
| 189 // draw second frame | |
| 190 draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame"); | |
| 191 | |
| 192 #endif | |
| 193 } | |
| OLD | NEW |