Bug 112635 [Xlib] XXlibRgb revamp ..
patch by Roland.Mainz@informatik.med.uni-giessen.de r=timecop@network.email.ne.jp rs=attinasi git-svn-id: svn://10.0.0.236/trunk@112223 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -117,14 +117,14 @@ EXTRA_DSO_LDOPTS += \
|
||||
$(GFX_XIE_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXNONXP
|
||||
DEFINES += -D_IMPL_NS_GFXNONXP -DUSE_MOZILLA_TYPES
|
||||
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
DEFINES += -D_BSD_SOURCE
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XPRINT
|
||||
DEFINES += -DUSE_XPRINT -DUSE_MOZILLA_TYPES
|
||||
DEFINES += -DUSE_XPRINT
|
||||
INCLUDES += -I$(srcdir)/../xprint
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_XPRINT_LDFLAGS)
|
||||
endif
|
||||
|
||||
@@ -30,11 +30,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/extensions/XIElib.h>
|
||||
#include "prenv.h"
|
||||
/* why do I need this define? */
|
||||
#define USE_MOZILLA_TYPES
|
||||
#include "xlibrgb.h"
|
||||
#include <X11/extensions/XIElib.h>
|
||||
|
||||
/* #define DEBUG_XIE 1 */
|
||||
static PRBool useXIE = PR_TRUE;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,15 +52,17 @@
|
||||
#ifndef __XLIB_RGB_H__
|
||||
#define __XLIB_RGB_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
/* Force ANSI C prototypes from X11 headers */
|
||||
#undef FUNCPROTO
|
||||
#define FUNCPROTO 15
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
_XFUNCPROTOBEGIN
|
||||
|
||||
/* Porting Note:
|
||||
* If you are going to use this code somewhere other than mozilla
|
||||
* you will need to set these defines. It's pretty easy for Intel
|
||||
@@ -93,18 +95,25 @@ typedef enum
|
||||
XLIB_RGB_DITHER_MAX
|
||||
} XlibRgbDither;
|
||||
|
||||
XlibRgbHandle *
|
||||
xxlib_rgb_create_handle (const char *name, Display *display, Screen *screen);
|
||||
typedef struct
|
||||
{
|
||||
const char *handle_name;
|
||||
int pseudogray; /* emulate GrayScale via PseudoColor visuals */
|
||||
int install_colormap;
|
||||
int disallow_image_tiling;
|
||||
int disallow_mit_shmem;
|
||||
int verbose;
|
||||
XVisualInfo xtemplate;
|
||||
long xtemplate_mask;
|
||||
} XlibRgbArgs;
|
||||
|
||||
XlibRgbHandle *
|
||||
xxlib_rgb_create_handle_with_depth (const char *name, Display *display, Screen *screen, int prefDepth);
|
||||
|
||||
xxlib_rgb_create_handle (Display *display, Screen *screen,
|
||||
XlibRgbArgs *args);
|
||||
|
||||
void
|
||||
xxlib_rgb_destroy_handle (XlibRgbHandle *handle);
|
||||
|
||||
void
|
||||
xxlib_disallow_image_tiling (XlibRgbHandle *handle, Bool disallow_it);
|
||||
|
||||
unsigned long
|
||||
xxlib_rgb_xpixel_from_rgb (XlibRgbHandle *handle, uint32 rgb);
|
||||
|
||||
@@ -186,10 +195,6 @@ xxlib_rgb_ditherable (XlibRgbHandle *handle);
|
||||
void
|
||||
xxlib_rgb_set_verbose (XlibRgbHandle *handle, Bool verbose);
|
||||
|
||||
/* experimental colormap stuff */
|
||||
void
|
||||
xxlib_rgb_set_install (XlibRgbHandle *handle, Bool install);
|
||||
|
||||
void
|
||||
xxlib_rgb_set_min_colors (XlibRgbHandle *handle, int min_colors);
|
||||
|
||||
@@ -230,9 +235,7 @@ xxlib_deregister_handle(const char *name);
|
||||
XlibRgbHandle *
|
||||
xxlib_find_handle(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
_XFUNCPROTOEND
|
||||
|
||||
#endif /* !__XLIB_RGB_H__ */
|
||||
|
||||
#endif /* __XLIB_RGB_H__ */
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h> /* for strerror & memset */
|
||||
|
||||
#define FORCE_PR_LOG /* Allow logging in the release build */
|
||||
#define PR_LOGGING 1
|
||||
#include "prlog.h"
|
||||
|
||||
#include "imgScaler.h"
|
||||
#include "nsXPrintContext.h"
|
||||
#include "nsDeviceContextXP.h"
|
||||
@@ -170,10 +175,50 @@ nsXPrintContext::Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec)
|
||||
|
||||
mScreen = XpGetScreenOfContext(mPDisplay, mPContext);
|
||||
mScreenNumber = XScreenNumberOfScreen(mScreen);
|
||||
mXlibRgbHandle = xxlib_rgb_create_handle_with_depth("xprint", mPDisplay, mScreen, prefDepth);
|
||||
|
||||
XlibRgbArgs xargs;
|
||||
memset(&xargs, 0, sizeof(xargs));
|
||||
xargs.handle_name = "xprint";
|
||||
xargs.disallow_image_tiling = True; /* XlibRGB's "Image tiling"-hack is
|
||||
* incompatible to Xprint API */
|
||||
|
||||
/* What about B/W-only printers ?! */
|
||||
if (mIsGrayscale)
|
||||
{
|
||||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("printing grayscale\n"));
|
||||
/* 1st attempt using StaticGray */
|
||||
xargs.xtemplate.c_class = StaticGray;
|
||||
xargs.xtemplate.depth = 8;
|
||||
xargs.xtemplate_mask = VisualClassMask|VisualDepthMask;
|
||||
mXlibRgbHandle = xxlib_rgb_create_handle(mPDisplay, mScreen, &xargs);
|
||||
if (!mXlibRgbHandle)
|
||||
{
|
||||
/* 2nd attempt using GrayScale */
|
||||
xargs.xtemplate.c_class = GrayScale;
|
||||
xargs.xtemplate.depth = 8;
|
||||
xargs.xtemplate_mask = VisualClassMask|VisualDepthMask;
|
||||
mXlibRgbHandle = xxlib_rgb_create_handle(mPDisplay, mScreen, &xargs);
|
||||
if (!mXlibRgbHandle)
|
||||
{
|
||||
/* Last attempt: Emulate StaticGray via Pseudocolor colormap */
|
||||
xargs.xtemplate_mask = 0L;
|
||||
xargs.xtemplate.depth = 0;
|
||||
xargs.pseudogray = True;
|
||||
mXlibRgbHandle = xxlib_rgb_create_handle(mPDisplay, mScreen, &xargs);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("printing color\n"));
|
||||
xargs.xtemplate.depth = prefDepth;
|
||||
xargs.xtemplate.c_class = (prefDepth>12)?(TrueColor):(PseudoColor);
|
||||
xargs.xtemplate_mask = VisualDepthMask|VisualClassMask;
|
||||
mXlibRgbHandle = xxlib_rgb_create_handle(mPDisplay, mScreen, &xargs);
|
||||
}
|
||||
|
||||
if (!mXlibRgbHandle)
|
||||
return NS_ERROR_GFX_PRINTER_INVALID_ATTRIBUTE;
|
||||
xxlib_disallow_image_tiling(mXlibRgbHandle, TRUE);
|
||||
|
||||
XpGetPageDimensions(mPDisplay, mPContext, &width, &height, &rect);
|
||||
rv = SetupWindow(rect.x, rect.y, rect.width, rect.height);
|
||||
@@ -841,24 +886,13 @@ nsXPrintContext::DrawImageBits(xGC *xgc,
|
||||
image_gc = *xgc;
|
||||
}
|
||||
|
||||
if( mIsGrayscale )
|
||||
{
|
||||
xxlib_draw_gray_image(mXlibRgbHandle,
|
||||
mDrawable,
|
||||
image_gc,
|
||||
aX, aY, aWidth, aHeight,
|
||||
NS_XPRINT_RGB_DITHER,
|
||||
image_bits, row_bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle,
|
||||
mDrawable,
|
||||
image_gc,
|
||||
aX, aY, aWidth, aHeight,
|
||||
NS_XPRINT_RGB_DITHER,
|
||||
image_bits, row_bytes);
|
||||
}
|
||||
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle,
|
||||
mDrawable,
|
||||
image_gc,
|
||||
aX, aY, aWidth, aHeight,
|
||||
NS_XPRINT_RGB_DITHER,
|
||||
image_bits, row_bytes);
|
||||
|
||||
if( alpha_pixmap != None )
|
||||
{
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
* GPL.
|
||||
*/
|
||||
|
||||
#ifndef NeedFunctionPrototypes
|
||||
#define NeedFunctionPrototypes (1) /* is this legal from within an app. !? */
|
||||
#endif
|
||||
/* Force ANSI C prototypes from X11 headers */
|
||||
#ifndef FUNCPROTO
|
||||
#define FUNCPROTO 15
|
||||
#endif /* !FUNCPROTO */
|
||||
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/extensions/Print.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
@@ -176,69 +176,86 @@ PR_END_EXTERN_C
|
||||
|
||||
NS_METHOD nsAppShell::Create(int* bac, char ** bav)
|
||||
{
|
||||
char *mArgv[1];
|
||||
int mArgc = 0;
|
||||
|
||||
int argc = bac ? *bac : 0;
|
||||
char **argv = bav;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if(NS_FAILED(rv))
|
||||
argc = bac ? *bac : 0;
|
||||
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if(NS_FAILED(rv))
|
||||
argv = bav;
|
||||
}
|
||||
|
||||
#ifdef NOT_NOW
|
||||
if (!XInitThreads()) {
|
||||
NS_WARNING("XInitThreads failed");
|
||||
/* fatal ! */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *displayName=nsnull;
|
||||
bool synchronize=false;
|
||||
|
||||
for (int i = 0; ++i < argc-1; )
|
||||
/*allow both --display and -display*/
|
||||
if (COMPARE_FLAG12 ("display",argv[i])){
|
||||
displayName=argv[i+1];
|
||||
break;
|
||||
}
|
||||
for (int j = 0; ++j < argc; )
|
||||
if (COMPARE_FLAG2 ("sync",argv[j])){
|
||||
synchronize=true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* setup locale */
|
||||
if (!setlocale (LC_ALL,""))
|
||||
NS_WARNING("locale not supported by C library");
|
||||
|
||||
if (!XSupportsLocale ()) {
|
||||
NS_WARNING("locale not supported by Xlib, locale set to C");
|
||||
setlocale (LC_ALL, "C");
|
||||
}
|
||||
|
||||
if (!XSetLocaleModifiers (""))
|
||||
NS_WARNING("can not set locale modifiers");
|
||||
|
||||
// Open the display
|
||||
/* Create the Xt Application context... */
|
||||
if (mAppContext == nsnull) {
|
||||
int argc = bac ? *bac : 0;
|
||||
char **argv = bav;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs = do_GetService(kCmdLineServiceCID);
|
||||
if (cmdLineArgs) {
|
||||
rv = cmdLineArgs->GetArgc(&argc);
|
||||
if(NS_FAILED(rv))
|
||||
argc = bac ? *bac : 0;
|
||||
|
||||
rv = cmdLineArgs->GetArgv(&argv);
|
||||
if(NS_FAILED(rv))
|
||||
argv = bav;
|
||||
}
|
||||
|
||||
char *displayName = nsnull;
|
||||
Bool synchronize = False;
|
||||
int i;
|
||||
XlibRgbArgs xargs;
|
||||
memset(&xargs, 0, sizeof(xargs));
|
||||
/* Use a "well-known" name that other modules can "look-up" this handle
|
||||
* via |xxlib_find_handle| ... */
|
||||
xargs.handle_name = XXLIBRGB_DEFAULT_HANDLE;
|
||||
|
||||
for (i = 0; ++i < argc-1; ) {
|
||||
/* allow both --display and -display */
|
||||
if (COMPARE_FLAG12 ("display", argv[i])) {
|
||||
displayName=argv[i+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; ++i < argc-1; ) {
|
||||
if (COMPARE_FLAG1 ("visual", argv[i])) {
|
||||
xargs.xtemplate_mask |= VisualIDMask;
|
||||
xargs.xtemplate.visualid = strtol(argv[i+1], NULL, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; ++i < argc; ) {
|
||||
if (COMPARE_FLAG1 ("sync", argv[i])) {
|
||||
synchronize = True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; ++i < argc; ) {
|
||||
/* allow both --no-xshm and -no-xshm */
|
||||
if (COMPARE_FLAG12 ("no-xshm", argv[i])) {
|
||||
xargs.disallow_mit_shmem = True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; ++i < argc; ) {
|
||||
if (COMPARE_FLAG1 ("install_colormap", argv[i])) {
|
||||
xargs.install_colormap = True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* setup locale */
|
||||
if (!setlocale (LC_ALL,""))
|
||||
NS_WARNING("locale not supported by C library");
|
||||
|
||||
if (!XSupportsLocale ()) {
|
||||
NS_WARNING("locale not supported by Xlib, locale set to C");
|
||||
setlocale (LC_ALL, "C");
|
||||
}
|
||||
|
||||
if (!XSetLocaleModifiers (""))
|
||||
NS_WARNING("can not set locale modifiers");
|
||||
|
||||
XtToolkitInitialize();
|
||||
mAppContext = XtCreateApplicationContext();
|
||||
|
||||
if (!(mDisplay = XtOpenDisplay (mAppContext, displayName,
|
||||
"Mozilla5", "Mozilla5", nsnull, 0,
|
||||
&mArgc, mArgv)))
|
||||
&argc, argv)))
|
||||
{
|
||||
fprintf (stderr, "%s: unable to open display \"%s\"\n", mArgv[0], XDisplayName(displayName));
|
||||
fprintf (stderr, "%s: unable to open display \"%s\"\n", argv[0], XDisplayName(displayName));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -253,10 +270,14 @@ NS_METHOD nsAppShell::Create(int* bac, char ** bav)
|
||||
NS_WARNING("running via unbuffered X connection.");
|
||||
XSynchronize(mDisplay, True);
|
||||
}
|
||||
|
||||
mXlib_rgb_handle = xxlib_rgb_create_handle(XXLIBRGB_DEFAULT_HANDLE, mDisplay, XDefaultScreenOfDisplay(mDisplay));
|
||||
|
||||
mXlib_rgb_handle = xxlib_rgb_create_handle(mDisplay, XDefaultScreenOfDisplay(mDisplay),
|
||||
&xargs);
|
||||
if (!mXlib_rgb_handle)
|
||||
abort();
|
||||
{
|
||||
fprintf (stderr, "%s: unable to create Xlib context\n", argv[0]);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsAppShell::Create(dpy=%p)\n",
|
||||
|
||||
Reference in New Issue
Block a user