Proposed SkCanvas API for preLoading textures to VRAM v2.0

This is an update to (Proposed SkCanvas API for preLoading textures to VRAM - https://codereview.chromium.org/192853002/). It takes into account in-person feedback on the initial proposal. The main feedback was to land this closer to where we will ultimately wind up with the reordered rendering capability (and don't have an SkCanvas entry point (yet)).

Committed: http://code.google.com/p/skia/source/detail?r=13810

R=reed@google.com, bsalomon@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/197123003

git-svn-id: http://skia.googlecode.com/svn/trunk@13822 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 4ac7b29..f2200a6 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2461,8 +2461,23 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
+void SkCanvas::EXPERIMENTAL_optimize(SkPicture* picture) {
+    SkBaseDevice* device = this->getDevice();
+    if (NULL != device) {
+        device->EXPERIMENTAL_optimize(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)) {
+            return; // the device has rendered the entire picture
+        }
+    }
+
     picture.draw(this);
 }