From 958c994fd3c344611382cb1fb91fbb1914768e17 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Wed, 3 Dec 2008 08:42:03 -0500 Subject: [PATCH] Bug 461860 - windows mobile fixes in gfx r+sr=vlad --- gfx/cairo/README | 2 + gfx/cairo/cairo/src/cairo-win32-private.h | 18 +++++++ gfx/cairo/cairo/src/cairo-win32-surface.c | 19 ++++++- gfx/cairo/wince-fixes.patch | 64 +++++++++++++++++++++++ gfx/src/thebes/nsThebesDeviceContext.cpp | 4 +- gfx/src/thebes/nsThebesImage.cpp | 7 ++- gfx/thebes/public/gfxWindowsSurface.h | 18 +++++++ gfx/thebes/src/gfxWindowsPlatform.cpp | 4 ++ 8 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 gfx/cairo/wince-fixes.patch diff --git a/gfx/cairo/README b/gfx/cairo/README index 42973bf48b3d..e234acad3403 100644 --- a/gfx/cairo/README +++ b/gfx/cairo/README @@ -34,6 +34,8 @@ win32-ddb-dib.patch: fix for bug 455513; not upstream yet pending feebdack qpainter-type.patch: add SURFACE_TYPE_QPAINTER to cairo.h +wince-fixes.patch: stubs out win32 functions we use but are not supported on win32. Also implements ExtSelectClipRgn in terms of other functions available on wince. + ==== pixman patches ==== endian.patch: include cairo-platform.h for endian macros diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h index 8e859ef495e0..7523473493fb 100644 --- a/gfx/cairo/cairo/src/cairo-win32-private.h +++ b/gfx/cairo/cairo/src/cairo-win32-private.h @@ -194,4 +194,22 @@ _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font); cairo_bool_t _cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font); +#ifdef WINCE + +// These are the required stubs for windows mobile +#define ETO_GLYPH_INDEX 0 +#define ETO_PDY 0 +#define HALFTONE COLORONCOLOR +#define GM_ADVANCED 2 +#define MWT_IDENTITY 1 + +inline int SetGraphicsMode(HDC hdc, int iMode) {return 1;} +inline int GetGraphicsMode(HDC hdc) {return 1;} /*GM_COMPATIBLE*/ +inline void GdiFlush() {} +inline BOOL SetWorldTransform(HDC hdc, CONST XFORM *lpXform) { return FALSE; } +inline BOOL GetWorldTransform(HDC hdc, LPXFORM lpXform ) { return FALSE; } +inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { return 1; } + +#endif + #endif /* CAIRO_WIN32_PRIVATE_H */ diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c index ccfaa1ddb9f4..06f5ff235413 100644 --- a/gfx/cairo/cairo/src/cairo-win32-surface.c +++ b/gfx/cairo/cairo/src/cairo-win32-surface.c @@ -1591,8 +1591,25 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, return _cairo_error (CAIRO_STATUS_NO_MEMORY); /* AND the new region into our DC */ + +#ifndef WINCE if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR) status = _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region"); +#else + // The ExtSelectClipRgn function combines the specified + // region with the current clipping region using the + // specified mode. Here we do similar using basic + // functions available on WINCE. + { + HRGN currentClip, newClip; + GetClipRgn(surface->dc, ¤tClip); + + if (CombineRgn(newClip, currentClip, gdi_region, RGN_AND) != ERROR) { + SelectClipRgn(surface->dc, newClip); + DeleteObject(newClip); + } + } +#endif DeleteObject (gdi_region); } @@ -1629,7 +1646,7 @@ _cairo_win32_surface_show_glyphs (void *surface, cairo_scaled_font_t *scaled_font, int *remaining_glyphs) { -#if CAIRO_HAS_WIN32_FONT +#if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE) cairo_win32_surface_t *dst = surface; WORD glyph_buf_stack[STACK_GLYPH_SIZE]; diff --git a/gfx/cairo/wince-fixes.patch b/gfx/cairo/wince-fixes.patch new file mode 100644 index 000000000000..af8e27d9096b --- /dev/null +++ b/gfx/cairo/wince-fixes.patch @@ -0,0 +1,64 @@ +diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h +--- a/gfx/cairo/cairo/src/cairo-win32-private.h ++++ b/gfx/cairo/cairo/src/cairo-win32-private.h +@@ -194,4 +194,22 @@ + cairo_bool_t + _cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font); + ++#ifdef WINCE ++ ++// These are the required stubs for windows mobile ++#define ETO_GLYPH_INDEX 0 ++#define ETO_PDY 0 ++#define HALFTONE COLORONCOLOR ++#define GM_ADVANCED 2 ++#define MWT_IDENTITY 1 ++ ++inline int SetGraphicsMode(HDC hdc, int iMode) {return 1;} ++inline int GetGraphicsMode(HDC hdc) {return 1;} /*GM_COMPATIBLE*/ ++inline void GdiFlush() {} ++inline BOOL SetWorldTransform(HDC hdc, CONST XFORM *lpXform) { return FALSE; } ++inline BOOL GetWorldTransform(HDC hdc, LPXFORM lpXform ) { return FALSE; } ++inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { return 1; } ++ ++#endif ++ + #endif /* CAIRO_WIN32_PRIVATE_H */ +diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c +--- a/gfx/cairo/cairo/src/cairo-win32-surface.c ++++ b/gfx/cairo/cairo/src/cairo-win32-surface.c +@@ -1591,8 +1591,25 @@ + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + + /* AND the new region into our DC */ ++ ++#ifndef WINCE + if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR) + status = _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region"); ++#else ++ // The ExtSelectClipRgn function combines the specified ++ // region with the current clipping region using the ++ // specified mode. Here we do similar using basic ++ // functions available on WINCE. ++ { ++ HRGN currentClip, newClip; ++ GetClipRgn(surface->dc, ¤tClip); ++ ++ if (CombineRgn(newClip, currentClip, gdi_region, RGN_AND) != ERROR) { ++ SelectClipRgn(surface->dc, newClip); ++ DeleteObject(newClip); ++ } ++ } ++#endif + + DeleteObject (gdi_region); + } +@@ -1629,7 +1646,7 @@ + cairo_scaled_font_t *scaled_font, + int *remaining_glyphs) + { +-#if CAIRO_HAS_WIN32_FONT ++#if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE) + cairo_win32_surface_t *dst = surface; + + WORD glyph_buf_stack[STACK_GLYPH_SIZE]; diff --git a/gfx/src/thebes/nsThebesDeviceContext.cpp b/gfx/src/thebes/nsThebesDeviceContext.cpp index 33aab4d5aebf..f0b945876562 100644 --- a/gfx/src/thebes/nsThebesDeviceContext.cpp +++ b/gfx/src/thebes/nsThebesDeviceContext.cpp @@ -78,7 +78,9 @@ static nsSystemFontsGTK2 *gSystemFonts = nsnull; #include "gfxWindowsSurface.h" #include "gfxPDFSurface.h" static nsSystemFontsWin *gSystemFonts = nsnull; +#ifndef WINCE #include +#endif #elif defined(XP_OS2) #include "nsSystemFontsOS2.h" #include "gfxPDFSurface.h" @@ -129,7 +131,7 @@ nsThebesDeviceContext::nsThebesDeviceContext() mWidgetSurfaceCache.Init(); -#ifdef XP_WIN +#if defined(XP_WIN) && !defined(WINCE) SCRIPT_DIGITSUBSTITUTE sds; ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds); #endif diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index ff4b5d9780a8..8ba9c10be3cd 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -693,7 +693,12 @@ nsThebesImage::Draw(gfxContext* aContext, PRBool nsThebesImage::ShouldUseImageSurfaces() { -#ifdef XP_WIN +#if defined(WINCE) + // There is no test on windows mobile to check for Gui resources. + // Allocate, until we run out of memory. + return PR_TRUE; + +#elif defined(XP_WIN) static const DWORD kGDIObjectsHighWaterMark = 7000; // at 7000 GDI objects, stop allocating normal images to make sure diff --git a/gfx/thebes/public/gfxWindowsSurface.h b/gfx/thebes/public/gfxWindowsSurface.h index 58aad7ea2fc4..c50c40009a6d 100644 --- a/gfx/thebes/public/gfxWindowsSurface.h +++ b/gfx/thebes/public/gfxWindowsSurface.h @@ -90,4 +90,22 @@ private: HWND mWnd; }; +#ifdef WINCE + +// These are the required stubs for windows mobile +#define ETO_GLYPH_INDEX 0 +#define ETO_PDY 0 +#define HALFTONE COLORONCOLOR +#define GM_ADVANCED 2 +#define MWT_IDENTITY 1 + +inline int SetGraphicsMode(HDC hdc, int iMode) {return 1;} +inline int GetGraphicsMode(HDC hdc) {return 1;} /*GM_COMPATIBLE*/ +inline void GdiFlush() {} +inline BOOL SetWorldTransform(HDC hdc, CONST XFORM *lpXform) { return FALSE; } +inline BOOL GetWorldTransform(HDC hdc, LPXFORM lpXform ) { return FALSE; } +inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { return 1; } + +#endif + #endif /* GFX_WINDOWSSURFACE_H */ diff --git a/gfx/thebes/src/gfxWindowsPlatform.cpp b/gfx/thebes/src/gfxWindowsPlatform.cpp index 06123d0f938a..e57eaa7811d2 100644 --- a/gfx/thebes/src/gfxWindowsPlatform.cpp +++ b/gfx/thebes/src/gfxWindowsPlatform.cpp @@ -886,6 +886,7 @@ gfxWindowsPlatform::FindFontEntry(const nsAString& aName, const gfxFontStyle& aF cmsHPROFILE gfxWindowsPlatform::GetPlatformCMSOutputProfile() { +#ifndef WINCE WCHAR str[1024+1]; DWORD size = 1024; @@ -902,6 +903,9 @@ gfxWindowsPlatform::GetPlatformCMSOutputProfile() NS_ConvertUTF16toUTF8(str).get()); #endif return profile; +#else + return nsnull; +#endif } PRBool