+2006-09-25 Dave Hyatt <hyat@apple.com>
+
+ Shunt the RenderTheme world transform adoption between
+ Cairo and Windows into getWindowsContext and move the method
+ out of GraphicsContextCairo and into GraphicsContextWin.
+
+ * ChangeLog:
+ * WebCore.vcproj/WebCore/WebCore.vcproj:
+ * platform/cairo/GraphicsContextCairo.cpp:
+ * platform/win/GraphicsContextWin.cpp: Added.
+ (WebCore::GraphicsContext::getWindowsContext):
+ (WebCore::GraphicsContext::releaseWindowsContext):
+ * rendering/RenderThemeWin.cpp:
+ (WebCore::prepareForDrawing):
+
2006-09-24 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt.
cairo_translate(context, x, y);
}
-HDC GraphicsContext::getWindowsContext()
-{
- cairo_surface_t* surface = cairo_get_target(platformContext());
- HDC hdc = cairo_win32_surface_get_dc(surface);
- SaveDC(hdc);
- return hdc;
-}
-
IntPoint GraphicsContext::origin()
{
cairo_matrix_t matrix;
return IntPoint(matrix.x0, matrix.y0);
}
-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);
-}
-
} // namespace WebCore
#endif // PLATFORM(CAIRO)
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(CAIRO)
+
+#include "config.h"
+#include "GraphicsContext.h"
+#include <cairo-win32.h>
+
+namespace WebCore
+{
+
+HDC GraphicsContext::getWindowsContext()
+{
+ cairo_surface_t* surface = cairo_get_target(platformContext());
+ HDC hdc = cairo_win32_surface_get_dc(surface);
+ SaveDC(hdc);
+
+ // FIXME: We need to make sure a clip is really set on the HDC.
+ // Call SetWorldTransform to honor the current Cairo transform.
+ SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
+ cairo_matrix_t mat;
+ cairo_get_matrix(platformContext(), &mat);
+ XFORM xform;
+ xform.eM11 = mat.xx;
+ xform.eM12 = mat.xy;
+ xform.eM21 = mat.yx;
+ xform.eM22 = mat.yy;
+ xform.eDx = mat.x0;
+ xform.eDy = mat.y0;
+ SetWorldTransform(hdc, &xform);
+
+ 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
{
}
+// May need to add stuff to these later, so keep the graphics context retrieval/release in some helpers.
static HDC prepareForDrawing(GraphicsContext* g)
{
- 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.)
-
- // Call SetWorldTransform to honor the current Cairo transform.
- SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
- cairo_matrix_t mat;
- cairo_get_matrix(g->platformContext(), &mat);
- XFORM xform;
- xform.eM11 = mat.xx;
- xform.eM12 = mat.xy;
- xform.eM21 = mat.yx;
- xform.eM22 = mat.yy;
- xform.eDx = mat.x0;
- xform.eDy = mat.y0;
- SetWorldTransform(hdc, &xform);
-
- return hdc;
+ return g->getWindowsContext();
}
-
+
static void doneDrawing(GraphicsContext* g)
{
g->releaseWindowsContext();