DEFINE_bool2(fullscreen, f, true, "Run fullscreen.");
DEFINE_bool2(interactive, n, false, "Run in interactive mode.");
+DEFINE_bool2(dif, d, false, "Use device-independent fonts.");
VisualBench::VisualBench(void* hwnd, int argc, char** argv)
: INHERITED(hwnd) {
SkCommandLineFlags::Parse(argc, argv);
- // this has to happen after commandline parsing
+ // these have to happen after commandline parsing
+ if (FLAGS_dif) {
+ const SkSurfaceProps& props(INHERITED::getSurfaceProps());
+ uint32_t flags = SkSurfaceProps::kUseDeviceIndependentFonts_Flag | props.flags();
+ INHERITED::setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
+ }
fModule.reset(new VisualLightweightBenchModule(this));
if (FLAGS_interactive) {
fModule.reset(new VisualInteractiveModule(this));
SkPath fPath;
};
-VisualBenchmarkStream::VisualBenchmarkStream()
- : fBenches(BenchRegistry::Head())
+VisualBenchmarkStream::VisualBenchmarkStream(const SkSurfaceProps& surfaceProps)
+ : fSurfaceProps(surfaceProps)
+ , fBenches(BenchRegistry::Head())
, fGMs(skiagm::GMRegistry::Head())
, fSourceType(nullptr)
, fBenchType(nullptr)
// TODO move this all to --config
if (bench && FLAGS_cpu) {
- bench = new CpuWrappedBenchmark(bench);
+ bench = new CpuWrappedBenchmark(fSurfaceProps, bench);
} else if (bench && FLAGS_nvpr) {
- bench = new NvprWrappedBenchmark(bench, 4);
+ bench = new NvprWrappedBenchmark(fSurfaceProps, bench, 4);
}
fBenchmark.reset(bench);
class VisualBenchmarkStream {
public:
- VisualBenchmarkStream();
+ VisualBenchmarkStream(const SkSurfaceProps&);
static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic);
private:
Benchmark* innerNext();
+ SkSurfaceProps fSurfaceProps;
const BenchRegistry* fBenches;
const skiagm::GMRegistry* fGMs;
SkTArray<SkString> fSKPs;
: fInitState(kReset_InitState)
, fPreWarmBeforeSample(preWarmBeforeSample)
, fOwner(owner) {
- fBenchmarkStream.reset(new VisualBenchmarkStream);
+ fBenchmarkStream.reset(new VisualBenchmarkStream(owner->getSurfaceProps()));
}
inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) {
class WrappedBenchmark : public Benchmark {
public:
// Takes ownership of caller's ref on `bench`.
- explicit WrappedBenchmark(Benchmark* bench) : fBench(bench) {}
+ explicit WrappedBenchmark(const SkSurfaceProps& surfaceProps, Benchmark* bench)
+ : fSurfaceProps(surfaceProps)
+ , fBench(bench) {}
+
+ const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
const char* onGetName() override { return fBench->getName(); }
const char* onGetUniqueName() override { return fBench->getUniqueName(); }
private:
virtual SkSurface* setupOffScreen(SkCanvas*)=0;
+ SkSurfaceProps fSurfaceProps;
SkAutoTUnref<SkSurface> fOffScreen;
SkAutoTUnref<Benchmark> fBench;
};
// Create a raster surface for off screen rendering
class CpuWrappedBenchmark : public WrappedBenchmark {
public:
- explicit CpuWrappedBenchmark(Benchmark* bench) : INHERITED(bench) {}
+ explicit CpuWrappedBenchmark(const SkSurfaceProps& surfaceProps, Benchmark* bench)
+ : INHERITED(surfaceProps, bench) {}
private:
SkSurface* setupOffScreen(SkCanvas* canvas) override {
- return SkSurface::NewRaster(canvas->imageInfo());
+ return SkSurface::NewRaster(canvas->imageInfo(), &this->surfaceProps());
}
typedef WrappedBenchmark INHERITED;
// Create an MSAA & NVPR-enabled GPU backend
class NvprWrappedBenchmark : public WrappedBenchmark {
public:
- explicit NvprWrappedBenchmark(Benchmark* bench, int numSamples)
- : INHERITED(bench)
+ explicit NvprWrappedBenchmark(const SkSurfaceProps& surfaceProps, Benchmark* bench,
+ int numSamples)
+ : INHERITED(surfaceProps, bench)
, fNumSamples(numSamples) {}
private:
return SkSurface::NewRenderTarget(canvas->getGrContext(),
SkSurface::kNo_Budgeted,
canvas->imageInfo(),
- fNumSamples);
+ fNumSamples,
+ &this->surfaceProps());
}
int fNumSamples;