summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/Android.mk1
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp12
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.h1
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp7
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h7
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.cpp89
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.h70
-rw-r--r--WebCore/platform/graphics/android/SharedTexture.cpp21
-rw-r--r--WebCore/plugins/PluginView.h2
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp8
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/plugins/ANPOpenGLInterface.cpp97
-rw-r--r--WebKit/android/plugins/ANPOpenGL_npapi.h57
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp26
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h7
-rw-r--r--WebKit/android/plugins/android_npapi.h6
16 files changed, 404 insertions, 8 deletions
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 7262336..d67aa34 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -612,6 +612,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ImageSourceAndroid.cpp \
platform/graphics/android/LayerAndroid.cpp \
platform/graphics/android/LayerTexture.cpp \
+ platform/graphics/android/MediaLayer.cpp \
platform/graphics/android/PaintLayerOperation.cpp \
platform/graphics/android/PathAndroid.cpp \
platform/graphics/android/PatternAndroid.cpp \
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 1efbecc..2fa1215 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -751,6 +751,18 @@ void GraphicsLayerAndroid::setContentsToImage(Image* image)
}
}
+void GraphicsLayerAndroid::setContentsToMedia(PlatformLayer* mediaLayer)
+{
+ if (m_contentLayer != mediaLayer) {
+ m_contentLayer->unref();
+ m_contentLayer = mediaLayer;
+ m_contentLayer->ref();
+ setNeedsDisplay();
+ }
+
+ askForSync();
+}
+
PlatformLayer* GraphicsLayerAndroid::platformLayer() const
{
LOG("platformLayer");
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index a243d65..ce6bac1 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -100,6 +100,7 @@ public:
virtual void resumeAnimations();
virtual void setContentsToImage(Image*);
+ virtual void setContentsToMedia(PlatformLayer*);
virtual PlatformLayer* platformLayer() const;
void pauseDisplay(bool state);
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 69822b5..b62575f 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -14,6 +14,7 @@
#include "SkPaint.h"
#include "SkPicture.h"
#include "TilesManager.h"
+#include "MediaLayer.h"
#include <wtf/CurrentTime.h>
#define LAYER_DEBUG // Add diagonals for debugging
@@ -619,6 +620,12 @@ bool LayerAndroid::drawGL(SkMatrix& matrix)
m_texture->consumerRelease();
}
+ return drawChildrenGL(matrix);
+}
+
+
+bool LayerAndroid::drawChildrenGL(SkMatrix& matrix)
+{
bool askPaint = false;
int count = this->countChildren();
if (count > 0) {
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 3d1c5af..fb6c4c7 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -112,8 +112,9 @@ public:
bool needsTexture();
void checkForObsolescence();
- bool drawGL(SkMatrix&);
- void paintBitmapGL();
+ virtual bool drawGL(SkMatrix&);
+ bool drawChildrenGL(SkMatrix&);
+ virtual void paintBitmapGL();
void updateGLPositions(const TransformationMatrix& parentMatrix, float opacity);
void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
@@ -223,6 +224,8 @@ public:
unsigned int pictureUsed() { return m_pictureUsed; }
void contentDraw(SkCanvas*);
+ virtual bool isMedia() const { return false; }
+
protected:
virtual void onDraw(SkCanvas*, SkScalar opacity);
diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp
new file mode 100644
index 0000000..9c370a5
--- /dev/null
+++ b/WebCore/platform/graphics/android/MediaLayer.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "config.h"
+#include "MediaLayer.h"
+#include "TilesManager.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include <wtf/CurrentTime.h>
+
+#define LAYER_DEBUG
+#undef LAYER_DEBUG
+
+#ifdef DEBUG
+
+#include <cutils/log.h>
+#include <wtf/text/CString.h>
+
+#undef XLOG
+#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "MediaLayer", __VA_ARGS__)
+
+#else
+
+#undef XLOG
+#define XLOG(...)
+
+#endif // DEBUG
+
+namespace WebCore {
+
+MediaLayer::MediaLayer() : LayerAndroid(false)
+{
+ m_bufferedTexture = new MediaTexture(EGL_NO_CONTEXT);
+ m_bufferedTexture->incStrong(this);
+ m_currentTextureInfo = 0;
+ XLOG("Creating Media Layer %p", this);
+}
+
+MediaLayer::MediaLayer(const MediaLayer& layer) : LayerAndroid(layer)
+{
+ m_bufferedTexture = layer.getTexture();
+ m_bufferedTexture->incStrong(this);
+ m_currentTextureInfo = 0;
+ XLOG("Creating Media Layer Copy %p -> %p", &layer, this);
+}
+
+MediaLayer::~MediaLayer()
+{
+ XLOG("Deleting Media Layer");
+ m_bufferedTexture->decStrong(this);
+}
+
+bool MediaLayer::drawGL(SkMatrix& matrix)
+{
+ if (m_bufferedTexture) {
+ TextureInfo* textureInfo = m_bufferedTexture->consumerLock();
+ if (textureInfo) {
+ SkRect rect;
+ rect.set(0, 0, getSize().width(), getSize().height());
+ TransformationMatrix m = drawTransform();
+ TilesManager::instance()->shader()->drawLayerQuad(m, rect,
+ textureInfo->m_textureId,
+ 1.0f); //TODO fix this m_drawOpacity
+ }
+ m_bufferedTexture->consumerRelease();
+ }
+
+ drawChildrenGL(matrix);
+
+ //TODO allow plugins to specify when they should be drawn
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/android/MediaLayer.h b/WebCore/platform/graphics/android/MediaLayer.h
new file mode 100644
index 0000000..2ff3197
--- /dev/null
+++ b/WebCore/platform/graphics/android/MediaLayer.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MediaLayer_h
+#define MediaLayer_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "RefPtr.h"
+#include "DoubleBufferedTexture.h"
+#include "LayerAndroid.h"
+#include <utils/RefBase.h>
+
+
+namespace WebCore {
+
+class MediaTexture : public DoubleBufferedTexture,
+ public android::LightRefBase<MediaTexture> {
+
+public:
+ MediaTexture(EGLContext sharedContext) : DoubleBufferedTexture(sharedContext) { };
+};
+
+
+class MediaLayer : public LayerAndroid {
+
+public:
+ MediaLayer();
+ MediaLayer(const MediaLayer& layer);
+ virtual ~MediaLayer();
+
+ virtual bool drawGL(SkMatrix&);
+ virtual void paintBitmapGL() const { };
+
+ virtual bool isMedia() const { return true; }
+ virtual LayerAndroid* copy() const { return new MediaLayer(*this); }
+
+ MediaTexture* getTexture() const { return m_bufferedTexture; }
+
+ void setCurrentTextureInfo(TextureInfo* info) { m_currentTextureInfo = info; }
+ TextureInfo* getCurrentTextureInfo() const { return m_currentTextureInfo; }
+
+
+private:
+
+ // GL textures management
+ MediaTexture* m_bufferedTexture;
+
+ TextureInfo* m_currentTextureInfo;
+
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // MediaLayer_h
diff --git a/WebCore/platform/graphics/android/SharedTexture.cpp b/WebCore/platform/graphics/android/SharedTexture.cpp
index 76d6da0..41b4af1 100644
--- a/WebCore/platform/graphics/android/SharedTexture.cpp
+++ b/WebCore/platform/graphics/android/SharedTexture.cpp
@@ -63,17 +63,16 @@ bool TextureInfo::operator==(const TextureInfo& otherTexture)
SharedTexture::SharedTexture()
{
- m_display = eglGetCurrentDisplay();
m_eglImage = EGL_NO_IMAGE_KHR;
m_isNewImage = true;
m_syncObject = EGL_NO_SYNC_KHR;
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
- m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported();
- // TODO temporarily disable fence sync until nvidia implementation is complete
+ // Defer initialization of these values until we initialize the source
+ // texture. This ensures that this initialization happens in the appropriate
+ // thread.
+ m_display = 0;
+ m_supportsEGLImage = false;
m_supportsEGLFenceSyncKHR = false;
-
- LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR);
}
// called by the consumer when it no longer wants to consume and after it has
@@ -90,6 +89,16 @@ SharedTexture::~SharedTexture()
void SharedTexture::initSourceTexture()
{
+
+ m_display = eglGetCurrentDisplay();
+ m_supportsEGLImage = GLUtils::isEGLImageSupported();
+ m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported();
+
+ //TODO temporarily disable fence sync until nvidia implementation is complete
+ m_supportsEGLFenceSyncKHR = false;
+
+ LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR);
+
glGenTextures(1, &m_sourceTexture.m_textureId);
}
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 68325cd..2ecdc51 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -276,6 +276,8 @@ namespace WebCore {
#if USE(ACCELERATED_COMPOSITING)
#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && PLATFORM(QT)
virtual PlatformLayer* platformLayer() const;
+#elif ENABLE(NETSCAPE_PLUGIN_API) && defined(ANDROID_PLUGINS)
+ virtual PlatformLayer* platformLayer() const;
#else
virtual PlatformLayer* platformLayer() const { return 0; }
#endif
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index f0890ae..68fa3d7 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -83,6 +83,7 @@
#include "PluginWidgetAndroid.h"
#include "android_npapi.h"
+#include "ANPOpenGL_npapi.h"
#include "ANPSurface_npapi.h"
#include "ANPSystem_npapi.h"
#include "SkANP.h"
@@ -104,6 +105,7 @@ extern void ANPSurfaceInterfaceV0_Init(ANPInterface* value);
extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value);
extern void ANPWindowInterfaceV0_Init(ANPInterface* value);
extern void ANPSystemInterfaceV0_Init(ANPInterface* value);
+extern void ANPOpenGLInterfaceV0_Init(ANPInterface* value);
struct VarProcPair {
int enumValue;
@@ -128,6 +130,7 @@ static const VarProcPair gVarProcs[] = {
{ VARPROCLINE(TypefaceInterfaceV0) },
{ VARPROCLINE(WindowInterfaceV0) },
{ VARPROCLINE(SystemInterfaceV0) },
+ { VARPROCLINE(OpenGLInterfaceV0) },
};
/* return true if var was an interface request (error will be set accordingly)
@@ -187,6 +190,11 @@ void PluginView::platformDestroy()
delete m_window;
}
+PlatformLayer* PluginView::platformLayer() const
+{
+ return (PlatformLayer*) m_window->getLayer();
+}
+
#if ENABLE(TOUCH_EVENTS)
void PluginView::handleTouchEvent(TouchEvent* event)
{
diff --git a/WebKit/Android.mk b/WebKit/Android.mk
index 510fb4e..f8ecd56 100644
--- a/WebKit/Android.mk
+++ b/WebKit/Android.mk
@@ -98,6 +98,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
android/plugins/ANPEventInterface.cpp \
android/plugins/ANPLogInterface.cpp \
android/plugins/ANPMatrixInterface.cpp \
+ android/plugins/ANPOpenGLInterface.cpp \
android/plugins/ANPPaintInterface.cpp \
android/plugins/ANPPathInterface.cpp \
android/plugins/ANPSoundInterface.cpp \
diff --git a/WebKit/android/plugins/ANPOpenGLInterface.cpp b/WebKit/android/plugins/ANPOpenGLInterface.cpp
new file mode 100644
index 0000000..55eb3e0
--- /dev/null
+++ b/WebKit/android/plugins/ANPOpenGLInterface.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2010, 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 "ANPOpenGL_npapi.h"
+#include "PluginView.h"
+#include "PluginWidgetAndroid.h"
+#include "MediaLayer.h"
+
+using namespace android;
+
+static WebCore::PluginView* pluginViewForInstance(NPP instance) {
+ if (instance && instance->ndata)
+ return static_cast<WebCore::PluginView*>(instance->ndata);
+ return WebCore::PluginView::currentPluginView();
+}
+
+static EGLContext anp_acquireContext(NPP instance) {
+ WebCore::PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+ WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer();
+
+ if (!mediaLayer)
+ return EGL_NO_CONTEXT;
+
+ return mediaLayer->getTexture()->producerAcquireContext();
+}
+
+static ANPTextureInfo anp_lockTexture(NPP instance) {
+ WebCore::PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+ WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer();
+ WebCore::DoubleBufferedTexture* texture = mediaLayer->getTexture();
+
+ // lock the texture and cache the internal info
+ WebCore::TextureInfo* info = texture->producerLock();
+ mediaLayer->setCurrentTextureInfo(info);
+
+ ANPTextureInfo anpInfo;
+ anpInfo.textureId = info->m_textureId;
+ anpInfo.width = info->m_width;
+ anpInfo.height = info->m_height;
+ anpInfo.internalFormat = info->m_internalFormat;
+ return anpInfo;
+}
+
+static void anp_releaseTexture(NPP instance, const ANPTextureInfo* textureInfo) {
+ WebCore::PluginView* pluginView = pluginViewForInstance(instance);
+ PluginWidgetAndroid* pluginWidget = pluginView->platformPluginWidget();
+ WebCore::MediaLayer* mediaLayer = pluginWidget->getLayer();
+ WebCore::DoubleBufferedTexture* texture = mediaLayer->getTexture();
+
+ //copy the info into our internal structure
+ WebCore::TextureInfo* info = mediaLayer->getCurrentTextureInfo();
+ info->m_textureId = textureInfo->textureId;
+ info->m_width = textureInfo->width;
+ info->m_height = textureInfo->height;
+ info->m_internalFormat = textureInfo->internalFormat;
+
+ texture->producerReleaseAndSwap();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define ASSIGN(obj, name) (obj)->name = anp_##name
+
+void ANPOpenGLInterfaceV0_Init(ANPInterface* v) {
+ ANPOpenGLInterfaceV0* i = reinterpret_cast<ANPOpenGLInterfaceV0*>(v);
+
+ ASSIGN(i, acquireContext);
+ ASSIGN(i, lockTexture);
+ ASSIGN(i, releaseTexture);
+}
diff --git a/WebKit/android/plugins/ANPOpenGL_npapi.h b/WebKit/android/plugins/ANPOpenGL_npapi.h
new file mode 100644
index 0000000..bfca0dd
--- /dev/null
+++ b/WebKit/android/plugins/ANPOpenGL_npapi.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010, 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 ANPOpenGL_npapi_H
+#define ANPOpenGL_npapi_H
+
+#include "android_npapi.h"
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+
+/**
+ * TODO should we not use EGL and GL data types for ABI safety?
+ */
+struct ANPTextureInfo {
+ GLuint textureId;
+ uint32_t width;
+ uint32_t height;
+ GLenum internalFormat;
+};
+
+struct ANPOpenGLInterfaceV0 : ANPInterface {
+ /**
+ */
+ EGLContext (*acquireContext)(NPP instance);
+
+ /**
+ */
+ ANPTextureInfo (*lockTexture)(NPP instance);
+
+ /**
+ */
+ void (*releaseTexture)(NPP instance, const ANPTextureInfo*);
+};
+
+#endif //ANPOpenGL_npapi_H
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index b90b53b..83bc8cb 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -71,6 +71,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view)
m_embeddedViewAttached = false;
m_acceptEvents = false;
m_isSurfaceClippedOut = false;
+ m_layer = 0;
}
PluginWidgetAndroid::~PluginWidgetAndroid() {
@@ -93,6 +94,9 @@ PluginWidgetAndroid::~PluginWidgetAndroid() {
}
m_flipPixelRef->safeUnref();
+
+ if (m_layer)
+ m_layer->unref();
}
void PluginWidgetAndroid::init(android::WebViewCore* core) {
@@ -135,6 +139,17 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {
}
bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) {
+
+ if (model == kOpenGL_ANPDrawingModel && m_layer == 0)
+ m_layer = new WebCore::MediaLayer();
+ else if (model != kOpenGL_ANPDrawingModel && m_layer != 0)
+ m_layer->unref();
+
+ if (m_drawingModel != model) {
+ // Trigger layer computation in RenderLayerCompositor
+ m_pluginView->getElement()->setNeedsStyleRecalc(SyntheticStyleChange);
+ }
+
m_drawingModel = model;
return true;
}
@@ -347,6 +362,17 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float
#endif
// TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel)
+ // notify the plugin of the new size
+ // TODO what if the plugin changes sizes?
+ if (m_drawingModel == kOpenGL_ANPDrawingModel && m_zoomLevel != zoom) {
+ ANPEvent event;
+ SkANP::InitEvent(&event, kDraw_ANPEventType);
+ event.data.draw.model = kOpenGL_ANPDrawingModel;
+ event.data.draw.data.surface.width = m_pluginWindow->width * zoom;
+ event.data.draw.data.surface.height = m_pluginWindow->height * zoom;
+ sendEvent(event);
+ }
+
int oldScreenW = m_visibleDocRect.width();
int oldScreenH = m_visibleDocRect.height();
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 162fb1d..974fbf0 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -29,6 +29,7 @@
#include "android_npapi.h"
#include "IntPoint.h"
#include "IntRect.h"
+#include "MediaLayer.h"
#include "SkRect.h"
#include <jni.h>
@@ -79,6 +80,8 @@ struct PluginWidgetAndroid {
*/
bool isSurfaceDrawingModel() const { return kSurface_ANPDrawingModel == m_drawingModel; }
+ bool isOpenGLDrawingModel() const { return kOpenGL_ANPDrawingModel == m_drawingModel; }
+
/* Returns true (and optionally updates rect with the dirty bounds in the
page coordinate) if the plugin has invalidate us.
*/
@@ -163,10 +166,14 @@ struct PluginWidgetAndroid {
*/
void requestCenterFitZoom();
+ WebCore::MediaLayer* getLayer() const { return m_layer; }
+
private:
void computeVisiblePluginRect();
void scrollToVisiblePluginRect();
+ WebCore::MediaLayer* m_layer;
+
WebCore::PluginView* m_pluginView;
android::WebViewCore* m_core;
SkFlipPixelRef* m_flipPixelRef;
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 87ca8cc..a99666e 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -121,6 +121,7 @@ typedef uint32_t ANPMatrixFlag;
#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011)
#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012)
+#define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013)
/** queries for the drawing models supported on this device.
@@ -182,6 +183,7 @@ enum ANPDrawingModels {
surface object.
*/
kSurface_ANPDrawingModel = 1 << 1,
+ kOpenGL_ANPDrawingModel = 1 << 2,
};
typedef int32_t ANPDrawingModel;
@@ -929,6 +931,10 @@ struct ANPEvent {
// use based on the value in model
union {
ANPBitmap bitmap;
+ struct {
+ int32_t width;
+ int32_t height;
+ } surface;
} data;
} draw;
int32_t other[8];