summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2010-10-29 18:39:15 -0700
committerNicolas Roard <nicolas@android.com>2010-11-01 16:56:13 -0700
commit9cbef29ebdf64aed66ee6a7d5081127dc3f26b4c (patch)
tree0ef356e6b7b69aad9a0dc6cefd21557cb9b4e4c0
parentcc519b6e7f277a2aa0aa197bdb7163d662749552 (diff)
downloadexternal_webkit-9cbef29ebdf64aed66ee6a7d5081127dc3f26b4c.zip
external_webkit-9cbef29ebdf64aed66ee6a7d5081127dc3f26b4c.tar.gz
external_webkit-9cbef29ebdf64aed66ee6a7d5081127dc3f26b4c.tar.bz2
Update the layers only
C++ counterpart to https://android-git.corp.google.com/g/#change,77500 Bug:2975990 Change-Id: I3b8fd27f991d6776059a15eef36d0c9a7b44f9bb
-rw-r--r--WebCore/platform/android/PlatformBridge.h3
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp27
-rw-r--r--WebKit/android/WebCoreSupport/PlatformBridge.cpp6
-rw-r--r--WebKit/android/jni/WebViewCore.cpp55
-rw-r--r--WebKit/android/jni/WebViewCore.h11
5 files changed, 80 insertions, 22 deletions
diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h
index 3900a74..334629b 100644
--- a/WebCore/platform/android/PlatformBridge.h
+++ b/WebCore/platform/android/PlatformBridge.h
@@ -136,6 +136,9 @@ public:
static void updateViewport(FrameView*);
static void updateTextfield(FrameView*, Node*, bool changeToPassword, const WTF::String& text);
+
+ // Updates the layers on the UI
+ static void updateLayers(FrameView* view);
};
}
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index b8c57c0..593c896 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -525,10 +525,13 @@ void GraphicsLayerAndroid::setNeedsDisplayInRect(const FloatRect& rect)
return;
}
+ bool addInval = true;
const size_t maxDirtyRects = 8;
for (size_t i = 0; i < m_invalidatedRects.size(); ++i) {
- if (m_invalidatedRects[i].contains(rect))
- return;
+ if (m_invalidatedRects[i].contains(rect)) {
+ addInval = false;
+ break;
+ }
}
#ifdef LAYER_DEBUG
@@ -536,13 +539,25 @@ void GraphicsLayerAndroid::setNeedsDisplayInRect(const FloatRect& rect)
m_needsRepaint, rect.x(), rect.y(), rect.width(), rect.height());
#endif
- if (m_invalidatedRects.size() < maxDirtyRects)
- m_invalidatedRects.append(rect);
- else
- m_invalidatedRects[0].unite(rect);
+ if (addInval) {
+ if (m_invalidatedRects.size() < maxDirtyRects)
+ m_invalidatedRects.append(rect);
+ else
+ m_invalidatedRects[0].unite(rect);
+ }
m_needsRepaint = true;
askForSync();
+
+ if (!m_client)
+ return;
+
+ // Update the layers on the UI
+ RenderLayer* renderLayer = renderLayerFromClient(m_client);
+ if (renderLayer) {
+ FrameView* frameView = renderLayer->root()->renderer()->view()->frameView();
+ PlatformBridge::updateLayers(frameView);
+ }
}
void GraphicsLayerAndroid::pauseDisplay(bool state)
diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
index 092676b..284e6b3 100644
--- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp
+++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
@@ -169,6 +169,12 @@ void PlatformBridge::updateTextfield(FrameView* frameView, Node* nodePtr, bool c
webViewCore->updateTextfield(nodePtr, changeToPassword, text);
}
+void PlatformBridge::updateLayers(FrameView* frameView)
+{
+ android::WebViewCore* webViewCore = android::WebViewCore::getWebViewCore(frameView);
+ webViewCore->layersDraw();
+}
+
} // namespace WebCore
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index aa7b79c..b3c0cd6 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -246,6 +246,7 @@ struct WebViewCore::JavaGlue {
jmethodID m_scrollTo;
jmethodID m_scrollBy;
jmethodID m_contentDraw;
+ jmethodID m_layersDraw;
jmethodID m_requestListBox;
jmethodID m_openFileChooser;
jmethodID m_requestSingleListBox;
@@ -339,6 +340,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_scrollTo = GetJMethod(env, clazz, "contentScrollTo", "(II)V");
m_javaGlue->m_scrollBy = GetJMethod(env, clazz, "contentScrollBy", "(IIZ)V");
m_javaGlue->m_contentDraw = GetJMethod(env, clazz, "contentDraw", "()V");
+ m_javaGlue->m_layersDraw = GetJMethod(env, clazz, "layersDraw", "()V");
m_javaGlue->m_requestListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[I[I)V");
m_javaGlue->m_openFileChooser = GetJMethod(env, clazz, "openFileChooser", "(Ljava/lang/String;)Ljava/lang/String;");
m_javaGlue->m_requestSingleListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[II)V");
@@ -842,6 +844,26 @@ void WebViewCore::rebuildPictureSet(PictureSet* pictureSet)
pictureSet->validate(__FUNCTION__);
}
+BaseLayerAndroid* WebViewCore::createBaseLayer()
+{
+ BaseLayerAndroid* base = new BaseLayerAndroid();
+ base->setContent(m_content);
+
+#if USE(ACCELERATED_COMPOSITING)
+ // We update the layers
+ ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>(m_mainFrame->page()->chrome()->client());
+ GraphicsLayerAndroid* root = static_cast<GraphicsLayerAndroid*>(chromeC->layersSync());
+ if (root) {
+ root->notifyClientAnimationStarted();
+ LayerAndroid* copyLayer = new LayerAndroid(*root->contentLayer());
+ base->addChild(copyLayer);
+ copyLayer->unref();
+ }
+#endif
+
+ return base;
+}
+
BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point)
{
DBG_SET_LOG("start");
@@ -863,22 +885,7 @@ BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point)
region->getBounds().fBottom);
DBG_SET_LOG("end");
- BaseLayerAndroid* base = new BaseLayerAndroid();
- base->setContent(m_content);
-
-#if USE(ACCELERATED_COMPOSITING)
- // We update the layers
- ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>(m_mainFrame->page()->chrome()->client());
- GraphicsLayerAndroid* root = static_cast<GraphicsLayerAndroid*>(chromeC->layersSync());
- if (root) {
- root->notifyClientAnimationStarted();
- LayerAndroid* copyLayer = new LayerAndroid(*root->contentLayer());
- base->addChild(copyLayer);
- copyLayer->unref();
- }
-#endif
-
- return base;
+ return createBaseLayer();
}
void WebViewCore::splitContent(PictureSet* content)
@@ -938,6 +945,13 @@ void WebViewCore::contentDraw()
checkException(env);
}
+void WebViewCore::layersDraw()
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_layersDraw);
+ checkException(env);
+}
+
void WebViewCore::contentInvalidate(const WebCore::IntRect &r)
{
DBG_SET_LOGD("rect={%d,%d,w=%d,h=%d}", r.x(), r.y(), r.width(), r.height());
@@ -3478,6 +3492,13 @@ void WebViewCore::addVisitedLink(const UChar* string, int length)
m_groupForVisitedLinks->addVisitedLink(string, length);
}
+static jint UpdateLayers(JNIEnv *env, jobject obj)
+{
+ WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ BaseLayerAndroid* result = viewImpl->createBaseLayer();
+ return reinterpret_cast<jint>(result);
+}
+
static jint RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt)
{
#ifdef ANDROID_INSTRUMENT
@@ -4014,6 +4035,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) UpdateFrameCache },
{ "nativeGetContentMinPrefWidth", "()I",
(void*) GetContentMinPrefWidth },
+ { "nativeUpdateLayers", "()I",
+ (void*) UpdateLayers },
{ "nativeRecordContent", "(Landroid/graphics/Region;Landroid/graphics/Point;)I",
(void*) RecordContent },
{ "setViewportSettingsFromNative", "()V",
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 520c2c9..853c17b 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -162,6 +162,11 @@ namespace android {
*/
void contentDraw();
+ /**
+ * copy the layers to the UI side
+ */
+ void layersDraw();
+
#if USE(ACCELERATED_COMPOSITING)
GraphicsLayerAndroid* graphicsRootLayer() const;
#endif
@@ -485,6 +490,12 @@ namespace android {
// record the inval area, and the picture size
BaseLayerAndroid* recordContent(SkRegion* , SkIPoint* );
+
+ // This creates a new BaseLayerAndroid by copying the current m_content
+ // and doing a copy of the layers. The layers' content may be updated
+ // as we are calling layersSync().
+ BaseLayerAndroid* createBaseLayer();
+
int textWrapWidth() const { return m_textWrapWidth; }
float scale() const { return m_scale; }
float textWrapScale() const { return m_screenWidth * m_scale / m_textWrapWidth; }