Adding virtual method to SkDeferredCanvas::NotificationClient for signaling when commands are skipped due to the skip on clear optimization.

TEST=DeferredCanvas unit test
BUG=http://code.google.com/p/chromium/issues/detail?id=116840 
Review URL: https://codereview.appspot.com/6590050

git-svn-id: http://skia.googlecode.com/svn/trunk@5747 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 95b3f73..f0b4ad2 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -217,7 +217,8 @@
 class NotificationCounter : public SkDeferredCanvas::NotificationClient {
 public:
     NotificationCounter() {
-        fPrepareForDrawCount = fStorageAllocatedChangedCount = fFlushedDrawCommandsCount = 0;
+        fPrepareForDrawCount = fStorageAllocatedChangedCount =
+            fFlushedDrawCommandsCount = fSkippedPendingDrawCommandsCount = 0;
     }
 
     virtual void prepareForDraw() SK_OVERRIDE {
@@ -229,10 +230,14 @@
     virtual void flushedDrawCommands() SK_OVERRIDE {
         fFlushedDrawCommandsCount++;
     }
+    virtual void skippedPendingDrawCommands() SK_OVERRIDE {
+        fSkippedPendingDrawCommandsCount++;
+    }
 
     int fPrepareForDrawCount;
     int fStorageAllocatedChangedCount;
     int fFlushedDrawCommandsCount;
+    int fSkippedPendingDrawCommandsCount;
 };
 
 static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
@@ -313,6 +318,26 @@
     sourceImages[1].notifyPixelsChanged();
     canvas.drawBitmap(sourceImages[1], 0, 0, NULL);
     REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() > 2*bitmapSize);
+
+    // Verify that nothing in this test caused commands to be skipped
+    REPORTER_ASSERT(reporter, 0 == notificationCounter.fSkippedPendingDrawCommandsCount);
+}
+
+static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) {
+    SkBitmap store;
+    store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
+    store.allocPixels();
+    SkDevice device(store);
+    NotificationCounter notificationCounter;
+    SkDeferredCanvas canvas(&device);
+    canvas.setNotificationClient(&notificationCounter);
+    canvas.clear(0x0);
+    REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawCommandsCount);
+    REPORTER_ASSERT(reporter, 0 == notificationCounter.fFlushedDrawCommandsCount);
+    canvas.flush();
+    REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawCommandsCount);
+    REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount);
+
 }
 
 static void TestDeferredCanvas(skiatest::Reporter* reporter) {
@@ -321,6 +346,7 @@
     TestDeferredCanvasFreshFrame(reporter);
     TestDeferredCanvasMemoryLimit(reporter);
     TestDeferredCanvasBitmapCaching(reporter);
+    TestDeferredCanvasSkip(reporter);
 }
 
 #include "TestClassDef.h"