Bug 549171: Check if there's support for sufficient D3D hardware for the D2D backend to work. r=jrmuizel

This commit is contained in:
Bas Schouten 2010-03-02 02:04:27 +01:00
parent f793f5610f
commit 07ee37b338
5 changed files with 44 additions and 1 deletions

View File

@ -195,8 +195,10 @@ public:
}
}
if (SUCCEEDED(hr)) {
mDeviceInstance->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);
}
}
mDeviceInstance->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);
}
return mDeviceInstance;
}

View File

@ -1985,6 +1985,14 @@ _cairo_d2d_getextents(void *surface,
cairo_surface_t*
cairo_d2d_surface_create_for_hwnd(HWND wnd)
{
if (!D3D10Factory::Device() || !D2DSurfFactory::Instance()) {
/**
* FIXME: In the near future we can use cairo_device_t to pass in a
* device.
*/
return _cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_NO_DEVICE));
}
cairo_d2d_surface_t *newSurf = static_cast<cairo_d2d_surface_t*>(malloc(sizeof(cairo_d2d_surface_t)));
memset(newSurf, 0, sizeof(cairo_d2d_surface_t));
@ -2103,6 +2111,13 @@ cairo_d2d_surface_create(cairo_format_t format,
int width,
int height)
{
if (!D3D10Factory::Device() || !D2DSurfFactory::Instance()) {
/**
* FIXME: In the near future we can use cairo_device_t to pass in a
* device.
*/
return _cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_NO_DEVICE));
}
cairo_d2d_surface_t *newSurf = static_cast<cairo_d2d_surface_t*>(malloc(sizeof(cairo_d2d_surface_t)));
memset(newSurf, 0, sizeof(cairo_d2d_surface_t));
@ -2233,3 +2248,16 @@ void cairo_d2d_scroll(cairo_surface_t *surface, int x, int y, cairo_rectangle_t
&rect);
}
cairo_bool_t
cairo_d2d_has_support()
{
/**
* FIXME: We should be able to fix this in the near future when we pass in
* a cairo_device_t to our surface creation functions.
*/
if (!D3D10Factory::Device() || !D2DSurfFactory::Instance()) {
return false;
}
return true;
}

View File

@ -164,6 +164,15 @@ void cairo_d2d_present_backbuffer(cairo_surface_t *surface);
* scrolling.
*/
void cairo_d2d_scroll(cairo_surface_t *surface, int x, int y, cairo_rectangle_t *clip);
/**
* Verify if D2D surfaces are actually supported. This will confirm the needed
* hardware is available.
*
* \return True if the support is available. If false surface creation will
* return error surfaces.
*/
cairo_bool_t cairo_d2d_has_support();
#endif
CAIRO_END_DECLS

View File

@ -290,6 +290,7 @@ typedef enum _cairo_status {
CAIRO_STATUS_INVALID_WEIGHT,
CAIRO_STATUS_INVALID_SIZE,
CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED,
CAIRO_STATUS_NO_DEVICE,
CAIRO_STATUS_LAST_STATUS
} cairo_status_t;

View File

@ -173,6 +173,9 @@ gfxWindowsPlatform::gfxWindowsPlatform()
#ifndef CAIRO_HAS_D2D_SURFACE
return;
#else
if (!cairo_d2d_has_support()) {
return;
}
#ifdef CAIRO_HAS_DWRITE_FONT
if (!GetDWriteFactory()) {
#endif