Update bench to be able to preprocess skps
This allows benchmarking of optimization improvements and plumbs in the purging API. The purging is necessary so we don't magically get faster because the saveLayers are always pre-generated. R=jvanverth@google.com, reed@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/233663002 git-svn-id: http://skia.googlecode.com/svn/trunk@14154 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
0bd03cf38c
commit
c873329ae9
@ -932,6 +932,12 @@ public:
|
||||
*/
|
||||
void EXPERIMENTAL_optimize(SkPicture* picture);
|
||||
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call
|
||||
Purge all the discardable optimization information associated with
|
||||
'picture'. If NULL is passed in, purge all discardable information.
|
||||
*/
|
||||
void EXPERIMENTAL_purge(SkPicture* picture);
|
||||
|
||||
/** Draw the picture into this canvas. This method effective brackets the
|
||||
playback of the picture's draw calls with save/restore, so the state
|
||||
of this canvas will be unchanged after this call.
|
||||
|
@ -343,6 +343,13 @@ protected:
|
||||
*/
|
||||
virtual void EXPERIMENTAL_optimize(SkPicture* picture);
|
||||
|
||||
/**
|
||||
* PRIVATE / EXPERIMENTAL -- do not call
|
||||
* Purge all discardable optimization information for 'picture'. If
|
||||
* picture is NULL then purge discardable information for all pictures.
|
||||
*/
|
||||
virtual void EXPERIMENTAL_purge(SkPicture* picture);
|
||||
|
||||
/**
|
||||
* PRIVATE / EXPERIMENTAL -- do not call
|
||||
* This entry point gives the backend an opportunity to take over the rendering
|
||||
@ -353,7 +360,7 @@ protected:
|
||||
* to perform some device-specific warm up tasks and then let SkCanvas
|
||||
* perform the main rendering loop (by return false from here).
|
||||
*/
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkPicture* picture);
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture);
|
||||
|
||||
private:
|
||||
friend class SkCanvas;
|
||||
|
@ -151,7 +151,9 @@ protected:
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call */
|
||||
virtual void EXPERIMENTAL_optimize(SkPicture* picture) SK_OVERRIDE;
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call */
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkPicture* picture) SK_OVERRIDE;
|
||||
virtual void EXPERIMENTAL_purge(SkPicture* picture) SK_OVERRIDE;
|
||||
/** PRIVATE / EXPERIMENTAL -- do not call */
|
||||
virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
|
@ -2542,12 +2542,19 @@ void SkCanvas::EXPERIMENTAL_optimize(SkPicture* picture) {
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::EXPERIMENTAL_purge(SkPicture* picture) {
|
||||
SkBaseDevice* device = this->getTopDevice();
|
||||
if (NULL != device) {
|
||||
device->EXPERIMENTAL_purge(picture);
|
||||
}
|
||||
}
|
||||
|
||||
void SkCanvas::drawPicture(SkPicture& picture) {
|
||||
SkBaseDevice* device = this->getTopDevice();
|
||||
if (NULL != device) {
|
||||
// Canvas has to first give the device the opportunity to render
|
||||
// the picture itself.
|
||||
if (device->EXPERIMENTAL_drawPicture(&picture)) {
|
||||
if (device->EXPERIMENTAL_drawPicture(this, &picture)) {
|
||||
return; // the device has rendered the entire picture
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,12 @@ void SkBaseDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
|
||||
// The base class doesn't perform any analysis but derived classes may
|
||||
}
|
||||
|
||||
bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkPicture* picture) {
|
||||
void SkBaseDevice::EXPERIMENTAL_purge(SkPicture* picture) {
|
||||
// Derived-classes may have data to purge but not the base class
|
||||
}
|
||||
|
||||
bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
|
||||
// The base class doesn't perform any accelerated picture rendering
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1918,7 +1918,11 @@ void SkGpuDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
|
||||
GatherGPUInfo(picture, data);
|
||||
}
|
||||
|
||||
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkPicture* picture) {
|
||||
void SkGpuDevice::EXPERIMENTAL_purge(SkPicture* picture) {
|
||||
|
||||
}
|
||||
|
||||
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, SkPicture* picture) {
|
||||
|
||||
SkPicture::AccelData::Key key = ComputeAccelDataKey();
|
||||
|
||||
|
@ -23,6 +23,7 @@ PictureBenchmark::PictureBenchmark()
|
||||
, fTimerTypes(0)
|
||||
, fTimeIndividualTiles(false)
|
||||
, fPurgeDecodedTex(false)
|
||||
, fPreprocess(false)
|
||||
{}
|
||||
|
||||
PictureBenchmark::~PictureBenchmark() {
|
||||
@ -77,9 +78,22 @@ void PictureBenchmark::run(SkPicture* pict) {
|
||||
|
||||
// We throw this away to remove first time effects (such as paging in this program)
|
||||
fRenderer->setup();
|
||||
|
||||
if (fPreprocess) {
|
||||
if (NULL != fRenderer->getCanvas()) {
|
||||
fRenderer->getCanvas()->EXPERIMENTAL_optimize(pict);
|
||||
}
|
||||
}
|
||||
|
||||
fRenderer->render(NULL);
|
||||
fRenderer->resetState(true); // flush, swapBuffers and Finish
|
||||
|
||||
if (fPreprocess) {
|
||||
if (NULL != fRenderer->getCanvas()) {
|
||||
fRenderer->getCanvas()->EXPERIMENTAL_purge(pict);
|
||||
}
|
||||
}
|
||||
|
||||
if (fPurgeDecodedTex) {
|
||||
fRenderer->purgeTextures();
|
||||
}
|
||||
@ -216,6 +230,12 @@ void PictureBenchmark::run(SkPicture* pict) {
|
||||
|
||||
SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get()));
|
||||
|
||||
if (fPreprocess) {
|
||||
if (NULL != fRenderer->getCanvas()) {
|
||||
fRenderer->getCanvas()->EXPERIMENTAL_purge(pict);
|
||||
}
|
||||
}
|
||||
|
||||
if (fPurgeDecodedTex) {
|
||||
fRenderer->purgeTextures();
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
void setPurgeDecodedTex(bool purgeDecodedTex) { fPurgeDecodedTex = purgeDecodedTex; }
|
||||
bool purgeDecodedText() const { return fPurgeDecodedTex; }
|
||||
|
||||
void setPreprocess(bool preprocess) { fPreprocess = preprocess; }
|
||||
bool preprocess() const { return fPreprocess; }
|
||||
|
||||
PictureRenderer* setRenderer(PictureRenderer*);
|
||||
|
||||
void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
|
||||
@ -62,6 +65,7 @@ private:
|
||||
uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values
|
||||
bool fTimeIndividualTiles;
|
||||
bool fPurgeDecodedTex;
|
||||
bool fPreprocess;
|
||||
|
||||
void logProgress(const char msg[]);
|
||||
|
||||
|
@ -49,6 +49,8 @@ DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecod
|
||||
"SK_LAZY_CACHE_STATS set to true. Report percentage of cache hits when using "
|
||||
"deferred image decoding.");
|
||||
|
||||
DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing before timing.");
|
||||
|
||||
static char const * const gFilterTypes[] = {
|
||||
"paint",
|
||||
"point",
|
||||
@ -341,6 +343,7 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
|
||||
}
|
||||
|
||||
benchmark->setPurgeDecodedTex(FLAGS_purgeDecodedTex);
|
||||
benchmark->setPreprocess(FLAGS_preprocess);
|
||||
|
||||
if (FLAGS_readPath.count() < 1) {
|
||||
gLogger.logError(".skp files or directories are required.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user