Index: skia/ext/skia_utils_win.cc |
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc |
index 3089b242c2626febb0a485c5dd8ff50c138c558b..9873373725705fe6f8e4491a54ebd56916829276 100644 |
--- a/skia/ext/skia_utils_win.cc |
+++ b/skia/ext/skia_utils_win.cc |
@@ -58,5 +58,44 @@ COLORREF SkColorToCOLORREF(SkColor color) { |
#endif |
} |
+void InitializeDC(HDC context) { |
+ // Enables world transformation. |
+ // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the |
+ // counterclockwise direction in logical space. This is equivalent to the |
+ // statement that, in the GM_ADVANCED graphics mode, both arc control points |
+ // and arcs themselves fully respect the device context's world-to-device |
+ // transformation. |
+ BOOL res = SetGraphicsMode(context, GM_ADVANCED); |
+ SkASSERT(res != 0); |
+ |
+ // Enables dithering. |
+ res = SetStretchBltMode(context, HALFTONE); |
+ SkASSERT(res != 0); |
+ // As per SetStretchBltMode() documentation, SetBrushOrgEx() must be called |
+ // right after. |
+ res = SetBrushOrgEx(context, 0, 0, NULL); |
+ SkASSERT(res != 0); |
+ |
+ // Sets up default orientation. |
+ res = SetArcDirection(context, AD_CLOCKWISE); |
+ SkASSERT(res != 0); |
+ |
+ // Sets up default colors. |
+ res = SetBkColor(context, RGB(255, 255, 255)); |
+ SkASSERT(res != CLR_INVALID); |
+ res = SetTextColor(context, RGB(0, 0, 0)); |
+ SkASSERT(res != CLR_INVALID); |
+ res = SetDCBrushColor(context, RGB(255, 255, 255)); |
+ SkASSERT(res != CLR_INVALID); |
+ res = SetDCPenColor(context, RGB(0, 0, 0)); |
+ SkASSERT(res != CLR_INVALID); |
+ |
+ // Sets up default transparency. |
+ res = SetBkMode(context, OPAQUE); |
+ SkASSERT(res != 0); |
+ res = SetROP2(context, R2_COPYPEN); |
+ SkASSERT(res != 0); |
+} |
+ |
} // namespace skia |