summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/UpdateManager.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2011-10-05 13:19:22 -0700
committerChris Craik <ccraik@google.com>2011-10-10 10:36:06 -0700
commite48d27773894f36d85e5c2e2052ab90d502e1c72 (patch)
tree9871a3729a937442be5fbd1af4dbf8e884fb3713 /Source/WebCore/platform/graphics/android/UpdateManager.cpp
parent63147313cabd16f95cd018f8b5ecc5070a985fe5 (diff)
downloadexternal_webkit-e48d27773894f36d85e5c2e2052ab90d502e1c72.zip
external_webkit-e48d27773894f36d85e5c2e2052ab90d502e1c72.tar.gz
external_webkit-e48d27773894f36d85e5c2e2052ab90d502e1c72.tar.bz2
Double buffering for layers
bug:5309934 Defer picture changes and invalidations when: 1) a tiled texture hasn't completed painting 2) the user is scrolling (done in PaintedSurface) Remaining issues: Should block updates on zooming Change-Id: I60ee722e651f96e95a4ac0e819999fc1589037c3
Diffstat (limited to 'Source/WebCore/platform/graphics/android/UpdateManager.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/UpdateManager.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/android/UpdateManager.cpp b/Source/WebCore/platform/graphics/android/UpdateManager.cpp
new file mode 100644
index 0000000..1c20f1f
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/UpdateManager.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PaintedSurface.h"
+
+#include "LayerAndroid.h"
+#include "TilesManager.h"
+#include "SkCanvas.h"
+#include "SkPicture.h"
+
+#include <cutils/log.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "UpdateManager", __VA_ARGS__)
+
+#ifdef DEBUG
+
+#undef XLOG
+#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "UpdateManager", __VA_ARGS__)
+
+#else
+
+#undef XLOG
+#define XLOG(...)
+
+#endif // DEBUG
+
+namespace WebCore {
+
+UpdateManager::UpdateManager()
+ : m_paintingPicture(0)
+ , m_deferredPicture(0)
+{
+}
+
+UpdateManager::~UpdateManager()
+{
+ SkSafeUnref(m_paintingPicture);
+ SkSafeUnref(m_deferredPicture);
+}
+
+void UpdateManager::swap()
+{
+ m_paintingInval.op(m_deferredInval, SkRegion::kUnion_Op);
+ m_deferredInval.setEmpty();
+
+ android::Mutex::Autolock lock(m_paintingPictureSync);
+ if (m_deferredPicture) {
+ XLOG("unlock of updatemanager %p, was painting %p, now painting %p",
+ this, m_paintingPicture, m_deferredPicture);
+ SkSafeUnref(m_paintingPicture);
+ m_paintingPicture = m_deferredPicture;
+ m_deferredPicture = 0;
+ }
+}
+
+void UpdateManager::updateInval(const SkRegion& invalRegion)
+{
+ m_deferredInval.op(invalRegion, SkRegion::kUnion_Op);
+}
+
+void UpdateManager::updatePicture(SkPicture* picture)
+{
+ SkSafeRef(picture);
+ SkSafeUnref(m_deferredPicture);
+ m_deferredPicture = picture;
+}
+
+bool UpdateManager::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed)
+{
+ m_paintingPictureSync.lock();
+ SkPicture* picture = m_paintingPicture;
+ SkSafeRef(picture);
+ m_paintingPictureSync.unlock();
+
+ XLOG("UpdateManager %p painting with picture %p", this, picture);
+
+ if (!picture)
+ return false;
+
+ canvas->drawPicture(*picture);
+
+ // TODO: visualization layer diagonals
+
+ SkSafeUnref(picture);
+ return true;
+}
+
+
+void UpdateManager::clearPaintingInval()
+{
+ m_paintingInval.setEmpty();
+}
+
+} // namespace WebCore