summaryrefslogtreecommitdiffstats
path: root/webkit/tools/pepper_test_plugin
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 23:27:43 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 23:27:43 +0000
commit9a298ada39103abf74e423519a9ee8251bbe0555 (patch)
treefe6229f2fe75a3d844408d9051cc3fa90dfe7fa8 /webkit/tools/pepper_test_plugin
parent49a518aabe67f9366bc23d0142493cb6508d662d (diff)
downloadchromium_src-9a298ada39103abf74e423519a9ee8251bbe0555.zip
chromium_src-9a298ada39103abf74e423519a9ee8251bbe0555.tar.gz
chromium_src-9a298ada39103abf74e423519a9ee8251bbe0555.tar.bz2
Added support for lost context recovery on the client side. None of our service side GL implementations actually report lost contexts (yet).
Added pglGetError to PGL library. pglSwapBuffers returns false on a lost context or other non-recoverable error and pglGetError reports PGL_CONTEXT_LOST. Updated demo plugins to reset their PGL contexts on context lost. Standalone plugins cannot currently recover from lost context because they don't use PGL. Added error code to NPDeviceContext3D for lost context. TEST=none BUG=none Review URL: http://codereview.chromium.org/566021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/pepper_test_plugin')
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.cc72
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.h2
2 files changed, 53 insertions, 21 deletions
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.cc b/webkit/tools/pepper_test_plugin/plugin_object.cc
index 013702b..6880099 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.cc
+++ b/webkit/tools/pepper_test_plugin/plugin_object.cc
@@ -309,6 +309,11 @@ PluginObject::PluginObject(NPP npp)
}
PluginObject::~PluginObject() {
+#if !defined(INDEPENDENT_PLUGIN)
+ if (pgl_context_)
+ Destroy3D();
+#endif
+
// TODO(kbr): add audio portion of test
#if !defined(OS_MACOSX)
deviceaudio_->destroyContext(npp_, &context_audio_);
@@ -359,10 +364,10 @@ void PluginObject::New(NPMIMEType pluginType,
}
void PluginObject::SetWindow(const NPWindow& window) {
- if (dimensions_ == 2) {
- width_ = window.width;
- height_ = window.height;
+ width_ = window.width;
+ height_ = window.height;
+ if (dimensions_ == 2) {
NPDeviceContext2DConfig config;
NPDeviceContext2D context;
device2d_->initializeContext(npp_, &config, &context);
@@ -376,20 +381,8 @@ void PluginObject::SetWindow(const NPWindow& window) {
device2d_->flushContext(npp_, &context, callback, NULL);
} else {
#if !defined(INDEPENDENT_PLUGIN)
- if (!pgl_context_) {
- // Initialize a 3D context.
- NPDeviceContext3DConfig config;
- config.commandBufferSize = kCommandBufferSize;
- device3d_->initializeContext(npp_, &config, &context3d_);
-
- // Create a PGL context.
- pgl_context_ = pglCreateContext(npp_, device3d_, &context3d_);
- }
-
- // Reset the viewport to new window size.
- pglMakeCurrent(pgl_context_);
- glViewport(0, 0, window.width, window.height);
- pglMakeCurrent(NULL);
+ if (!pgl_context_)
+ Initialize3D();
// Schedule the first call to Draw.
browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
@@ -413,15 +406,52 @@ void PluginObject::SetWindow(const NPWindow& window) {
#endif
}
-void PluginObject::Draw3D() {
+void PluginObject::Initialize3D() {
#if !defined(INDEPENDENT_PLUGIN)
- // Render some stuff.
+ DCHECK(!pgl_context_);
+
+ // Initialize a 3D context.
+ NPDeviceContext3DConfig config;
+ config.commandBufferSize = kCommandBufferSize;
+ device3d_->initializeContext(npp_, &config, &context3d_);
+
+ // Create a PGL context.
+ pgl_context_ = pglCreateContext(npp_, device3d_, &context3d_);
+
+ // Initialize the demo GL state.
pglMakeCurrent(pgl_context_);
- GLFromCPPTestFunction();
+ GLFromCPPInit();
+ pglMakeCurrent(NULL);
+#endif // INDEPENDENT_PLUGIN
+}
+
+void PluginObject::Destroy3D() {
+#if !defined(INDEPENDENT_PLUGIN)
+ DCHECK(pgl_context_);
+
+ // Destroy the PGL context.
+ pglDestroyContext(pgl_context_);
+ pgl_context_ = NULL;
+
+ // Destroy the Device3D context.
+ device3d_->destroyContext(npp_, &context3d_);
+#endif // INDEPENDENT_PLUGIN
+}
+
+void PluginObject::Draw3D() {
+#if !defined(INDEPENDENT_PLUGIN)
+ if (!pglMakeCurrent(pgl_context_) && pglGetError() == PGL_CONTEXT_LOST) {
+ Destroy3D();
+ Initialize3D();
+ pglMakeCurrent(pgl_context_);
+ }
+
+ glViewport(0, 0, width_, height_);
+ GLFromCPPDraw();
pglSwapBuffers();
pglMakeCurrent(NULL);
// Schedule another call to Draw.
browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
-#endif
+#endif // INDEPENDENT_PLUGIN
}
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.h b/webkit/tools/pepper_test_plugin/plugin_object.h
index 1d9970d..73a3277 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.h
+++ b/webkit/tools/pepper_test_plugin/plugin_object.h
@@ -47,6 +47,8 @@ class PluginObject {
void New(NPMIMEType pluginType, int16 argc, char* argn[], char* argv[]);
void SetWindow(const NPWindow& window);
+ void Initialize3D();
+ void Destroy3D();
void Draw3D();
private: