Adding hasPendingCommands API method to SkDeferredCanvas
authorjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Sep 2012 22:10:33 +0000 (22:10 +0000)
committerjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Sep 2012 22:10:33 +0000 (22:10 +0000)
BUG=http://code.google.com/p/chromium/issues/detail?id=146178
Review URL: https://codereview.appspot.com/6550050

git-svn-id: http://skia.googlecode.com/svn/trunk@5632 2bbb7eff-a529-9590-31e7-b0007b416f81

include/utils/SkDeferredCanvas.h
src/utils/SkDeferredCanvas.cpp

index f3005b3..f5674d1 100644 (file)
@@ -87,6 +87,12 @@ public:
     bool isFreshFrame() const;
 
     /**
+     *  Returns true if the canvas has recorded draw commands that have
+     *  not yet been played back.
+     */
+    bool hasPendingCommands() const;
+
+    /**
      *  Specify the maximum number of bytes to be allocated for the purpose
      *  of recording draw commands to this canvas.  The default limit, is
      *  64MB.
index 5beaa5b..a854d8c 100644 (file)
@@ -157,7 +157,7 @@ public:
     virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE;
     virtual void notifyWritten(size_t bytes) SK_OVERRIDE;
     void playback(bool silent);
-    bool hasRecorded() const { return fAllocator.blockCount() != 0; }
+    bool hasPendingCommands() const { return fAllocator.blockCount() != 0; }
     size_t storageAllocatedForRecording() const { return fAllocator.totalCapacity(); }
 private:
     enum {
@@ -237,6 +237,7 @@ public:
     SkCanvas* immediateCanvas() const {return fImmediateCanvas;}
     SkDevice* immediateDevice() const {return fImmediateDevice;}
     bool isFreshFrame();
+    bool hasPendingCommands();
     size_t storageAllocatedForRecording() const;
     size_t freeMemoryIfPossible(size_t bytesToFree);
     void flushPendingCommands(PlaybackMode);
@@ -377,7 +378,7 @@ void DeferredDevice::setNotificationClient(
 }
 
 void DeferredDevice::skipPendingCommands() {
-    if (!fRecordingCanvas->isDrawingToLayer() && fPipeController.hasRecorded()) {
+    if (!fRecordingCanvas->isDrawingToLayer() && fPipeController.hasPendingCommands()) {
         fFreshFrame = true;
         flushPendingCommands(kSilent_PlaybackMode);
     }
@@ -389,8 +390,12 @@ bool DeferredDevice::isFreshFrame() {
     return ret;
 }
 
+bool DeferredDevice::hasPendingCommands() {
+    return fPipeController.hasPendingCommands();
+}
+
 void DeferredDevice::flushPendingCommands(PlaybackMode playbackMode) {
-    if (!fPipeController.hasRecorded()) {
+    if (!fPipeController.hasPendingCommands()) {
         return;
     }
     if (playbackMode == kNormal_PlaybackMode && fNotificationClient) {
@@ -589,6 +594,10 @@ bool SkDeferredCanvas::isFreshFrame() const {
     return this->getDeferredDevice()->isFreshFrame();
 }
 
+bool SkDeferredCanvas::hasPendingCommands() const {
+    return this->getDeferredDevice()->hasPendingCommands();
+}
+
 void SkDeferredCanvas::silentFlush() {
     if (fDeferredDrawing) {
         this->getDeferredDevice()->flushPendingCommands(kSilent_PlaybackMode);