aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkCanvas.h6
-rw-r--r--include/core/SkDevice.h9
-rw-r--r--include/gpu/SkGpuDevice.h4
-rw-r--r--src/core/SkCanvas.cpp9
-rw-r--r--src/core/SkDevice.cpp7
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--tools/PictureBenchmark.cpp20
-rw-r--r--tools/PictureBenchmark.h4
-rw-r--r--tools/bench_pictures_main.cpp3
9 files changed, 63 insertions, 5 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 4d9c462b73..94eb6add7f 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -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.
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index e2f676465e..f8a0c2ca62 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -345,6 +345,13 @@ protected:
/**
* 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
* of 'picture'. If optimization data is available (due to an earlier
* 'optimize' call) this entry point should make use of it and return true
@@ -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;
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index a8231914e4..7f564dedd2 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -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;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index c16ac9a09f..8d35eaedf9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -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
}
}
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 255ad02e08..f8a7115aa8 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -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;
}
+
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 911ac5a235..7c804ab2a0 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -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();
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index 3cc34157fd..62369a430f 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -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();
}
diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h
index e9d9f65c49..e149f8c9e9 100644
--- a/tools/PictureBenchmark.h
+++ b/tools/PictureBenchmark.h
@@ -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[]);
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 4952571fad..5ff519c8c5 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -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");