OSDN Git Service

Support registering page swap callback, content inval
authorChris Craik <ccraik@google.com>
Mon, 1 Aug 2011 20:44:44 +0000 (13:44 -0700)
committerChris Craik <ccraik@google.com>
Tue, 2 Aug 2011 23:48:44 +0000 (16:48 -0700)
bug:5062896

Depends on the following frameworks/base change:
https://android-git.corp.google.com/g/#change,124879

a WebView may now register a page swap callback and content invalidate to
benchmark tile rendering performance

Change-Id: I97f6ed05cff12b11266a472163aab1f3b3ddc87e

Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
Source/WebCore/platform/graphics/android/GLWebViewState.cpp
Source/WebCore/platform/graphics/android/GLWebViewState.h
Source/WebKit/android/nav/WebView.cpp

index 014fa40..3aa325f 100644 (file)
@@ -254,6 +254,11 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale,
             *pagesSwapped = true;
     }
 
+    // if no longer trailing behind invalidates, unlock (so invalidates can
+    // go directly to the the TiledPages without deferral)
+    if (!needsRedraw)
+        m_glWebViewState->unlockBaseLayerUpdate();
+
     m_glWebViewState->paintExtras();
     return needsRedraw;
 }
index 07dda03..bc582d9 100644 (file)
@@ -220,6 +220,7 @@ void GLWebViewState::setExtra(BaseLayerAndroid* layer, SkPicture& picture,
 void GLWebViewState::inval(const IntRect& rect)
 {
     if (m_baseLayerUpdate) {
+        // base layer isn't locked, so go ahead and issue the inval to both tiled pages
         m_currentPictureCounter++;
         if (!rect.isEmpty()) {
             // find which tiles fall within the invalRect and mark them as dirty
@@ -234,6 +235,7 @@ void GLWebViewState::inval(const IntRect& rect)
                  rect.x(), rect.y(), rect.width(), rect.height());
         }
     } else {
+        // base layer is locked, so defer invalidation until unlockBaseLayerUpdate()
         m_invalidateRegion.op(rect.x(), rect.y(), rect.maxX(), rect.maxY(), SkRegion::kUnion_Op);
     }
     TilesManager::instance()->getProfiler()->nextInval(rect, m_currentScale);
index 4f8d4fe..82b6f12 100644 (file)
@@ -129,6 +129,12 @@ class LayerAndroid;
 // paint the tile and the second id (B) represents the pictureSet in which the
 // tile was invalidated by webkit. Thus, if A < B then tile is dirty.
 //
+// Since invalidates can occur faster than a full tiled page update, the tiled
+// page is protected by a 'lock' (m_baseLayerUpdate) that is set to true to
+// defer updates to the background layer, giving the foreground time to render
+// content instead of constantly flushing with invalidates. See
+// lockBaseLayerUpdate() & unlockBaseLayerUpdate().
+//
 // Painting scheduling
 // -------------------
 //
index 69d1ee8..eb7562a 100644 (file)
@@ -1449,6 +1449,11 @@ static void copyScrollPositionRecursive(const LayerAndroid* from,
 }
 #endif
 
+void registerPageSwapCallback()
+{
+    m_pageSwapCallbackRegistered = true;
+}
+
 void setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndicator,
                   bool isPictureAfterFirstLayout, bool registerPageSwapCallback)
 {
@@ -2456,6 +2461,11 @@ static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jboolean set,
     GET_NATIVE_VIEW(env, obj)->setSelectionPointer(set, scale, x, y);
 }
 
+static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj)
+{
+    GET_NATIVE_VIEW(env, obj)->registerPageSwapCallback();
+}
+
 static void nativeTileProfilingStart(JNIEnv *env, jobject obj)
 {
     TilesManager::instance()->getProfiler()->start();
@@ -2786,6 +2796,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
         (void*) nativeSetSelectionPointer },
     { "nativeShowCursorTimed", "()V",
         (void*) nativeShowCursorTimed },
+    { "nativeRegisterPageSwapCallback", "()V",
+        (void*) nativeRegisterPageSwapCallback },
     { "nativeTileProfilingStart", "()V",
         (void*) nativeTileProfilingStart },
     { "nativeTileProfilingStop", "()F",