Adding a flush method to SkCanvas
BUG=http://code.google.com/p/skia/issues/detail?id=467
REVIEW=http://codereview.appspot.com/5600044/
TEST=gm uses the new code path on all its test cases
git-svn-id: http://skia.googlecode.com/svn/trunk@3102 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index c1304a2..7be822a 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -287,9 +287,7 @@
}
SkAutoUnref canvasUnref(canvas);
invokeGM(gm, canvas);
- if (deferred) {
- canvas->getDevice()->accessBitmap(false); // trigger a flush
- }
+ canvas->flush();
} else { // GPU
if (NULL == context) {
return ERROR_NO_GPU_CONTEXT;
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6d3a24d..4e74e0a 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -62,6 +62,11 @@
///////////////////////////////////////////////////////////////////////////
/**
+ * Trigger the immediate execution of all pending draw operations.
+ */
+ void flush();
+
+ /**
* Return the width/height of the underlying device. The current drawable
* area may be small (due to clipping or saveLayer). For a canvas with
* no device, 0,0 will be returned.
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 2a5a748..ed65eca 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -470,6 +470,13 @@
///////////////////////////////////////////////////////////////////////////////
+void SkCanvas::flush() {
+ SkDevice* device = this->getDevice();
+ if (device) {
+ device->flush();
+ }
+}
+
SkISize SkCanvas::getDeviceSize() const {
SkDevice* d = this->getDevice();
return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0);
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index e92f1f8..906b1c5 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -535,6 +535,7 @@
void SkDeferredCanvas::DeferredDevice::flush()
{
flushPending();
+ fImmediateCanvas->flush();
}
void SkDeferredCanvas::DeferredDevice::flushContext()