diff options
Diffstat (limited to 'o3d/plugin/win')
-rw-r--r-- | o3d/plugin/win/main_win.cc | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc index 9458819..33561c7 100644 --- a/o3d/plugin/win/main_win.cc +++ b/o3d/plugin/win/main_win.cc @@ -42,6 +42,7 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/ref_counted.h" #include "core/cross/display_mode.h" #include "core/cross/event.h" #include "plugin/cross/plugin_logging.h" @@ -50,14 +51,32 @@ #include "v8/include/v8.h" #include "breakpad/win/bluescreen_detector.h" +#if defined(RENDERER_CB) +#include "core/cross/command_buffer/renderer_cb.h" +#include "core/cross/command_buffer/display_window_cb.h" +#include "gpu_plugin/command_buffer.h" +#endif + using glue::_o3d::PluginObject; using glue::StreamManager; using o3d::DisplayWindowWindows; using o3d::Event; +#if defined(RENDERER_CB) +using o3d::gpu_plugin::CommandBuffer; +using o3d::gpu_plugin::NPObjectPointer; +#endif + namespace { // The instance handle of the O3D DLL. HINSTANCE g_module_instance; + +// TODO(apatrick): We can have an NPBrowser in the other configurations when we +// move over to gyp. This is just to avoid having to write scons files for +// np_utils. +#if defined(RENDERER_CB) +o3d::gpu_plugin::NPBrowser* g_browser; +#endif } // namespace anonymous #if !defined(O3D_INTERNAL_PLUGIN) @@ -717,6 +736,11 @@ extern "C" { NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs) { HANDLE_CRASHES; + +#if defined(RENDERER_CB) + g_browser = new o3d::gpu_plugin::NPBrowser(browserFuncs); +#endif + NPError retval = InitializeNPNApi(browserFuncs); if (retval != NPERR_NO_ERROR) return retval; return InitializePlugin(); @@ -755,6 +779,11 @@ NPError OSCALL NP_Shutdown(void) { g_bluescreen_detector = NULL; } +#if defined(RENDERER_CB) + delete g_browser; + g_browser = NULL; +#endif + #endif // O3D_INTERNAL_PLUGIN return NPERR_NO_ERROR; @@ -887,11 +916,26 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window) { ::ShowWindow(content_window, SW_SHOW); // create and assign the graphics context +#if defined(RENDERER_CB) + const unsigned int kDefaultCommandBufferSize = 256 << 10; + NPObjectPointer<CommandBuffer> command_buffer = + RendererCBLocal::CreateCommandBuffer(instance, + obj->GetHWnd(), + kDefaultCommandBufferSize); + + DisplayWindowCB default_display; + default_display.set_npp(instance); + default_display.set_command_buffer(command_buffer); + + obj->CreateRenderer(default_display); + obj->renderer()->Resize(window->width, window->height); + obj->client()->Init(); +#else DisplayWindowWindows default_display; default_display.set_hwnd(obj->GetHWnd()); - obj->CreateRenderer(default_display); obj->client()->Init(); +#endif // we set the timer to 10ms or 100fps. At the time of this comment // the renderer does a vsync the max fps it will run will be the refresh |