summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-10-10 13:28:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-10 13:28:07 -0700
commit8242049005e7219ea9846eff8eff3cead8e2461e (patch)
tree064fdc9dedcded63e950dfe4a184548e92921c2a
parent62e2515c022e538e62d28aa1bc7ee4986a64a2a4 (diff)
parent12831797a65a96977bbb6e066cc5d258e04e2161 (diff)
downloadexternal_webkit-8242049005e7219ea9846eff8eff3cead8e2461e.zip
external_webkit-8242049005e7219ea9846eff8eff3cead8e2461e.tar.gz
external_webkit-8242049005e7219ea9846eff8eff3cead8e2461e.tar.bz2
Merge "Delay sending Plugin Draw event until the surface is ready."
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp18
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp18
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h3
-rw-r--r--Source/WebKit/android/plugins/PluginWidgetAndroid.cpp17
-rw-r--r--Source/WebKit/android/plugins/PluginWidgetAndroid.h3
5 files changed, 58 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index 1a5e2cc..e12518e 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -96,6 +96,21 @@ void MediaTexture::initNativeWindowIfNeeded()
// create a content texture if none exists
if (!m_contentTexture) {
m_contentTexture = createTexture();
+
+ // send a message to the WebKit thread to notify the plugin that it can draw
+ if (m_weakWebViewRef) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ jobject localWebViewRef = env->NewLocalRef(m_weakWebViewRef);
+ if (localWebViewRef) {
+ jclass wvClass = env->GetObjectClass(localWebViewRef);
+ jmethodID sendPluginDrawMsg =
+ env->GetMethodID(wvClass, "sendPluginDrawMsg", "()V");
+ env->CallVoidMethod(localWebViewRef, sendPluginDrawMsg);
+ env->DeleteLocalRef(wvClass);
+ env->DeleteLocalRef(localWebViewRef);
+ }
+ checkException(env);
+ }
}
// finally create a video texture if needed
@@ -110,6 +125,8 @@ void MediaTexture::initNativeWindowIfNeeded()
m_newWindowRequest = false;
m_newWindow = videoTexture->nativeWindow;
}
+
+ // signal the WebKit thread in case it is waiting
m_newMediaRequestCond.signal();
}
@@ -253,6 +270,7 @@ void MediaTexture::setDimensions(const ANativeWindow* window,
void MediaTexture::setFramerateCallback(const ANativeWindow* window,
FramerateCallbackProc callback)
{
+ XLOG("Release ANW %p (%p):(%p)", this, m_surfaceTexture.get(), m_surfaceTextureClient.get());
android::Mutex::Autolock lock(m_mediaLock);
for (unsigned int i = 0; i < m_videoTextures.size(); i++) {
if (m_videoTextures[i]->nativeWindow.get() == window) {
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 527d596..17a8bc5 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -2044,6 +2044,15 @@ void WebViewCore::sendPluginVisibleScreen()
}
}
+void WebViewCore::sendPluginSurfaceReady()
+{
+ PluginWidgetAndroid** iter = m_plugins.begin();
+ PluginWidgetAndroid** stop = m_plugins.end();
+ for (; iter < stop; ++iter) {
+ (*iter)->checkSurfaceReady();
+ }
+}
+
void WebViewCore::sendPluginEvent(const ANPEvent& evt)
{
/* The list of plugins may be manipulated as we iterate through the list.
@@ -4544,6 +4553,13 @@ static void ProvideVisitedHistory(JNIEnv *env, jobject obj, jobject hist)
}
}
+static void PluginSurfaceReady(JNIEnv* env, jobject obj)
+{
+ WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
+ if (viewImpl)
+ viewImpl->sendPluginSurfaceReady();
+}
+
// Notification from the UI thread that the plugin's full-screen surface has been discarded
static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp)
{
@@ -4740,6 +4756,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) ProvideVisitedHistory },
{ "nativeFullScreenPluginHidden", "(I)V",
(void*) FullScreenPluginHidden },
+ { "nativePluginSurfaceReady", "()V",
+ (void*) PluginSurfaceReady },
{ "nativeValidNodeAndBounds", "(IILandroid/graphics/Rect;)Z",
(void*) ValidNodeAndBounds },
{ "nativeGetTouchHighlightRects", "(III)Ljava/util/ArrayList;",
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 6d65957..491a0ad 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -444,6 +444,9 @@ namespace android {
// send the current screen size/zoom to all of the plugins in our list
void sendPluginVisibleScreen();
+ // notify plugin that a new drawing surface was created in the UI thread
+ void sendPluginSurfaceReady();
+
// send onLoad event to plugins who are descendents of the given frame
void notifyPluginsOnFrameLoad(const Frame*);
diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
index 761e948..fc98837 100644
--- a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -76,6 +76,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_layer = 0;
m_powerState = kDefault_ANPPowerState;
m_fullScreenOrientation = -1;
+ m_drawEventDelayed = false;
}
PluginWidgetAndroid::~PluginWidgetAndroid() {
@@ -175,6 +176,14 @@ bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) {
return true;
}
+void PluginWidgetAndroid::checkSurfaceReady() {
+ if(!m_drawEventDelayed)
+ return;
+
+ m_drawEventDelayed = false;
+ sendSizeAndVisibilityEvents(true);
+}
+
// returned rect is in the page coordinate
bool PluginWidgetAndroid::isDirty(SkIRect* rect) const {
// nothing to report if we haven't had setWindow() called yet
@@ -382,8 +391,14 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) {
}
void PluginWidgetAndroid::sendSizeAndVisibilityEvents(const bool updateDimensions) {
- // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel)
+ if (m_drawingModel == kOpenGL_ANPDrawingModel &&
+ !m_layer->acquireNativeWindowForContent()) {
+ m_drawEventDelayed = true;
+ return;
+ }
+
+ // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel)
const float zoomLevel = m_core->scale();
// notify the plugin of the new size
diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.h b/Source/WebKit/android/plugins/PluginWidgetAndroid.h
index 0e4cf7e..87612dd 100644
--- a/Source/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -83,6 +83,8 @@ struct PluginWidgetAndroid {
bool isOpenGLDrawingModel() const { return kOpenGL_ANPDrawingModel == m_drawingModel; }
+ void checkSurfaceReady();
+
/* Returns true (and optionally updates rect with the dirty bounds in the
page coordinate) if the plugin has invalidate us.
*/
@@ -207,6 +209,7 @@ private:
bool m_isSurfaceClippedOut;
ANPPowerState m_powerState;
int m_fullScreenOrientation;
+ bool m_drawEventDelayed;
/* We limit the number of rectangles to minimize storage and ensure adequate
speed.