Bug 461860 - windows mobile fixes in gfx r+sr=vlad
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -29,15 +29,17 @@ buggy-repeat.patch: Unconditionally turn
tmpfile_wince.patch: Make Windows CE use tmpfile() on windows mobile due to the lack of _open_osfhandle and no fs permissions.
cairo-version-fixes.patch: fix up cairo-version.c/cairo-version.h for in-place builds
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
==== disable printing patch ====
disable-printing.patch: allows us to use NS_PRINTING to disable printing.
--- a/gfx/cairo/cairo/src/cairo-win32-private.h
+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
@@ -189,9 +189,27 @@ void
_cairo_win32_debug_dump_hrgn (HRGN rgn, char *header);
cairo_bool_t
_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 */
--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
@@ -1586,18 +1586,35 @@ static cairo_int_status_t
gdi_region = ExtCreateRegion (NULL, data_size, data);
free (data);
if (!gdi_region)
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);
}
}
return status;
}
@@ -1624,17 +1641,17 @@ cairo_int_status_t
_cairo_win32_surface_show_glyphs (void *surface,
cairo_operator_t op,
cairo_pattern_t *source,
cairo_glyph_t *glyphs,
int num_glyphs,
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];
WORD *glyph_buf = glyph_buf_stack;
int dxy_buf_stack[2 * STACK_GLYPH_SIZE];
int *dxy_buf = dxy_buf_stack;
BOOL win_result = 0;
new file mode 100644
--- /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];
--- a/gfx/src/thebes/nsThebesDeviceContext.cpp
+++ b/gfx/src/thebes/nsThebesDeviceContext.cpp
@@ -73,17 +73,19 @@
#include "gfxPDFSurface.h"
#include "gfxPSSurface.h"
static nsSystemFontsGTK2 *gSystemFonts = nsnull;
#elif XP_WIN
#include "nsSystemFontsWin.h"
#include "gfxWindowsSurface.h"
#include "gfxPDFSurface.h"
static nsSystemFontsWin *gSystemFonts = nsnull;
+#ifndef WINCE
#include <usp10.h>
+#endif
#elif defined(XP_OS2)
#include "nsSystemFontsOS2.h"
#include "gfxPDFSurface.h"
static nsSystemFontsOS2 *gSystemFonts = nsnull;
#elif defined(XP_BEOS)
#include "nsSystemFontsBeOS.h"
static nsSystemFontsBeOS *gSystemFonts = nsnull;
#elif XP_MACOSX
@@ -124,17 +126,17 @@ nsThebesDeviceContext::nsThebesDeviceCon
mDepth = 0;
mWidth = 0;
mHeight = 0;
mPrintingScale = 1.0f;
mWidgetSurfaceCache.Init();
-#ifdef XP_WIN
+#if defined(XP_WIN) && !defined(WINCE)
SCRIPT_DIGITSUBSTITUTE sds;
ScriptRecordDigitSubstitution(LOCALE_USER_DEFAULT, &sds);
#endif
}
nsThebesDeviceContext::~nsThebesDeviceContext()
{
}
--- a/gfx/src/thebes/nsThebesImage.cpp
+++ b/gfx/src/thebes/nsThebesImage.cpp
@@ -688,17 +688,22 @@ nsThebesImage::Draw(gfxContext* a
aContext->Paint();
aContext->Restore();
}
}
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
// we never hit the 10k hard limit.
// GetCurrentProcess() just returns (HANDLE)-1, it's inlined afaik
DWORD count = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
if (count == 0 ||
count > kGDIObjectsHighWaterMark)
--- a/gfx/thebes/public/gfxWindowsSurface.h
+++ b/gfx/thebes/public/gfxWindowsSurface.h
@@ -85,9 +85,27 @@ public:
private:
PRPackedBool mOwnsDC;
PRPackedBool mForPrinting;
HDC mDC;
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 */
--- a/gfx/thebes/src/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/src/gfxWindowsPlatform.cpp
@@ -881,32 +881,36 @@ gfxWindowsPlatform::FindFontEntry(const
return nsnull;
return ff->FindFontEntry(aFontStyle);
}
cmsHPROFILE
gfxWindowsPlatform::GetPlatformCMSOutputProfile()
{
+#ifndef WINCE
WCHAR str[1024+1];
DWORD size = 1024;
HDC dc = GetDC(nsnull);
GetICMProfileW(dc, &size, (LPWSTR)&str);
ReleaseDC(nsnull, dc);
cmsHPROFILE profile =
cmsOpenProfileFromFile(NS_ConvertUTF16toUTF8(str).get(), "r");
#ifdef DEBUG_tor
if (profile)
fprintf(stderr,
"ICM profile read from %s successfully\n",
NS_ConvertUTF16toUTF8(str).get());
#endif
return profile;
+#else
+ return nsnull;
+#endif
}
PRBool
gfxWindowsPlatform::GetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<FontEntry> > *array)
{
return mPrefFonts.Get(aKey, array);
}