Factored out get/release of HDC from cairo GraphicsContext.
authorseangies <seangies@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2006 21:58:40 +0000 (21:58 +0000)
committerseangies <seangies@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2006 21:58:40 +0000 (21:58 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16511 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/GraphicsContext.h
WebCore/platform/cairo/GraphicsContextCairo.cpp
WebCore/rendering/RenderThemeWin.cpp

index 198f85a..1a43f1e 100644 (file)
@@ -1,3 +1,13 @@
+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
index 50509ff..3e2ce88 100644 (file)
@@ -169,6 +169,8 @@ namespace WebCore {
 
 #if PLATFORM(WIN)
         GraphicsContext(HDC); // FIXME: To be removed.
+        HDC getWindowsContext();
+        void releaseWindowsContext();
 #endif
 
     private:
index ba44a36..9d381a1 100644 (file)
@@ -446,6 +446,22 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
     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)
index 6a26a33..ee850d8 100644 (file)
@@ -213,9 +213,7 @@ void RenderThemeWin::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, El
 
 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.)
@@ -238,12 +236,7 @@ static HDC prepareForDrawing(GraphicsContext* g)
 
 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)