skia2/tools/PictureBenchmark.h
scroggo@google.com 161e1ba4c0 Created my own flag parser, based off of gflags.
Share common code between bench_ and render_ to set up the PictureRenderer.
Fix an include error in SkPictureRenderer.h.
Simplified parameter passing in render_pictures_main.
Switch to using an SkAutoTUnref for the PictureRenderer.
I also changed the input format somewhat, so the buildbots need to be updated as well: https://codereview.appspot.com/7441044/
Fixed a bug in PictureBenchmark where calling setTimeIndividualTiles(false) sets the member variable to true.
Removed setDeviceType from PictureBenchmark, since only the PictureRenderer needs to know which device type to use.

Some changes to the input format:
'--logPerIter' no longer takes a 1 or 0. Instead, '--logPerIter'
turns it on and '--nologPerIter' turns it off (with off as the
default). (Note that this is for bench_pictures; bench still uses the old format)

Change '--device' to '--config' and 'bitmap' to '8888' to be
the same as gm.

Requires '--r' before inputs (to match gm), though there can be multiple inputs following it.

Changed --enable-deferred-image-decoding (which no one uses but me yet anyway) to --deferImageDecoding, since the former is incompatible with the flag parser.

Changes to behavior:
Show a short error message on failure (rather than the explanation of all
flags).

BUG=https://code.google.com/p/skia/issues/detail?id=1094

Review URL: https://codereview.appspot.com/7230053

git-svn-id: http://skia.googlecode.com/svn/trunk@7961 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-03-04 16:41:06 +00:00

83 lines
2.1 KiB
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef PictureBenchmark_DEFINED
#define PictureBenchmark_DEFINED
#include "SkTypes.h"
#include "PictureRenderer.h"
class BenchTimer;
class SkBenchLogger;
class SkPicture;
class SkString;
namespace sk_tools {
class PictureBenchmark {
public:
PictureBenchmark();
~PictureBenchmark();
/**
* Draw the provided SkPicture fRepeats times while collecting timing data, and log the output
* via fLogger.
*/
void run(SkPicture* pict);
void setRepeats(int repeats) {
fRepeats = repeats;
}
/**
* If true, tells run to log separate timing data for each individual tile. Each tile will be
* drawn fRepeats times. Requires the PictureRenderer set by setRenderer to be a
* TiledPictureRenderer.
*/
void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; }
bool timeIndividualTiles() { return fTimeIndividualTiles; }
PictureRenderer* setRenderer(PictureRenderer*);
void setLogPerIter(bool log) { fLogPerIter = log; }
void setPrintMin(bool min) { fPrintMin = min; }
void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) {
fShowWallTime = wall;
fShowTruncatedWallTime = truncatedWall;
fShowCpuTime = cpu;
fShowTruncatedCpuTime = truncatedCpu;
fShowGpuTime = gpu;
}
void setLogger(SkBenchLogger* logger) { fLogger = logger; }
private:
int fRepeats;
SkBenchLogger* fLogger;
PictureRenderer* fRenderer;
bool fLogPerIter;
bool fPrintMin;
bool fShowWallTime;
bool fShowTruncatedWallTime;
bool fShowCpuTime;
bool fShowTruncatedCpuTime;
bool fShowGpuTime;
bool fTimeIndividualTiles;
void logProgress(const char msg[]);
BenchTimer* setupTimer(bool useGLTimer = true);
};
}
#endif // PictureBenchmark_DEFINED