diff options
author | Nicolas Roard <nicolas@android.com> | 2010-01-04 19:33:17 +0000 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2010-01-04 19:33:17 +0000 |
commit | 9acd586e4a0aa54e4f630665aa0d3c8c95b78e72 (patch) | |
tree | 97f62cc64e391bde4a9436791e844dda7ed3f76a /WebKit | |
parent | 5bd553b63661fa0f711bb9c02566d5df80a9432f (diff) | |
download | external_webkit-9acd586e4a0aa54e4f630665aa0d3c8c95b78e72.zip external_webkit-9acd586e4a0aa54e4f630665aa0d3c8c95b78e72.tar.gz external_webkit-9acd586e4a0aa54e4f630665aa0d3c8c95b78e72.tar.bz2 |
webkit layers support
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 63 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.h | 26 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 19 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 51 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 5 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 92 |
6 files changed, 252 insertions, 4 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 8390cbc..f14c2c1 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -38,6 +38,7 @@ #include "FrameLoader.h" #include "FrameView.h" #include "Geolocation.h" +#include "GraphicsLayerAndroid.h" #include "Page.h" #include "Screen.h" #include "ScriptController.h" @@ -49,6 +50,68 @@ namespace android { +#if USE(ACCELERATED_COMPOSITING) + +void ChromeClientAndroid::syncTimerFired(Timer<ChromeClientAndroid>* client) +{ + m_syncTimer.stop(); + compositingLayerSync(); +} + +void ChromeClientAndroid::compositingLayerSync() +{ + if (!m_rootGraphicsLayer) { + scheduleCompositingLayerSync(); + return; + } + + if (m_webFrame) { + FrameView* frameView = m_webFrame->page()->mainFrame()->view(); + if (frameView && !frameView->layoutPending() && !frameView->needsLayout()) { + frameView->syncCompositingStateRecursive(); + GraphicsLayerAndroid* androidGraphicsLayer = + static_cast<GraphicsLayerAndroid*>(m_rootGraphicsLayer); + if (androidGraphicsLayer) + androidGraphicsLayer->sendImmediateRepaint(); + return; + } + } + if (m_askToDrawAgain) { + m_askToDrawAgain = false; + scheduleCompositingLayerSync(); + } +} + +void ChromeClientAndroid::scheduleCompositingLayerSync() +{ + if (!m_syncTimer.isActive()) + m_syncTimer.startOneShot(0.001); // 1ms + else + m_askToDrawAgain = true; +} + +void ChromeClientAndroid::setNeedsOneShotDrawingSynchronization() +{ + // This should not be needed +} + +void ChromeClientAndroid::attachRootGraphicsLayer(WebCore::Frame* frame, WebCore::GraphicsLayer* layer) +{ + m_rootGraphicsLayer = layer; + if (!layer) { + WebViewCore::getWebViewCore(frame->view())->setRootLayer(0); + return; + } + WebCore::GraphicsLayerAndroid* androidGraphicsLayer = static_cast<GraphicsLayerAndroid*>(layer); + if (frame && frame->view() && androidGraphicsLayer) { + androidGraphicsLayer->setFrame(frame); + WebCore::LayerAndroid* androidLayer = new LayerAndroid(androidGraphicsLayer->contentLayer()); + WebViewCore::getWebViewCore(frame->view())->setRootLayer((int)androidLayer); + } +} + +#endif + void ChromeClientAndroid::setWebFrame(android::WebFrame* webframe) { Release(m_webFrame); diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index 7396997..45dd078 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -43,7 +43,13 @@ namespace android { class ChromeClientAndroid : public ChromeClient { public: - ChromeClientAndroid() : m_webFrame(0), m_geolocationPermissions(0) { } + ChromeClientAndroid() : m_webFrame(0), m_geolocationPermissions(0) +#if USE(ACCELERATED_COMPOSITING) + , m_rootGraphicsLayer(0) + , m_askToDrawAgain(false) + , m_syncTimer(this, &ChromeClientAndroid::syncTimerFired) +#endif + { } virtual void chromeDestroyed(); virtual void setWindowRect(const FloatRect&); @@ -149,13 +155,27 @@ namespace android { // Android-specific void setWebFrame(android::WebFrame* webframe); void wakeUpMainThreadWithNewQuota(long newQuota); + +#if USE(ACCELERATED_COMPOSITING) + virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer* g); + virtual void setNeedsOneShotDrawingSynchronization(); + virtual void scheduleCompositingLayerSync(); + void compositingLayerSync(); + void syncTimerFired(Timer<ChromeClientAndroid>*); +#endif + private: android::WebFrame* m_webFrame; + // The Geolocation permissions manager. + OwnPtr<GeolocationPermissions> m_geolocationPermissions; +#if USE(ACCELERATED_COMPOSITING) + WebCore::GraphicsLayer* m_rootGraphicsLayer; + bool m_askToDrawAgain; + Timer<ChromeClientAndroid> m_syncTimer; +#endif WTF::ThreadCondition m_quotaThreadCondition; WTF::Mutex m_quotaThreadLock; long m_newQuota; - // The Geolocation permissions manager. - OwnPtr<GeolocationPermissions> m_geolocationPermissions; }; } diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index e4fe4ce..e93d3da 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -28,11 +28,28 @@ #include "JavaSharedClient.h" #include "KeyGeneratorClient.h" +#include "WebViewCore.h" using namespace android; namespace WebCore { +#if USE(ACCELERATED_COMPOSITING) + +void PlatformBridge::setRootLayer(const WebCore::FrameView* view, int layer) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); + core->setRootLayer(layer); +} + +void PlatformBridge::immediateRepaint(const WebCore::FrameView* view) +{ + android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); + core->immediateRepaint(); +} + +#endif // USE(ACCELERATED_COMPOSITING) + WTF::Vector<String> PlatformBridge::getSupportedKeyStrengthList() { KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); @@ -51,4 +68,4 @@ String PlatformBridge::getSignedPublicKeyAndChallengeString(unsigned index, cons return client->getSignedPublicKeyAndChallengeString(index, challenge, url); } -}
\ No newline at end of file +} diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 1c1384a..5ebee31 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -130,6 +130,11 @@ FILE* gRenderTreeFile = 0; #include "TimeCounter.h" #endif +#if USE(ACCELERATED_COMPOSITING) +#include "GraphicsLayerAndroid.h" +#include "RenderLayerCompositor.h" +#endif + /* We pass this flag when recording the actual content, so that we don't spend time actually regionizing complex path clips, when all we really want to do is record them. @@ -195,6 +200,8 @@ struct WebViewCore::JavaGlue { jmethodID m_updateViewport; jmethodID m_sendNotifyProgressFinished; jmethodID m_sendViewInvalidate; + jmethodID m_sendImmediateRepaint; + jmethodID m_setRootLayer; jmethodID m_updateTextfield; jmethodID m_updateTextSelection; jmethodID m_clearTextEntry; @@ -277,6 +284,8 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_updateViewport = GetJMethod(env, clazz, "updateViewport", "()V"); m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V"); m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V"); + m_javaGlue->m_sendImmediateRepaint = GetJMethod(env, clazz, "sendImmediateRepaint", "()V"); + m_javaGlue->m_setRootLayer = GetJMethod(env, clazz, "setRootLayer", "(I)V"); m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIII)V"); m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); @@ -879,6 +888,28 @@ void WebViewCore::scrollBy(int dx, int dy, bool animate) checkException(env); } +#if USE(ACCELERATED_COMPOSITING) + +void WebViewCore::immediateRepaint() +{ + LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_sendImmediateRepaint); + checkException(env); +} + +void WebViewCore::setRootLayer(int layer) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), + m_javaGlue->m_setRootLayer, + layer); + checkException(env); +} + +#endif // USE(ACCELERATED_COMPOSITING) + void WebViewCore::contentDraw() { JNIEnv* env = JSC::Bindings::getJNIEnv(); @@ -1267,6 +1298,12 @@ void WebViewCore::updateCacheOnNodeChange() void WebViewCore::updateFrameCache() { +#if USE(ACCELERATED_COMPOSITING) + ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>( + mainFrame()->page()->chrome()->client()); + chromeC->scheduleCompositingLayerSync(); +#endif + if (!m_frameCacheOutOfDate) { DBG_NAV_LOG("!m_frameCacheOutOfDate"); return; @@ -2098,6 +2135,16 @@ int WebViewCore::handleTouchEvent(int action, int x, int y) { int preventDefault = 0; +#if USE(ACCELERATED_COMPOSITING) + RenderView* contentRenderer = m_mainFrame->contentRenderer(); + GraphicsLayerAndroid* rootLayer = 0; + if (contentRenderer) + rootLayer = static_cast<GraphicsLayerAndroid*>( + contentRenderer->compositor()->rootPlatformLayer()); + if (rootLayer) + rootLayer->pauseDisplay(true); +#endif + #if ENABLE(TOUCH_EVENTS) // Android WebCore::TouchEventType type = WebCore::TouchEventCancel; switch (action) { @@ -2125,6 +2172,10 @@ int WebViewCore::handleTouchEvent(int action, int x, int y) preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te); #endif +#if USE(ACCELERATED_COMPOSITING) + if (rootLayer) + rootLayer->pauseDisplay(false); +#endif return preventDefault; } diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 4c8de78..75df0b5 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -126,6 +126,11 @@ namespace android { */ void contentDraw(); +#if USE(ACCELERATED_COMPOSITING) + void immediateRepaint(); + void setRootLayer(int layer); +#endif + /** Invalidate the view/screen, NOT the content/DOM, but expressed in * content/DOM coordinates (i.e. they need to eventually be scaled, * by webview into view.java coordinates diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index d1d5e86..c8d89de 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -28,6 +28,7 @@ #include <config.h> #include "android_graphics.h" +#include "AndroidAnimation.h" #include "AndroidLog.h" #include "AtomicString.h" #include "CachedFrame.h" @@ -39,6 +40,7 @@ #include "HTMLInputElement.h" #include "IntPoint.h" #include "IntRect.h" +#include "LayerAndroid.h" #include "Node.h" #include "PlatformGraphicsContext.h" #include "PlatformString.h" @@ -1602,6 +1604,86 @@ static void nativeDrawMatches(JNIEnv *env, jobject obj, jobject canv) view->drawMatches(canvas); } +static void nativeDrawLayers(JNIEnv *env, jobject obj, + jint layer, jfloat scrollX, jfloat scrollY, + jfloat scale, jobject canv) +{ + if (!env) + return; + if (!layer) + return; + if (!canv) + return; + +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); + if (canvas) + layerImpl->paintOn(scrollX, scrollY, scale, canvas); +#endif +} + +static void nativeUpdateLayers(JNIEnv *env, jobject obj, + jint layer, jint updates) +{ + if (!env) + return; + if (!layer) + return; + if (!updates) + return; + +#if USE(ACCELERATED_COMPOSITING) + Vector<RefPtr<AndroidAnimationValue> >* updatesImpl = + reinterpret_cast<Vector<RefPtr<AndroidAnimationValue> >* >(updates); + if (updatesImpl) { + for (unsigned int i = 0; i < updatesImpl->size(); i++) + (updatesImpl->at(i))->apply(); + delete updatesImpl; + } +#endif +} + +static bool nativeLayersHaveAnimations(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return false; + if (!layer) + return false; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + return layerImpl->hasAnimations(); +#else + return false; +#endif +} + +static int nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return 0; + if (!layer) + return 0; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + return reinterpret_cast<int>(layerImpl->evaluateAnimations()); +#else + return 0; +#endif +} + +static void nativeDestroyLayer(JNIEnv *env, jobject obj, jint layer) +{ + if (!env) + return; + if (!layer) + return; +#if USE(ACCELERATED_COMPOSITING) + LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); + delete layerImpl; +#endif +} + static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv) { SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); @@ -2143,6 +2225,16 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeDestroy }, { "nativeDrawCursorRing", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawCursorRing }, + { "nativeDestroyLayer", "(I)V", + (void*) nativeDestroyLayer }, + { "nativeLayersHaveAnimations", "(I)Z", + (void*) nativeLayersHaveAnimations }, + { "nativeEvaluateLayersAnimations", "(I)I", + (void*) nativeEvaluateLayersAnimations }, + { "nativeDrawLayers", "(IFFFLandroid/graphics/Canvas;)V", + (void*) nativeDrawLayers }, + { "nativeUpdateLayers", "(II)V", + (void*) nativeUpdateLayers }, { "nativeDrawMatches", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawMatches }, { "nativeDrawSelectionPointer", "(Landroid/graphics/Canvas;FIIZ)V", |