diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:14:53 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:14:53 +0000 |
commit | f1002ee286ad56e2b80736661e89989b650aad6e (patch) | |
tree | e7f82831f9bccd51fa10ba0c6b28501a5ad83aaa /webkit | |
parent | 3ccfe535658c8852c1cc1df01372ecc602f376cd (diff) | |
download | chromium_src-f1002ee286ad56e2b80736661e89989b650aad6e.zip chromium_src-f1002ee286ad56e2b80736661e89989b650aad6e.tar.gz chromium_src-f1002ee286ad56e2b80736661e89989b650aad6e.tar.bz2 |
Revert 35649 - Make Pepper plugins work on Linux.
fix pepper_test_plugin so that it is loaded on Linux
remove skia & base dependency in test plugin so that it can be compiled with fPIC
remove ifdef WIN in pepper code
Patch by neb@chromium.org
Original review: http://codereview.chromium.org/501124/show
BUG=none
TEST=none
TBR=brettw@chromium.org
Review URL: http://codereview.chromium.org/524051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/pepper_test_plugin/event_handler.cc | 53 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/main.cc | 50 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp | 14 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/plugin_object.cc | 44 | ||||
-rw-r--r-- | webkit/tools/pepper_test_plugin/plugin_object.h | 10 |
5 files changed, 67 insertions, 104 deletions
diff --git a/webkit/tools/pepper_test_plugin/event_handler.cc b/webkit/tools/pepper_test_plugin/event_handler.cc index 65df790..7884fac 100644 --- a/webkit/tools/pepper_test_plugin/event_handler.cc +++ b/webkit/tools/pepper_test_plugin/event_handler.cc @@ -26,8 +26,11 @@ #include "webkit/tools/pepper_test_plugin/event_handler.h" #include <stdio.h> -#include <sstream> +#include <string> +#include "base/basictypes.h" +#include "base/logging.h" +#include "base/string_util.h" #include "webkit/tools/pepper_test_plugin/plugin_object.h" EventHandler* event_handler = NULL; @@ -55,10 +58,7 @@ void EventHandler::addText(const char* cstr) { } std::string EventHandler::EventName(double timestamp, int32 type) { - std::stringstream strstr; - strstr.setf(std::ios::fixed, std::ios::floatfield); - strstr << timestamp << ": "; - std::string str(strstr.str()); + std::string str = DoubleToString(timestamp) + ": "; switch (type) { case NPEventType_MouseDown: return str + "MouseDown"; @@ -94,43 +94,46 @@ std::string EventHandler::EventName(double timestamp, int32 type) { int EventHandler::handle(void* event) { NPPepperEvent* npevent = reinterpret_cast<NPPepperEvent*>(event); - std::stringstream str; - str << EventName(npevent->timeStampSeconds, npevent->type); + std::string str = EventName(npevent->timeStampSeconds, npevent->type); switch (npevent->type) { case NPEventType_MouseDown: case NPEventType_MouseUp: case NPEventType_MouseMove: case NPEventType_MouseEnter: case NPEventType_MouseLeave: - str << ": mod " << npevent->u.mouse.modifier - << ", but: " << npevent->u.mouse.button - << ", x: " << npevent->u.mouse.x - << ", y: " << npevent->u.mouse.y - << ", click: " << npevent->u.mouse.clickCount; + str += StringPrintf(": mod %x, but: %x, x: %d, y: %d, click: %d", + npevent->u.mouse.modifier, + npevent->u.mouse.button, + npevent->u.mouse.x, + npevent->u.mouse.y, + npevent->u.mouse.clickCount); break; case NPEventType_MouseWheel: - str << ": mod " << npevent->u.wheel.modifier - << ", dx: " << npevent->u.wheel.deltaX - << ", dy: " << npevent->u.wheel.deltaY - << ", wtx: " << npevent->u.wheel.wheelTicksX - << ", wty: " << npevent->u.wheel.wheelTicksY - << ", sbp:" << npevent->u.wheel.scrollByPage; + str += StringPrintf(": mod %x, dx: %f, dy: %f, wtx: %f, wty: %d: sbp %d", + npevent->u.wheel.modifier, + npevent->u.wheel.deltaX, + npevent->u.wheel.deltaY, + npevent->u.wheel.wheelTicksX, + npevent->u.wheel.wheelTicksY, + npevent->u.wheel.scrollByPage); break; case NPEventType_RawKeyDown: case NPEventType_KeyDown: case NPEventType_KeyUp: - str << ": mod " << npevent->u.key.modifier - << ", key: " << npevent->u.key.normalizedKeyCode; + str += StringPrintf(": mod %x, key: %x", + npevent->u.key.modifier, + npevent->u.key.normalizedKeyCode); break; case NPEventType_Char: - str << ": mod " << npevent->u.character.modifier << ", text: "; + str += StringPrintf(": mod %x, text: ", + npevent->u.character.modifier); size_t i; for (i = 0; i < arraysize(npevent->u.character.text); ++i) { - str << npevent->u.character.text[i] << ' '; + str += StringPrintf("%x ", npevent->u.character.text[i]); } - str << ", unmod: "; + str += ", unmod: "; for (i = 0; i < arraysize(npevent->u.character.unmodifiedText); ++i) { - str << npevent->u.character.unmodifiedText[i] << ' '; + str += StringPrintf("%x ", npevent->u.character.unmodifiedText[i]); } break; case NPEventType_Minimize: @@ -141,7 +144,7 @@ int EventHandler::handle(void* event) { default: break; } - addText(str.str().c_str()); + addText(str.c_str()); return 0; } diff --git a/webkit/tools/pepper_test_plugin/main.cc b/webkit/tools/pepper_test_plugin/main.cc index 8e46ecd..ef9a64b 100644 --- a/webkit/tools/pepper_test_plugin/main.cc +++ b/webkit/tools/pepper_test_plugin/main.cc @@ -34,21 +34,15 @@ #include <stdlib.h> #include <stdio.h> -#if defined(INDEPENDENT_PLUGIN) -#include <iostream> -#define LOG(x) std::cerr -#else #include "base/logging.h" #include "base/string_util.h" -#endif -#include "webkit/glue/plugins/nphostapi.h" #include "webkit/tools/pepper_test_plugin/plugin_object.h" #include "webkit/tools/pepper_test_plugin/event_handler.h" -#if __GNUC__ >= 4 -#define EXPORT __attribute__ ((visibility("default"))) -#elif defined(_MSC_VER) -#define EXPORT __declspec(dllexport) +#ifdef WIN32 +#define NPAPI WINAPI +#else +#define NPAPI #endif namespace { @@ -57,14 +51,7 @@ void Log(NPP instance, const char* format, ...) { va_list args; va_start(args, format); std::string message("PLUGIN: "); -#if defined(INDEPENDENT_PLUGIN) - { - char msgbuf[100]; - vsnprintf(msgbuf, 100, format, args); - } -#else StringAppendV(&message, format, args); -#endif va_end(args); NPObject* window_object = 0; @@ -112,25 +99,34 @@ void Log(NPP instance, const char* format, ...) { // Plugin entry points extern "C" { -EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs +#if defined(OS_WIN) +//__declspec(dllexport) +#endif +NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs #if defined(OS_LINUX) , NPPluginFuncs* plugin_funcs #endif ); -EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs); +#if defined(OS_WIN) +//__declspec(dllexport) +#endif +NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs); -EXPORT void API_CALL NP_Shutdown() { +#if defined(OS_WIN) +//__declspec(dllexport) +#endif +void NPAPI NP_Shutdown() { } #if defined(OS_LINUX) -EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable, void* value); -EXPORT const char* API_CALL NP_GetMIMEDescription(); +NPError NP_GetValue(NPP instance, NPPVariable variable, void* value); +const char* NP_GetMIMEDescription(); #endif } // extern "C" // Plugin entry points -EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs +NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs #if defined(OS_LINUX) , NPPluginFuncs* plugin_funcs #endif @@ -145,7 +141,7 @@ EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs // Entrypoints ----------------------------------------------------------------- -NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { +NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { plugin_funcs->version = 11; plugin_funcs->size = sizeof(plugin_funcs); plugin_funcs->newp = NPP_New; @@ -275,11 +271,11 @@ NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) { } #if defined(OS_LINUX) -NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable, void* value) { +NPError NP_GetValue(NPP instance, NPPVariable variable, void* value) { return NPP_GetValue(instance, variable, value); } -const char* API_CALL NP_GetMIMEDescription() { - return "pepper-application/x-pepper-test-plugin::Pepper Test"; +const char* NP_GetMIMEDescription() { + return "pepper-application/x-pepper-test-plugin pepper test;"; } #endif diff --git a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp index 9383747..aa3908a 100644 --- a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp +++ b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp @@ -5,6 +5,8 @@ 'target_name': 'pepper_test_plugin', 'type': 'shared_library', 'dependencies': [ + '../../../base/base.gyp:base', + '../../../skia/skia.gyp:skia', '../../../third_party/npapi/npapi.gyp:npapi', ], 'include_dirs': [ @@ -21,17 +23,7 @@ 'pepper_test_plugin.def', 'pepper_test_plugin.rc', ], - }], - ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', { - # Shared libraries need -fPIC on x86-64 - 'cflags': ['-fPIC'], - 'defines': ['INDEPENDENT_PLUGIN'], - }, { - 'dependencies': [ - '../../../base/base.gyp:base', - '../../../skia/skia.gyp:skia', - ], - }], + }] ], 'sources': [ 'command_buffer_pepper.cc', diff --git a/webkit/tools/pepper_test_plugin/plugin_object.cc b/webkit/tools/pepper_test_plugin/plugin_object.cc index 91b406f..59212ac 100644 --- a/webkit/tools/pepper_test_plugin/plugin_object.cc +++ b/webkit/tools/pepper_test_plugin/plugin_object.cc @@ -28,16 +28,12 @@ #include <stdio.h> #include <string> -#if defined(INDEPENDENT_PLUGIN) -#define CHECK(x) -#else #include "base/logging.h" #include "gpu/command_buffer/client/gles2_lib.h" #include "gpu/command_buffer/client/gles2_demo_cc.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/effects/SkGradientShader.h" -#endif #include "webkit/tools/pepper_test_plugin/event_handler.h" #include "webkit/tools/pepper_test_plugin/test_object.h" @@ -214,26 +210,7 @@ NPClass plugin_class = { // Bitmap painting ------------------------------------------------------------- -#if defined(INDEPENDENT_PLUGIN) -void DrawSampleBitmap(void *region, int width, int height) { - int32 *bitmap = reinterpret_cast<int32 *>(region); - - for (int h = 0; h < height; ++h) { - uint8 opacity = (h * 0xff) / height; - for (int w = 0; w < width; ++w) { - // kudos to apatrick for noticing we're using premultiplied alpha - uint8 greenness = (w * opacity) / width; - *bitmap++ = (opacity << 24) | (greenness << 8); - } - } -} -#else -void DrawSampleBitmap(void *region, int width, int height) { - SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - bitmap.setPixels(region); - - SkCanvas canvas(bitmap); +void DrawSampleBitmap(SkCanvas& canvas, int width, int height) { SkRect rect; rect.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(width), SkIntToScalar(height)); @@ -256,7 +233,7 @@ void DrawSampleBitmap(void *region, int width, int height) { canvas.drawPath(path, paint); } -#endif + void FlushCallback(NPP instance, NPDeviceContext* context, NPError err, void* user_data) { } @@ -313,14 +290,19 @@ void PluginObject::New(NPMIMEType pluginType, void PluginObject::SetWindow(const NPWindow& window) { if (dimensions_ == 2) { - width_ = window.width; - height_ = window.height; + size_.set_width(window.width); + size_.set_height(window.height); NPDeviceContext2DConfig config; NPDeviceContext2D context; device2d_->initializeContext(npp_, &config, &context); - DrawSampleBitmap(context.region, width_, height_); + SkBitmap bitmap; + bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height); + bitmap.setPixels(context.region); + + SkCanvas canvas(bitmap); + DrawSampleBitmap(canvas, window.width, window.height); // TODO(brettw) figure out why this cast is necessary, the functions seem to // match. Could be a calling convention mismatch? @@ -328,7 +310,6 @@ void PluginObject::SetWindow(const NPWindow& window) { reinterpret_cast<NPDeviceFlushContextCallbackPtr>(&FlushCallback); device2d_->flushContext(npp_, &context, callback, NULL); } else { -#if !defined(INDEPENDENT_PLUGIN) if (!command_buffer_.get()) { if (!InitializeCommandBuffer()) return; @@ -338,12 +319,10 @@ void PluginObject::SetWindow(const NPWindow& window) { // Schedule the first call to Draw. browser->pluginthreadasynccall(npp_, Draw3DCallback, this); -#endif } } void PluginObject::Draw3D() { -#if !defined(INDEPENDENT_PLUGIN) // Render some stuff. gles2::g_gl_impl = gles2_implementation_.get(); GLFromCPPTestFunction(); @@ -353,11 +332,9 @@ void PluginObject::Draw3D() { // Schedule another call to Draw. browser->pluginthreadasynccall(npp_, Draw3DCallback, this); -#endif } bool PluginObject::InitializeCommandBuffer() { -#if !defined(INDEPENDENT_PLUGIN) const static int32 kCommandBufferSize = 512 * 1024; command_buffer_.reset(new CommandBufferPepper(npp_, browser)); if (command_buffer_->Initialize(kCommandBufferSize)) { @@ -383,7 +360,6 @@ bool PluginObject::InitializeCommandBuffer() { } command_buffer_.reset(); -#endif return false; } diff --git a/webkit/tools/pepper_test_plugin/plugin_object.h b/webkit/tools/pepper_test_plugin/plugin_object.h index e671a94..4dcff15 100644 --- a/webkit/tools/pepper_test_plugin/plugin_object.h +++ b/webkit/tools/pepper_test_plugin/plugin_object.h @@ -27,12 +27,11 @@ #define WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_PLUGIN_OBJECT_H_ #include "base/basictypes.h" +#include "base/gfx/size.h" #include "base/scoped_ptr.h" -#include "webkit/glue/plugins/nphostapi.h" -#if !defined(INDEPENDENT_PLUGIN) #include "gpu/command_buffer/client/gles2_implementation.h" #include "webkit/tools/pepper_test_plugin/command_buffer_pepper.h" -#endif +#include "webkit/glue/plugins/nphostapi.h" extern NPNetscapeFuncs* browser; @@ -62,14 +61,11 @@ class PluginObject { // TODO(apatrick): this destruction order causes the plugin to crash on // shutdown. -#if !defined(INDEPENDENT_PLUGIN) scoped_ptr<CommandBufferPepper> command_buffer_; scoped_ptr<gpu::gles2::GLES2Implementation> gles2_implementation_; scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; -#endif - int width_; - int height_; + gfx::Size size_; DISALLOW_COPY_AND_ASSIGN(PluginObject); }; |