summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2009-08-10 10:26:04 -0400
committerDerek Sollenberger <djsollen@google.com>2009-08-10 10:31:14 -0400
commit3ac4dcc7e27db648f597d2062fd84997544165f1 (patch)
treeaa9c5d1263302ab7534ceecd29482acb42d3d548
parent57a5d7d6714b40f0cdf8b5ec0fe4780c87716e94 (diff)
downloadexternal_webkit-3ac4dcc7e27db648f597d2062fd84997544165f1.zip
external_webkit-3ac4dcc7e27db648f597d2062fd84997544165f1.tar.gz
external_webkit-3ac4dcc7e27db648f597d2062fd84997544165f1.tar.bz2
modifying the android_npapi.h to accomodate surfaces with different pixel formats.
-rw-r--r--WebKit/android/jni/WebViewCore.cpp7
-rw-r--r--WebKit/android/jni/WebViewCore.h3
-rw-r--r--WebKit/android/plugins/ANPSurfaceInterface.cpp24
-rw-r--r--WebKit/android/plugins/PluginSurface.cpp39
-rw-r--r--WebKit/android/plugins/PluginSurface.h9
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.cpp7
-rw-r--r--WebKit/android/plugins/PluginWidgetAndroid.h4
-rw-r--r--WebKit/android/plugins/android_npapi.h14
8 files changed, 55 insertions, 52 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index e743eff..973e317 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -254,7 +254,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_geolocationPermissionsShowPrompt = GetJMethod(env, clazz, "geolocationPermissionsShowPrompt", "(Ljava/lang/String;)V");
m_javaGlue->m_geolocationPermissionsHidePrompt = GetJMethod(env, clazz, "geolocationPermissionsHidePrompt", "()V");
m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V");
- m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(IZ)Landroid/view/SurfaceView;");
+ m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(IIZ)Landroid/view/SurfaceView;");
m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/view/SurfaceView;)V");
m_javaGlue->m_attachSurface = GetJMethod(env, clazz, "attachSurface", "(Landroid/view/SurfaceView;IIII)V");
@@ -2095,11 +2095,12 @@ void WebViewCore::setBackgroundColor(SkColor c)
view->setBaseBackgroundColor(bcolor);
}
-jobject WebViewCore::createSurface(SurfaceCallback* cb, bool isFixedSize)
+jobject WebViewCore::createSurface(SurfaceCallback* cb, PixelFormat format,
+ bool isFixedSize)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
jobject surface = env->CallObjectMethod(m_javaGlue->object(env).get(),
- m_javaGlue->m_createSurface, (int) cb, isFixedSize);
+ m_javaGlue->m_createSurface, (int) cb, (int) format, isFixedSize);
checkException(env);
return surface;
}
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index f763ee5..22e00e2 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -39,6 +39,7 @@
#include "WebCoreJni.h"
#include <jni.h>
#include <ui/KeycodeLabels.h>
+#include <ui/PixelFormat.h>
namespace WebCore {
class AtomicString;
@@ -345,7 +346,7 @@ namespace android {
void requestKeyboard(bool);
// Creates a SurfaceView for a plugin
- jobject createSurface(SurfaceCallback* cb, bool isFixedSize);
+ jobject createSurface(SurfaceCallback* cb, PixelFormat format, bool isFixedSize);
// Destroys the SurfaceView after removing from the view system.
void destroySurface(jobject surface);
diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp
index 20df7f8..a96220f 100644
--- a/WebKit/android/plugins/ANPSurfaceInterface.cpp
+++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp
@@ -33,11 +33,12 @@
using namespace WebCore;
-static ANPSurface* anp_newSurface(NPP instance, ANPSurfaceType type, bool fixedSize) {
+static ANPSurface* anp_newRasterSurface(NPP instance, ANPBitmapFormat format,
+ bool fixedSize) {
if (instance && instance->ndata) {
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginWidgetAndroid* widget = view->platformPluginWidget();
- return widget->createSurface(type, fixedSize);
+ return widget->createRasterSurface(format, fixedSize);
}
return NULL;
}
@@ -53,23 +54,12 @@ static void anp_deleteSurface(ANPSurface* surface) {
}
}
-static bool anp_lock(ANPSurface* surface, ANPBitmap* bitmap,
- ANPRectI* dirtyRect) {
+static bool anp_lock(ANPSurface* surface, ANPBitmap* bitmap, ANPRectI* dirtyRect) {
if (bitmap && surface && surface->data) {
android::PluginSurface* s =
static_cast<android::PluginSurface*>(surface->data);
- SkBitmap src;
- bool res = false;
- if (dirtyRect) {
- SkIRect rect;
- res = s->lock(SkANP::SetRect(&rect, *dirtyRect), &src);
- } else {
- res = s->lock(NULL, &src);
- }
- if (res) {
- res &= SkANP::SetBitmap(bitmap, src);
- }
- return res;
+
+ return s->lock(dirtyRect, bitmap);
}
return false;
}
@@ -89,7 +79,7 @@ static void anp_unlock(ANPSurface* surface) {
void ANPSurfaceInterfaceV0_Init(ANPInterface* value) {
ANPSurfaceInterfaceV0* i = reinterpret_cast<ANPSurfaceInterfaceV0*>(value);
- ASSIGN(i, newSurface);
+ ASSIGN(i, newRasterSurface);
ASSIGN(i, deleteSurface);
ASSIGN(i, lock);
ASSIGN(i, unlock);
diff --git a/WebKit/android/plugins/PluginSurface.cpp b/WebKit/android/plugins/PluginSurface.cpp
index c5bd74a..451ceee 100644
--- a/WebKit/android/plugins/PluginSurface.cpp
+++ b/WebKit/android/plugins/PluginSurface.cpp
@@ -68,21 +68,28 @@ static inline sp<Surface> getSurface(jobject view) {
return sp<Surface>((Surface*) env->GetIntField(surface, gSurfaceField));
}
-static inline SkBitmap::Config convertPixelFormat(PixelFormat format) {
+static inline ANPBitmapFormat convertPixelFormat(PixelFormat format) {
switch (format) {
- case PIXEL_FORMAT_RGBA_8888: return SkBitmap::kARGB_8888_Config;
- case PIXEL_FORMAT_RGBA_4444: return SkBitmap::kARGB_4444_Config;
- case PIXEL_FORMAT_RGB_565: return SkBitmap::kRGB_565_Config;
- case PIXEL_FORMAT_A_8: return SkBitmap::kA8_Config;
- default: return SkBitmap::kNo_Config;
+ case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_ANPBitmapFormat;
+ case PIXEL_FORMAT_RGB_565: return kRGB_565_ANPBitmapFormat;
+ default: return kUnknown_ANPBitmapFormat;
}
}
-PluginSurface::PluginSurface(PluginWidgetAndroid* widget, bool isFixedSize)
+static inline PixelFormat convertANPBitmapFormat(ANPBitmapFormat format) {
+ switch (format) {
+ case kRGBA_8888_ANPBitmapFormat: return PIXEL_FORMAT_RGBA_8888;
+ case kRGB_565_ANPBitmapFormat: return PIXEL_FORMAT_RGB_565;
+ default: return PIXEL_FORMAT_UNKNOWN;
+ }
+}
+
+PluginSurface::PluginSurface(PluginWidgetAndroid* widget, ANPBitmapFormat format,
+ bool isFixedSize)
: m_jSurfaceView(0)
, m_widget(widget) {
// Create our java SurfaceView.
- jobject obj = widget->webViewCore()->createSurface(this, isFixedSize);
+ jobject obj = widget->webViewCore()->createSurface(this, convertANPBitmapFormat(format), isFixedSize);
if (obj) {
JNIEnv* env = JSC::Bindings::getJNIEnv();
m_jSurfaceView = env->NewGlobalRef(obj);
@@ -107,14 +114,14 @@ void PluginSurface::destroy() {
}
}
-bool PluginSurface::lock(SkIRect* dirty, SkBitmap* bitmap) {
+bool PluginSurface::lock(ANPRectI* dirty, ANPBitmap* bitmap) {
if (!bitmap || !Surface::isValid(m_surface)) {
return false;
}
Region dirtyRegion;
if (dirty) {
- Rect rect(dirty->fLeft, dirty->fTop, dirty->fRight, dirty->fBottom);
+ Rect rect(dirty->left, dirty->top, dirty->right, dirty->bottom);
if (!rect.isEmpty()) {
dirtyRegion.set(rect);
}
@@ -129,11 +136,17 @@ bool PluginSurface::lock(SkIRect* dirty, SkBitmap* bitmap) {
}
ssize_t bpr = info.s * bytesPerPixel(info.format);
- bitmap->setConfig(convertPixelFormat(info.format), info.w, info.h, bpr);
+
+ bitmap->format = convertPixelFormat(info.format);
+ bitmap->width = info.w;
+ bitmap->height = info.h;
+ bitmap->rowBytes = bpr;
+
if (info.w > 0 && info.h > 0) {
- bitmap->setPixels(info.bits);
+ bitmap->baseAddr = info.bits;
} else {
- bitmap->setPixels(NULL);
+ bitmap->baseAddr = NULL;
+ return false;
}
return true;
diff --git a/WebKit/android/plugins/PluginSurface.h b/WebKit/android/plugins/PluginSurface.h
index 2b2b57a..893f698 100644
--- a/WebKit/android/plugins/PluginSurface.h
+++ b/WebKit/android/plugins/PluginSurface.h
@@ -39,6 +39,11 @@ struct PluginWidgetAndroid;
class SkBitmap;
struct SkIRect;
+enum ANPSurfaceTypes {
+ kRaster_ANPSurfaceType = 0
+};
+typedef int32_t ANPSurfaceType;
+
struct ANPSurface {
void* data;
ANPSurfaceType type;
@@ -50,14 +55,14 @@ class Surface;
class PluginSurface : public SurfaceCallback {
public:
- PluginSurface(PluginWidgetAndroid* widget, bool isFixedSize);
+ PluginSurface(PluginWidgetAndroid* widget, ANPBitmapFormat format, bool isFixedSize);
virtual ~PluginSurface() {
destroy();
}
void attach(int x, int y, int width, int height);
void destroy();
- bool lock(SkIRect* dirty, SkBitmap* bitmap);
+ bool lock(ANPRectI* dirty, ANPBitmap* bitmap);
void unlock();
virtual void surfaceCreated();
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp
index f1f0a15..60d7058 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -210,14 +210,15 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) {
return m_eventFlags & flag;
}
-ANPSurface* PluginWidgetAndroid::createSurface(ANPSurfaceType ignored, bool fixedSize) {
+ANPSurface* PluginWidgetAndroid::createRasterSurface(ANPBitmapFormat format,
+ bool fixedSize) {
if (m_drawingModel != kSurface_ANPDrawingModel) {
return NULL;
}
- m_surface.set(new android::PluginSurface(this, fixedSize));
+ m_surface.set(new android::PluginSurface(this, format, fixedSize));
ANPSurface* surface = new ANPSurface;
surface->data = m_surface.get();
- surface->type = ignored;
+ surface->type = kRaster_ANPSurfaceType;
return surface;
}
diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h
index 72e6660..d1575d7 100644
--- a/WebKit/android/plugins/PluginWidgetAndroid.h
+++ b/WebKit/android/plugins/PluginWidgetAndroid.h
@@ -111,13 +111,13 @@ struct PluginWidgetAndroid {
bool isAcceptingEvent(ANPEventFlag);
/* Create an ANPSurface that the plugin may draw in to. The drawing model
- must be kSurface_ANPDrawingModel for this call to succeed. The type
+ must be kSurface_ANPDrawingModel for this call to succeed. The format
specifies what kind of pixel access will be available. If true the
fixedSize param signals that the browser will auto-scale the surface for
the plugin (e.g. in the case of zooming). If false the surface will be
resized when zoomed and the plugin must manually scale to the new size.
*/
- ANPSurface* createSurface(ANPSurfaceType type, bool fixedSize);
+ ANPSurface* createRasterSurface(ANPBitmapFormat format, bool fixedSize);
/* Notify the plugin of the currently visible screen coordinates (document
space) and the current zoom level.
diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h
index 71890ea..0ab3879 100644
--- a/WebKit/android/plugins/android_npapi.h
+++ b/WebKit/android/plugins/android_npapi.h
@@ -200,24 +200,16 @@ struct ANPBitmapInterfaceV0 : ANPInterface {
bool (*getPixelPacking)(ANPBitmapFormat, ANPPixelPacking* packing);
};
-/** The surfaceType is the mechanism by which the plugin informs the native
- libraries which type of surface view it wishes to use.
- */
-enum ANPSurfaceTypes {
- kRGBA_ANPSurfaceType = 0
-};
-typedef int32_t ANPSurfaceType;
-
/** The ANPSurface acts as a handle between the plugin and the native libraries
that render the surface to the screen.
*/
struct ANPSurface;
struct ANPSurfaceInterfaceV0 : ANPInterface {
- /** Creates a new surface handle based on the given surface type. If the
- given surface type is not supported then NULL is returned.
+ /** Creates a new raster surface handle based on the given bitmap format. If
+ raster surfaces or the bitmap format is not supported then NULL is returned.
*/
- ANPSurface* (*newSurface)(NPP instance, ANPSurfaceType, bool fixedSize);
+ ANPSurface* (*newRasterSurface)(NPP instance, ANPBitmapFormat, bool fixedSize);
/** Given a valid surface handle (i.e. one created by calling newSurface)
the underlying surface is removed and the pointer is set to NULL.
*/