summaryrefslogtreecommitdiffstats
path: root/WebKit/android/plugins
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-01-25 18:02:00 -0500
committerDerek Sollenberger <djsollen@google.com>2011-01-26 18:27:07 -0500
commit136290ef021ff9a9bf9152124a5fa42069acfdfc (patch)
tree763219807011b9f4442e72e25f44bede0a2683fa /WebKit/android/plugins
parent9d071845bbad7f9b73a17de59ad8b564e6ce39e4 (diff)
downloadexternal_webkit-136290ef021ff9a9bf9152124a5fa42069acfdfc.zip
external_webkit-136290ef021ff9a9bf9152124a5fa42069acfdfc.tar.gz
external_webkit-136290ef021ff9a9bf9152124a5fa42069acfdfc.tar.bz2
Initial pass at a video API for plugins.
bug: 3072603 Change-Id: Ie22d289a93682dfd68cf81f5220d658d45a69d81
Diffstat (limited to 'WebKit/android/plugins')
-rw-r--r--WebKit/android/plugins/ANPVideoInterface.cpp83
-rw-r--r--WebKit/android/plugins/ANPVideo_npapi.h61
-rw-r--r--WebKit/android/plugins/android_npapi.h1
3 files changed, 145 insertions, 0 deletions
diff --git a/WebKit/android/plugins/ANPVideoInterface.cpp b/WebKit/android/plugins/ANPVideoInterface.cpp
new file mode 100644
index 0000000..8eb9846
--- /dev/null
+++ b/WebKit/android/plugins/ANPVideoInterface.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// must include config.h first for webkit to fiddle with new/delete
+#include "config.h"
+#include "ANPVideo_npapi.h"
+#include "SkANP.h"
+
+#include "PluginView.h"
+#include "PluginWidgetAndroid.h"
+#include "MediaLayer.h"
+
+static WebCore::PluginView* pluginViewForInstance(NPP instance) {
+ if (instance && instance->ndata)
+ return static_cast<WebCore::PluginView*>(instance->ndata);
+ return WebCore::PluginView::currentPluginView();
+}
+
+static WebCore::MediaLayer* mediaLayerForInstance(NPP instance) {
+ WebCore::PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+ return pluginWidget->getLayer();
+}
+
+static ANativeWindow* anp_acquireNativeWindow(NPP instance) {
+ WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance);
+
+ return mediaLayer->acquireNativeWindowForVideo();
+}
+
+static void anp_setWindowDimensions(NPP instance, const ANativeWindow* window,
+ const ANPRectF* dimensions) {
+
+ WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance);
+ if (!mediaLayer)
+ return;
+
+ SkRect rect;
+ mediaLayer->setWindowDimensionsForVideo(window, *SkANP::SetRect(&rect, *dimensions));
+}
+
+
+static void anp_releaseNativeWindow(NPP instance, ANativeWindow* window) {
+ WebCore::MediaLayer* mediaLayer = mediaLayerForInstance(instance);
+ if (!mediaLayer)
+ return;
+
+ mediaLayer->releaseNativeWindowForVideo(window);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define ASSIGN(obj, name) (obj)->name = anp_##name
+
+void ANPVideoInterfaceV0_Init(ANPInterface* value) {
+ ANPVideoInterfaceV0* i = reinterpret_cast<ANPVideoInterfaceV0*>(value);
+
+ ASSIGN(i, acquireNativeWindow);
+ ASSIGN(i, setWindowDimensions);
+ ASSIGN(i, releaseNativeWindow);
+}
diff --git a/WebKit/android/plugins/ANPVideo_npapi.h b/WebKit/android/plugins/ANPVideo_npapi.h
new file mode 100644
index 0000000..18e0231
--- /dev/null
+++ b/WebKit/android/plugins/ANPVideo_npapi.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ANPVideo_npapi_H
+#define ANPVideo_npapi_H
+
+#include "android_npapi.h"
+#include <android/native_window.h>
+
+struct ANPVideoInterfaceV0 : ANPInterface {
+
+ /**
+ * Constructs a new native window to be used for rendering video content.
+ *
+ * Subsequent calls will produce new windows, but may also return NULL after
+ * n attempts if the browser has reached it's limit. Further, if the browser
+ * is unable to acquire the window quickly it may also return NULL in order
+ * to not prevent the plugin from executing. A subsequent call will then
+ * return the window if it is avaiable.
+ *
+ * NOTE: The hardware may fail if you try to decode more than the allowable
+ * number of videos supported on that device.
+ */
+ ANativeWindow* (*acquireNativeWindow)(NPP instance);
+
+ /**
+ * Sets the rectangle that specifies where the video content is to be drawn.
+ * The dimensions are in document space. Further, if the rect is NULL the
+ * browser will not attempt to draw the window, therefore do not set the
+ * dimensions until you queue the first buffer in the window.
+ */
+ void (*setWindowDimensions)(NPP instance, const ANativeWindow* window, const ANPRectF* dimensions);
+
+ /**
+ */
+ void (*releaseNativeWindow)(NPP instance, ANativeWindow* window);
+};
+
+#endif //ANPVideo_npapi_H
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index a9993a5..dd2dd10 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -123,6 +123,7 @@ typedef uint32_t ANPMatrixFlag;
#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012)
#define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013)
#define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014)
+#define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015)
/** queries for the drawing models supported on this device.