Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: bench/SKPBench.cpp

Issue 1715873002: Fix nanobench SKP flushes between loops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool SKPBench::isSuitableFor(Backend backend) { 103 bool SKPBench::isSuitableFor(Backend backend) {
104 return backend != kNonRendering_Backend; 104 return backend != kNonRendering_Backend;
105 } 105 }
106 106
107 SkIPoint SKPBench::onGetSize() { 107 SkIPoint SKPBench::onGetSize() {
108 return SkIPoint::Make(fClip.width(), fClip.height()); 108 return SkIPoint::Make(fClip.width(), fClip.height());
109 } 109 }
110 110
111 void SKPBench::onDraw(int loops, SkCanvas* canvas) { 111 void SKPBench::onDraw(int loops, SkCanvas* canvas) {
112 SkASSERT(fDoLooping || 1 == loops); 112 SkASSERT(fDoLooping || 1 == loops);
113 if (fUseMultiPictureDraw) { 113 while (1) {
114 for (int i = 0; i < loops; i++) { 114 if (fUseMultiPictureDraw) {
115 this->drawMPDPicture(); 115 this->drawMPDPicture();
116 } 116 } else {
117 } else {
118 for (int i = 0; i < loops; i++) {
119 this->drawPicture(); 117 this->drawPicture();
120 } 118 }
119 if (0 == --loops) {
120 break;
121 }
122 #if SK_SUPPORT_GPU
123 // Ensure the GrContext doesn't batch across draw loops.
124 if (GrContext* context = canvas->getGrContext()) {
125 context->flush();
126 }
127 #endif
121 } 128 }
122 #if SK_SUPPORT_GPU
123 // Ensure the GrContext doesn't batch across draw loops.
124 if (GrContext* context = canvas->getGrContext()) {
125 context->flush();
126 }
127 #endif
128 } 129 }
129 130
130 void SKPBench::drawMPDPicture() { 131 void SKPBench::drawMPDPicture() {
131 SkMultiPictureDraw mpd; 132 SkMultiPictureDraw mpd;
132 133
133 for (int j = 0; j < fTileRects.count(); ++j) { 134 for (int j = 0; j < fTileRects.count(); ++j) {
134 SkMatrix trans; 135 SkMatrix trans;
135 trans.setTranslate(-fTileRects[j].fLeft/fScale, 136 trans.setTranslate(-fTileRects[j].fLeft/fScale,
136 -fTileRects[j].fTop/fScale); 137 -fTileRects[j].fTop/fScale);
137 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans); 138 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 context->freeGpuResources(); 190 context->freeGpuResources();
190 context->resetContext(); 191 context->resetContext();
191 context->getGpu()->resetShaderCacheForTesting(); 192 context->getGpu()->resetShaderCacheForTesting();
192 draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame"); 193 draw_pic_for_stats(canvas, context, fPic, keys, values, "first_frame");
193 194
194 // draw second frame 195 // draw second frame
195 draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame"); 196 draw_pic_for_stats(canvas, context, fPic, keys, values, "second_frame");
196 197
197 #endif 198 #endif
198 } 199 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698