skia2/bench/nanobench.h
bsalomon a0a024e323 Revert of Make NVPR a GL context option instead of a GL context (patchset #2 id:20001 of https://codereview.chromium.org/1448883002/ )
Reason for revert:
BUG=skia:4609

skbug.com/4609

Seems like GrContextFactory needs to fail when the NVPR option is requested but the driver version isn't sufficiently high.

Original issue's description:
> Make NVPR a GL context option instead of a GL context
>
> Make NVPR a GL context option instead of a GL context.
> This may enable NVPR to be run with command buffer
> interface.
>
> No functionality change in DM or nanobench. NVPR can
> only be run with normal GL APIs.
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1

TBR=mtklein@google.com,jvanverth@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992

Review URL: https://codereview.chromium.org/1486153002
2015-12-01 07:58:44 -08:00

88 lines
2.3 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef nanobench_DEFINED
#define nanobench_DEFINED
#include "Benchmark.h"
#include "SkImageInfo.h"
#include "SkSurface.h"
#include "SkTypes.h"
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
#endif
class ResultsWriter;
class SkBitmap;
class SkCanvas;
struct Config {
const char* name;
Benchmark::Backend backend;
SkColorType color;
SkAlphaType alpha;
int samples;
#if SK_SUPPORT_GPU
GrContextFactory::GLContextType ctxType;
bool useDFText;
#else
int bogusInt;
bool bogusBool;
#endif
};
struct Target {
explicit Target(const Config& c) : config(c) { }
virtual ~Target() { }
const Config config;
SkAutoTDelete<SkSurface> surface;
/** Called once per target, immediately before any timing or drawing. */
virtual void setup() { }
/** Called *after* the clock timer is started, before the benchmark
is drawn. Most back ends just return the canvas passed in,
but some may replace it. */
virtual SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; }
/** Called *after* a benchmark is drawn, but before the clock timer
is stopped. */
virtual void endTiming() { }
/** Called between benchmarks (or between calibration and measured
runs) to make sure all pending work in drivers / threads is
complete. */
virtual void fence() { }
/** CPU-like targets can just be timed, but GPU-like
targets need to pay attention to frame boundaries
or other similar details. */
virtual bool needsFrameTiming(int* frameLag) const { return false; }
/** Called once per target, during program initialization.
Returns false if initialization fails. */
virtual bool init(SkImageInfo info, Benchmark* bench);
/** Stores any pixels drawn to the screen in the bitmap.
Returns false on error. */
virtual bool capturePixels(SkBitmap* bmp);
/** Writes any config-specific data to the log. */
virtual void fillOptions(ResultsWriter*) { }
SkCanvas* getCanvas() const {
if (!surface.get()) {
return nullptr;
}
return surface->getCanvas();
}
};
#endif // nanobench_DEFINED