+2006-09-21 Sean Gies <seangies@apple.com>
+
+ Reviewed by Adam Roben.
+
+ Add utility functions to get and release HDC from GraphicsContext.
+
+ * platform/GraphicsContext.h: Add utilities to get and release HDC.
+ * platform/cairo/GraphicsContextCairo.cpp: Implement new utilities.
+ * rendering/RenderThemeWin.cpp: Switch to new utilities.
+
2006-09-21 Justin Garcia <justin.garcia@apple.com>
Reviewed by anders
#if PLATFORM(WIN)
GraphicsContext(HDC); // FIXME: To be removed.
+ HDC getWindowsContext();
+ void releaseWindowsContext();
#endif
private:
return result;
}
+HDC GraphicsContext::getWindowsContext()
+{
+ cairo_surface_t* surface = cairo_get_target(platformContext());
+ HDC hdc = cairo_win32_surface_get_dc(surface);
+ SaveDC(hdc);
+ return hdc;
+}
+
+void GraphicsContext::releaseWindowsContext()
+{
+ cairo_surface_t* surface = cairo_get_target(platformContext());
+ HDC hdc = cairo_win32_surface_get_dc(surface);
+ RestoreDC(hdc, -1);
+ cairo_surface_mark_dirty(surface);
+}
+
}
#endif // PLATFORM(CAIRO)
static HDC prepareForDrawing(GraphicsContext* g)
{
- cairo_surface_t* surface = cairo_get_target(g->platformContext());
- HDC hdc = cairo_win32_surface_get_dc(surface);
- SaveDC(hdc);
+ HDC hdc = g->getWindowsContext();
// FIXME: We need to make sure a clip is really set on the HDC. See what Mozilla does with
// UpdateSurfaceClip on its GraphicsContext. (Cairo may not have put its clip into native form yet.)
static void doneDrawing(GraphicsContext* g)
{
- cairo_surface_t* surface = cairo_get_target(g->platformContext());
- HDC hdc = cairo_win32_surface_get_dc(surface);
- RestoreDC(hdc, -1);
-
- // We call this whenever we do drawing outside of cairo.
- cairo_surface_mark_dirty(surface);
+ g->releaseWindowsContext();
}
bool RenderThemeWin::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)