diff options
author | gangji@google.com <gangji@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 23:00:16 +0000 |
---|---|---|
committer | gangji@google.com <gangji@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 23:00:16 +0000 |
commit | e9bdf5333ff6527d4f3c490ad0582e54ff4ca638 (patch) | |
tree | 3bf1cf7cd4088906004de7ce60b2e2e0c6063a08 /o3d | |
parent | 232a58169700ed7abde79d9858c288eb21409e60 (diff) | |
download | chromium_src-e9bdf5333ff6527d4f3c490ad0582e54ff4ca638.zip chromium_src-e9bdf5333ff6527d4f3c490ad0582e54ff4ca638.tar.gz chromium_src-e9bdf5333ff6527d4f3c490ad0582e54ff4ca638.tar.bz2 |
Add O2D rendering with cairo into Windows build.
Review URL: http://codereview.chromium.org/6628015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/build/common.gypi | 2 | ||||
-rw-r--r-- | o3d/build/libs.gyp | 2 | ||||
-rw-r--r-- | o3d/core/cross/cairo/renderer_cairo.cc | 44 | ||||
-rw-r--r-- | o3d/core/cross/cairo/renderer_cairo.h | 2 | ||||
-rw-r--r-- | o3d/plugin/win/main_win.cc | 4 |
5 files changed, 49 insertions, 5 deletions
diff --git a/o3d/build/common.gypi b/o3d/build/common.gypi index 796d493..e8369a8 100644 --- a/o3d/build/common.gypi +++ b/o3d/build/common.gypi @@ -43,7 +43,7 @@ 'cgdir': 'third_party/cg/files/win', 'renderer%': 'd3d9', 'swiftshaderdir': 'o3d-internal/third_party/swiftshader/files', - 'support_cairo%' : 0, + 'support_cairo%' : 1, }, ], ['OS == "mac"', diff --git a/o3d/build/libs.gyp b/o3d/build/libs.gyp index 0f31c25..f398bd7 100644 --- a/o3d/build/libs.gyp +++ b/o3d/build/libs.gyp @@ -76,7 +76,7 @@ ], 'include_dirs': [ '../../<(cairodir)/src', - '../build/misc' + '../build/misc', ], }, 'dependencies': [ diff --git a/o3d/core/cross/cairo/renderer_cairo.cc b/o3d/core/cross/cairo/renderer_cairo.cc index 66e1c83..1aea379 100644 --- a/o3d/core/cross/cairo/renderer_cairo.cc +++ b/o3d/core/cross/cairo/renderer_cairo.cc @@ -37,7 +37,10 @@ #include <cairo-xlib.h> #elif defined(OS_MACOSX) #include <cairo-quartz.h> +#elif defined(OS_WIN) +#include <cairo-win32.h> #endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -61,6 +64,8 @@ RendererCairo::RendererCairo(ServiceLocator* service_locator) window_(0), #elif defined(OS_MACOSX) mac_cg_context_ref_(0), +#elif defined(OS_WIN) + hwnd_(NULL), #endif main_surface_(NULL) { // Don't need to do anything. @@ -85,6 +90,8 @@ void RendererCairo::Destroy() { window_ = 0; #elif defined(OS_MACOSX) mac_cg_context_ref_ = 0; +#elif defined(OS_WIN) + hwnd_ = NULL; #endif } @@ -251,6 +258,33 @@ void RendererCairo::CreateCairoSurface() { mac_cg_context_ref_, display_width(), display_height()); +#elif defined(OS_WIN) + HDC hdc = GetDC(hwnd_); + if (display_width() > 0 && display_height() > 0) { + RECT rect; + GetClipBox(hdc, &rect); + if (rect.right - rect.left != display_width() || + rect.bottom - rect.top != display_height()) { + // The hdc doesn't have the right clip box. + // Need to reset the clip box on hdc. + DLOG(WARNING) << "CreateCairoSurface clip box (" << rect.left << "," + << rect.top << "," << rect.right << "," << rect.bottom + << ") doesn't match the image size " << display_width() + << "x" << display_height(); + HRGN hRegion = CreateRectRgn(0, 0, display_width(), display_height()); + int result = SelectClipRgn(hdc, hRegion); + if (result == ERROR) { + LOG(ERROR) << "CreateCairoSurface SelectClipRgn returns ERROR"; + } else if (result == NULLREGION) { + // This should not happen since the ShowWindow is called. + LOG(ERROR) << "CreateCairoSurface SelectClipRgn returns NULLREGION"; + } + DeleteObject(hRegion); + } + } + + main_surface_ = cairo_win32_surface_create(hdc); + ReleaseDC(hwnd_, hdc); #endif } @@ -281,7 +315,15 @@ Renderer::InitStatus RendererCairo::InitPlatformSpecific( const DisplayWindowMac &display_platform = static_cast<const DisplayWindowMac&>(display_window); mac_cg_context_ref_ = display_platform.cg_context_ref(); +#elif defined(OS_WIN) + const DisplayWindowWindows &display_platform = + static_cast<const DisplayWindowWindows&>(display_window); + hwnd_ = display_platform.hwnd(); + if (NULL == hwnd_) { + return INITIALIZATION_ERROR; + } #endif + return SUCCESS; } @@ -303,7 +345,7 @@ void RendererCairo::Resize(int width, int height) { #if defined(OS_LINUX) // Resize the mainSurface and buffer cairo_xlib_surface_set_size(main_surface_, width, height); -#elif defined(OS_MACOSX) +#elif defined(OS_MACOSX) || defined(OS_WIN) DestroyCairoSurface(); CreateCairoSurface(); #endif diff --git a/o3d/core/cross/cairo/renderer_cairo.h b/o3d/core/cross/cairo/renderer_cairo.h index b80d246..46b7c68 100644 --- a/o3d/core/cross/cairo/renderer_cairo.h +++ b/o3d/core/cross/cairo/renderer_cairo.h @@ -238,6 +238,8 @@ class RendererCairo : public Renderer { Window window_; #elif defined(OS_MACOSX) CGContextRef mac_cg_context_ref_; +#elif defined(OS_WIN) + HWND hwnd_; #endif // Main surface to render cairo diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc index 8f93439..1a1504d 100644 --- a/o3d/plugin/win/main_win.cc +++ b/o3d/plugin/win/main_win.cc @@ -772,7 +772,6 @@ NPError PlatformNPPSetWindow(NPP instance, } return NPERR_NO_ERROR; } - if (obj->GetPluginHWnd() == hWnd) { // May need to resize the content window. DCHECK(obj->GetContentHWnd()); @@ -824,16 +823,17 @@ NPError PlatformNPPSetWindow(NPP instance, NULL, g_module_instance, NULL); - obj->Resize(window->width, window->height); obj->SetContentHWnd(content_window); PluginObject::StorePluginProperty(content_window, obj); ::ShowWindow(content_window, SW_SHOW); + ::ShowWindow(hWnd, SW_SHOW); // create and assign the graphics context DisplayWindowWindows default_display; default_display.set_hwnd(obj->GetHWnd()); obj->CreateRenderer(default_display); obj->client()->Init(); + obj->Resize(window->width, window->height); // 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 |