Index: tools/viewer/sk_app/Window.h |
diff --git a/tools/viewer/sk_app/Window.h b/tools/viewer/sk_app/Window.h |
index 63d5e19e5594716c9bc95742b0fac51fe8b9af75..c1718c44ff73de58e1dc3056ead05bd2ff164479 100644 |
--- a/tools/viewer/sk_app/Window.h |
+++ b/tools/viewer/sk_app/Window.h |
@@ -12,6 +12,7 @@ |
#include "SkRect.h" |
#include "SkTouchGesture.h" |
#include "SkTypes.h" |
+#include "../private/SkMutex.h" |
class SkCanvas; |
@@ -27,8 +28,15 @@ public: |
virtual void setTitle(const char*) = 0; |
virtual void show() = 0; |
+ |
+ // Make sure that onPaint is called in the subclasses' implementations of inval. |
+ // We will unset fIsContentInvalided in onPaint, which allows checkAndInval |
+ // to invalidate the content after the onPaint. |
virtual void inval() = 0; |
+ // Check if the current window has any pending inval; call inval if not. |
+ void checkAndInval(); |
+ |
virtual bool scaleContentToFit() const { return false; } |
virtual bool supportsContentRect() const { return false; } |
virtual SkRect getContentRect() { return SkRect::MakeEmpty(); } |
@@ -164,6 +172,9 @@ protected: |
void* fPaintUserData; |
WindowContext* fWindowContext = nullptr; |
+ |
+ bool fIsContentInvalidated = false; // use this to avoid duplicate invalidate events |
+ SkMutex fMutex; |
}; |
} // namespace sk_app |