diff options
author | Jonathan Dixon <joth@google.com> | 2012-03-05 19:43:05 +0000 |
---|---|---|
committer | Jonathan Dixon <joth@google.com> | 2012-03-21 07:59:14 +0000 |
commit | 1acf6173ad2e607642c57cf7572354df1f2f3fa8 (patch) | |
tree | 101ab2266b40c49b2e8136a68d2f004486525343 | |
parent | d77fa7bfea2cf8a2d29b5f3d994b45a270443a51 (diff) | |
download | external_webkit-1acf6173ad2e607642c57cf7572354df1f2f3fa8.zip external_webkit-1acf6173ad2e607642c57cf7572354df1f2f3fa8.tar.gz external_webkit-1acf6173ad2e607642c57cf7572354df1f2f3fa8.tar.bz2 |
Plumb WebView and WebViewCore thru to MediaLayer
Depends on https://android-git.corp.google.com/g/171224
Changes the plugin code to provide the WebView (not WebViewClassic) jobject
instance into the plugin, as this provides the full public API expected.
As a knock-on, I had to plumb WebViewCore jobject through to MediaTexture
so it can retain the sendPluginDrawMsg() call. This isn't pretty, but in
terms of layering it's no worse than before.
Change-Id: Iaaa6e0c6b65963fedaff078a20477d8595c82a5d
6 files changed, 23 insertions, 28 deletions
diff --git a/Source/WebCore/platform/graphics/android/MediaLayer.cpp b/Source/WebCore/platform/graphics/android/MediaLayer.cpp index de1db17..6227ea4 100644 --- a/Source/WebCore/platform/graphics/android/MediaLayer.cpp +++ b/Source/WebCore/platform/graphics/android/MediaLayer.cpp @@ -28,9 +28,9 @@ namespace WebCore { -MediaLayer::MediaLayer(jobject webViewRef) : LayerAndroid((RenderLayer*) NULL) +MediaLayer::MediaLayer(jobject webViewRef, jobject webViewCoreRef) : LayerAndroid((RenderLayer*) NULL) { - m_mediaTexture = new MediaTexture(webViewRef); + m_mediaTexture = new MediaTexture(webViewRef, webViewCoreRef); m_mediaTexture->incStrong(this); m_isCopy = false; diff --git a/Source/WebCore/platform/graphics/android/MediaLayer.h b/Source/WebCore/platform/graphics/android/MediaLayer.h index 907c53c..2f39d74 100644 --- a/Source/WebCore/platform/graphics/android/MediaLayer.h +++ b/Source/WebCore/platform/graphics/android/MediaLayer.h @@ -32,7 +32,7 @@ namespace WebCore { class MediaLayer : public LayerAndroid { public: - MediaLayer(jobject webViewRef); + MediaLayer(jobject webViewRef, jobject webViewCoreRef); MediaLayer(const MediaLayer& layer); virtual ~MediaLayer(); diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp index 789ca03..faa20a1 100644 --- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp +++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp @@ -41,14 +41,11 @@ namespace WebCore { -MediaTexture::MediaTexture(jobject webViewRef) : android::LightRefBase<MediaTexture>() +MediaTexture::MediaTexture(jobject webViewRef, jobject webViewCoreRef) : android::LightRefBase<MediaTexture>() { - if (webViewRef) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - m_weakWebViewRef = env->NewWeakGlobalRef(webViewRef); - } else { - m_weakWebViewRef = 0; - } + JNIEnv* env = JSC::Bindings::getJNIEnv(); + m_weakWebViewRef = env->NewWeakGlobalRef(webViewRef); + m_weakWebViewCoreRef = env->NewWeakGlobalRef(webViewCoreRef); m_contentTexture = 0; m_isContentInverted = false; @@ -63,10 +60,9 @@ MediaTexture::~MediaTexture() deleteTexture(m_videoTextures[i], true); } - if (m_weakWebViewRef) { - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->DeleteWeakGlobalRef(m_weakWebViewRef); - } + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->DeleteWeakGlobalRef(m_weakWebViewRef); + env->DeleteWeakGlobalRef(m_weakWebViewCoreRef); } bool MediaTexture::isContentInverted() @@ -98,16 +94,16 @@ void MediaTexture::initNativeWindowIfNeeded() m_contentTexture = createTexture(); // send a message to the WebKit thread to notify the plugin that it can draw - if (m_weakWebViewRef) { + if (m_weakWebViewCoreRef) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - jobject localWebViewRef = env->NewLocalRef(m_weakWebViewRef); - if (localWebViewRef) { - jclass wvClass = env->GetObjectClass(localWebViewRef); + jobject localWebViewCoreRef = env->NewLocalRef(m_weakWebViewCoreRef); + if (localWebViewCoreRef) { + jclass wvClass = env->GetObjectClass(localWebViewCoreRef); jmethodID sendPluginDrawMsg = env->GetMethodID(wvClass, "sendPluginDrawMsg", "()V"); - env->CallVoidMethod(localWebViewRef, sendPluginDrawMsg); + env->CallVoidMethod(localWebViewCoreRef, sendPluginDrawMsg); env->DeleteLocalRef(wvClass); - env->DeleteLocalRef(localWebViewRef); + env->DeleteLocalRef(localWebViewCoreRef); } checkException(env); } diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.h b/Source/WebCore/platform/graphics/android/MediaTexture.h index 97bb530..9ea7be2 100644 --- a/Source/WebCore/platform/graphics/android/MediaTexture.h +++ b/Source/WebCore/platform/graphics/android/MediaTexture.h @@ -40,7 +40,7 @@ class MediaListener; class MediaTexture : public android::LightRefBase<MediaTexture> { public: - MediaTexture(jobject webViewRef); + MediaTexture(jobject webViewRef, jobject webViewCoreRef); ~MediaTexture(); bool isContentInverted(); @@ -83,6 +83,7 @@ private: sp<ANativeWindow> m_newWindow; jobject m_weakWebViewRef; + jobject m_weakWebViewCoreRef; android::Mutex m_mediaLock; android::Condition m_newMediaRequestCond; diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 9aaec25..d1d8c84 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -309,7 +309,6 @@ struct WebViewCoreFields { jfieldID m_viewportMaximumScale; jfieldID m_viewportUserScalable; jfieldID m_viewportDensityDpi; - jfieldID m_webView; jfieldID m_drawIsPaused; jfieldID m_lowMemoryUsageMb; jfieldID m_highMemoryUsageMb; @@ -331,6 +330,7 @@ struct WebViewCore::JavaGlue { jmethodID m_jsPrompt; jmethodID m_jsUnload; jmethodID m_jsInterrupt; + jmethodID m_getWebView; jmethodID m_didFirstLayout; jmethodID m_updateViewport; jmethodID m_sendNotifyProgressFinished; @@ -466,6 +466,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_jsPrompt = GetJMethod(env, clazz, "jsPrompt", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); m_javaGlue->m_jsUnload = GetJMethod(env, clazz, "jsUnload", "(Ljava/lang/String;Ljava/lang/String;)Z"); m_javaGlue->m_jsInterrupt = GetJMethod(env, clazz, "jsInterrupt", "()Z"); + m_javaGlue->m_getWebView = GetJMethod(env, clazz, "getWebView", "()Landroid/webkit/WebView;"); m_javaGlue->m_didFirstLayout = GetJMethod(env, clazz, "didFirstLayout", "(Z)V"); m_javaGlue->m_updateViewport = GetJMethod(env, clazz, "updateViewport", "()V"); m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V"); @@ -3733,7 +3734,7 @@ WebViewCore::getWebViewJavaObject() AutoJObject javaObject = m_javaGlue->object(env); if (!javaObject.get()) return 0; - return env->GetObjectField(javaObject.get(), gWebViewCoreFields.m_webView); + return env->CallObjectMethod(javaObject.get(), m_javaGlue->m_getWebView); } RenderTextControl* WebViewCore::toRenderTextControl(Node* node) @@ -5172,10 +5173,6 @@ int registerWebViewCore(JNIEnv* env) "mViewportDensityDpi", "I"); ALOG_ASSERT(gWebViewCoreFields.m_viewportDensityDpi, "Unable to find android/webkit/WebViewCore.mViewportDensityDpi"); - gWebViewCoreFields.m_webView = env->GetFieldID(widget, - "mWebView", "Landroid/webkit/WebViewClassic;"); - ALOG_ASSERT(gWebViewCoreFields.m_webView, - "Unable to find android/webkit/WebViewCore.mWebView"); gWebViewCoreFields.m_drawIsPaused = env->GetFieldID(widget, "mDrawIsPaused", "Z"); ALOG_ASSERT(gWebViewCoreFields.m_drawIsPaused, diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp index d0af1a5..09bb24e 100644 --- a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -160,7 +160,8 @@ bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { if (model == kOpenGL_ANPDrawingModel && m_layer == 0) { jobject webview = m_core->getWebViewJavaObject(); - m_layer = new WebCore::MediaLayer(webview); + AutoJObject webViewCore = m_core->getJavaObject(); + m_layer = new WebCore::MediaLayer(webview, webViewCore.get()); } else if (model != kOpenGL_ANPDrawingModel && m_layer != 0) { m_layer->unref(); |