summaryrefslogtreecommitdiffstats
path: root/webkit/tools/pepper_test_plugin
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 23:07:02 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 23:07:02 +0000
commit66b4e8dfc5cce75c998889d5b968ecb72a204447 (patch)
tree215d020b5bb8a5cfa43debf580e9bd3d55091b77 /webkit/tools/pepper_test_plugin
parent3984b4b1edee2b14b0ebd41d31fc9fedfc7a0ef9 (diff)
downloadchromium_src-66b4e8dfc5cce75c998889d5b968ecb72a204447.zip
chromium_src-66b4e8dfc5cce75c998889d5b968ecb72a204447.tar.gz
chromium_src-66b4e8dfc5cce75c998889d5b968ecb72a204447.tar.bz2
Update the Pepper APIs to the latest spec for the 2D demo plugin.
This also adds the npapi headers to the npapi.gyp file since I got tired of Visual Studio not finding the files. This removes the "open file in sandbox" feature which it doesn't look like we will use. One more significant change is that I changed to including pepper.h in all cases, even when pepper is disabled. We used to have a forward declare in npapi.h for the structs in question, but we'll be adding a lot more structs for the different contexts and I don't think this will scale. I think its OK fo rthe pepper API declarations to be available when Pepper isn't enabled. BUT=none TEST=none Review URL: http://codereview.chromium.org/453015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/pepper_test_plugin')
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.cc45
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.h2
2 files changed, 20 insertions, 27 deletions
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.cc b/webkit/tools/pepper_test_plugin/plugin_object.cc
index 8af7591..432bfc4 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.cc
+++ b/webkit/tools/pepper_test_plugin/plugin_object.cc
@@ -224,11 +224,12 @@ void DrawSampleBitmap(SkCanvas& canvas, int width, int height) {
canvas.drawPath(path, paint);
}
-NPPepperExtensions* pepper = NULL;
-
-void FlushCallback(NPRenderContext* context, void* user_data) {
+void FlushCallback(NPP instance, NPDeviceContext* context,
+ NPError err, void* user_data) {
}
+NPExtensions* extensions = NULL;
+
} // namespace
@@ -236,15 +237,19 @@ void FlushCallback(NPRenderContext* context, void* user_data) {
PluginObject::PluginObject(NPP npp)
: npp_(npp),
- test_object_(browser->createobject(npp, GetTestClass())) {
- if (!pepper) {
+ test_object_(browser->createobject(npp, GetTestClass())),
+ device2d_(NULL) {
+ if (!extensions) {
browser->getvalue(npp_, NPNVPepperExtensions,
- reinterpret_cast<void*>(&pepper));
- CHECK(pepper);
+ reinterpret_cast<void*>(&extensions));
+ CHECK(extensions);
}
+ device2d_ = extensions->acquireDevice(npp, NPPepper2DDevice);
+ CHECK(device2d_);
}
PluginObject::~PluginObject() {
+ // FIXME(brettw) destroy the context.
browser->releaseobject(test_object_);
}
@@ -254,26 +259,12 @@ NPClass* PluginObject::GetPluginClass() {
}
void PluginObject::SetWindow(const NPWindow& window) {
- // File test
- /* TODO(brettw): remove this when the file stuff is complete. This code is for
- testing the OpenFileInSandbox function which is not complete.
- {
- void* handle = (void*)112358;
- NPError err = pepper->openFile(npp_,
- "q:\\prj\\src2\\src\\webkit\\tools\\pepper_test_plugin\\README",
- &handle);
- CHECK(err == NPERR_NO_ERROR);
-
- char buf[256];
- sprintf(buf, "Got the handle %d", (int)handle);
- ::MessageBoxA(NULL, buf, "pepper", 0);
- }*/
-
size_.set_width(window.width);
size_.set_height(window.height);
- NPRenderContext context;
- pepper->initializeRender(npp_, NPRenderGraphicsRGBA, &context);
+ NPDeviceContext2DConfig config;
+ NPDeviceContext2D context;
+ device2d_->initializeContext(npp_, &config, &context);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, window.width, window.height);
@@ -284,7 +275,7 @@ void PluginObject::SetWindow(const NPWindow& window) {
// TODO(brettw) figure out why this cast is necessary, the functions seem to
// match. Could be a calling convention mismatch?
- NPFlushRenderContextCallbackPtr callback =
- reinterpret_cast<NPFlushRenderContextCallbackPtr>(&FlushCallback);
- pepper->flushRender(npp_, &context, callback, NULL);
+ NPDeviceFlushContextCallbackPtr callback =
+ reinterpret_cast<NPDeviceFlushContextCallbackPtr>(&FlushCallback);
+ device2d_->flushContext(npp_, &context, callback, NULL);
}
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.h b/webkit/tools/pepper_test_plugin/plugin_object.h
index a45bdc4..1dcbb80 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.h
+++ b/webkit/tools/pepper_test_plugin/plugin_object.h
@@ -49,6 +49,8 @@ class PluginObject {
NPP npp_;
NPObject* test_object_;
+ NPDevice* device2d_;
+
gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(PluginObject);