diff options
Diffstat (limited to 'gpu/demos')
-rw-r--r-- | gpu/demos/framework/Plugin_Info.plist | 46 | ||||
-rw-r--r-- | gpu/demos/framework/plugin.cc | 209 | ||||
-rw-r--r-- | gpu/demos/framework/plugin.def | 4 | ||||
-rw-r--r-- | gpu/demos/framework/plugin.h | 58 | ||||
-rw-r--r-- | gpu/demos/framework/plugin.rc | 35 | ||||
-rw-r--r-- | gpu/demos/framework/window.cc | 2 |
6 files changed, 1 insertions, 353 deletions
diff --git a/gpu/demos/framework/Plugin_Info.plist b/gpu/demos/framework/Plugin_Info.plist deleted file mode 100644 index 4a4e455..0000000 --- a/gpu/demos/framework/Plugin_Info.plist +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>${EXECUTABLE_NAME}</string> - <key>CFBundleGetInfoString</key> - <string>Copyright 2010 Google, Inc.</string> - <key>CFBundleIdentifier</key> - <string>com.google.peppergpudemoplugin</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>${PRODUCT_NAME}</string> - <key>CFBundlePackageType</key> - <string>BRPL</string> - <key>CFBundleShortVersionString</key> - <string>1.0</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleVersion</key> - <string>1.0</string> - <key>CFPlugInDynamicRegisterFunction</key> - <string></string> - <key>CFPlugInDynamicRegistration</key> - <string>NO</string> - <key>WebPluginDescription</key> - <string>Simple Pepper plug-in that demonstrates 3D rendering.</string> - <key>WebPluginMIMETypes</key> - <dict> - <key>pepper-application/x-gpu-demo</key> - <dict> - <key>WebPluginExtensions</key> - <array> - <string>peppergpudemo</string> - </array> - <key>WebPluginTypeDescription</key> - <string>Pepper GPU Demo</string> - </dict> - </dict> - <key>WebPluginName</key> - <string>Pepper GPU Demo</string> -</dict> -</plist> diff --git a/gpu/demos/framework/plugin.cc b/gpu/demos/framework/plugin.cc deleted file mode 100644 index db605e6..0000000 --- a/gpu/demos/framework/plugin.cc +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "gpu/demos/framework/plugin.h" - -#include <cassert> -#include "gpu/demos/framework/demo_factory.h" - -using gpu::demos::Plugin; - -namespace { -const int32 kCommandBufferSize = 1024 * 1024; -NPExtensions* g_extensions = NULL; - -// Plugin class functions. -NPObject* PluginAllocate(NPP npp, NPClass* the_class) { - Plugin* plugin = new Plugin(npp); - return plugin; -} - -void PluginDeallocate(NPObject* header) { - Plugin* plugin = static_cast<Plugin*>(header); - delete plugin; -} - -void PluginInvalidate(NPObject* obj) { -} - -bool PluginHasMethod(NPObject* obj, NPIdentifier name) { - return false; -} - -bool PluginInvoke(NPObject* header, - NPIdentifier name, - const NPVariant* args, uint32 arg_count, - NPVariant* result) { - return false; -} - -bool PluginInvokeDefault(NPObject* obj, - const NPVariant* args, uint32 arg_count, - NPVariant* result) { - VOID_TO_NPVARIANT(*result); - return true; -} - -bool PluginHasProperty(NPObject* obj, NPIdentifier name) { - return false; -} - -bool PluginGetProperty(NPObject* obj, - NPIdentifier name, - NPVariant* result) { - return false; -} - -bool PluginSetProperty(NPObject* obj, - NPIdentifier name, - const NPVariant* variant) { - return false; -} - -NPClass plugin_class = { - NP_CLASS_STRUCT_VERSION, - PluginAllocate, - PluginDeallocate, - PluginInvalidate, - PluginHasMethod, - PluginInvoke, - PluginInvokeDefault, - PluginHasProperty, - PluginGetProperty, - PluginSetProperty, -}; - -void TickCallback(void* data) { - reinterpret_cast<gpu::demos::Plugin*>(data)->Tick(); -} - -void RepaintCallback(NPP npp, NPDeviceContext3D* /* context */) { - Plugin* plugin = static_cast<Plugin*>(npp->pdata); - plugin->Paint(); -} -} - -namespace gpu { -namespace demos { - -NPNetscapeFuncs* g_browser; - -Plugin::Plugin(NPP npp) - : npp_(npp), - device3d_(NULL), - pgl_context_(NULL), - demo_(CreateDemo()) { - memset(&context3d_, 0, sizeof(context3d_)); -} - -Plugin::~Plugin() { - // Destroy demo while GL context is current and before it is destroyed. - pglMakeCurrent(pgl_context_); - demo_.reset(); - pglMakeCurrent(PGL_NO_CONTEXT); - - DestroyContext(); -} - -NPClass* Plugin::GetPluginClass() { - return &plugin_class; -} - -void Plugin::New(NPMIMEType pluginType, - int16 argc, char* argn[], char* argv[]) { - if (!g_extensions) { - g_browser->getvalue(npp_, NPNVPepperExtensions, &g_extensions); - assert(g_extensions); - } - - device3d_ = g_extensions->acquireDevice(npp_, NPPepper3DDevice); - assert(device3d_); -} - -void Plugin::SetWindow(const NPWindow& window) { - demo_->InitWindowSize(window.width, window.height); - - if (!pgl_context_) { - if (!CreateContext()) - return; - - // Schedule first call to Tick. - if (demo_->IsAnimated()) - g_browser->pluginthreadasynccall(npp_, TickCallback, this); - } -} - -int32 Plugin::HandleEvent(const NPPepperEvent& event) { - return 0; -} - -void Plugin::Tick() { - Paint(); - - // Schedule another call to Tick. - g_browser->pluginthreadasynccall(npp_, TickCallback, this); -} - -void Plugin::Paint() { - if (!pglMakeCurrent(pgl_context_) && pglGetError() == PGL_CONTEXT_LOST) { - DestroyContext(); - if (!CreateContext()) - return; - - pglMakeCurrent(pgl_context_); - } - - demo_->Draw(); - pglSwapBuffers(); - pglMakeCurrent(PGL_NO_CONTEXT); -} - -bool Plugin::CreateContext() { - assert(!pgl_context_); - - // Initialize a 3D context. - NPDeviceContext3DConfig config; - config.commandBufferSize = kCommandBufferSize; - if (NPERR_NO_ERROR != device3d_->initializeContext(npp_, - &config, - &context3d_)) { - DestroyContext(); - return false; - } - - context3d_.repaintCallback = RepaintCallback; - - // Create a PGL context. - pgl_context_ = pglCreateContext(npp_, device3d_, &context3d_); - if (!pgl_context_) { - DestroyContext(); - return false; - } - - // Initialize demo. - pglMakeCurrent(pgl_context_); - if (!demo_->InitGL()) { - DestroyContext(); - return false; - } - - pglMakeCurrent(PGL_NO_CONTEXT); - - return true; -} - -void Plugin::DestroyContext() { - if (pgl_context_) { - pglDestroyContext(pgl_context_); - pgl_context_ = NULL; - } - - if (context3d_.commandBuffer) { - device3d_->destroyContext(npp_, &context3d_); - memset(&context3d_, 0, sizeof(context3d_)); - } -} - -} // namespace demos -} // namespace gpu diff --git a/gpu/demos/framework/plugin.def b/gpu/demos/framework/plugin.def deleted file mode 100644 index ddc24ce..0000000 --- a/gpu/demos/framework/plugin.def +++ /dev/null @@ -1,4 +0,0 @@ -EXPORTS - NP_GetEntryPoints @1 - NP_Initialize @2 - NP_Shutdown @3 diff --git a/gpu/demos/framework/plugin.h b/gpu/demos/framework/plugin.h deleted file mode 100644 index c892d2c..0000000 --- a/gpu/demos/framework/plugin.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GPU_DEMOS_FRAMEWORK_PLUGIN_H_ -#define GPU_DEMOS_FRAMEWORK_PLUGIN_H_ - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "gpu/demos/framework/demo.h" -#include "gpu/pgl/pgl.h" -#include "third_party/npapi/bindings/nphostapi.h" - -namespace gpu { -namespace demos { - -// Acts as a framework for pepper3d demos. It is in fact a pepper plugin with -// a pepper3d device. It delegates all rendering tasks to demo object. -class Plugin : public NPObject { - public: - explicit Plugin(NPP npp); - ~Plugin(); - - static NPClass* GetPluginClass(); - - NPP npp() const { return npp_; } - void New(NPMIMEType pluginType, int16 argc, char* argn[], char* argv[]); - void SetWindow(const NPWindow& window); - int32 HandleEvent(const NPPepperEvent& event); - - // Called continuously for animated demos. - void Tick(); - - // Called by the browser to paint the window. - void Paint(); - - private: - bool CreateContext(); - void DestroyContext(); - - // This class object needs to be safely casted to NPObject* and cross - // c-c++ module boundaries. To accomplish that this class should not have - // any virtual member function. - NPP npp_; - - NPDevice* device3d_; - NPDeviceContext3D context3d_; - PGLContext pgl_context_; - scoped_ptr<Demo> demo_; - - DISALLOW_COPY_AND_ASSIGN(Plugin); -}; - -extern NPNetscapeFuncs* g_browser; - -} // namespace demos -} // namespace gpu -#endif // GPU_DEMOS_FRAMEWORK_PLUGIN_H_ diff --git a/gpu/demos/framework/plugin.rc b/gpu/demos/framework/plugin.rc deleted file mode 100644 index ee6b4fa..0000000 --- a/gpu/demos/framework/plugin.rc +++ /dev/null @@ -1,35 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-1 VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x7L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "FileDescription", "Pepper GPU Demo"
- VALUE "FileVersion", "1, 0, 0, 1"
- VALUE "LegalCopyright", "Copyright (C) 2010"
- VALUE "ProductName", "Pepper GPU Demo"
- VALUE "ProductVersion", "1, 0, 0, 1"
- VALUE "MIMEType", "pepper-application/x-gpu-demo"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc index 974a5ee..a0eedcc 100644 --- a/gpu/demos/framework/window.cc +++ b/gpu/demos/framework/window.cc @@ -69,7 +69,7 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { } command_buffer->SetPutOffsetChangeCallback( - NewCallback(gpu_scheduler, &GpuScheduler::ProcessCommands)); + NewCallback(gpu_scheduler, &GpuScheduler::PutChanged)); GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); if (!helper->Initialize(kCommandBufferSize)) { |