зеркало из https://github.com/mozilla/gecko-dev.git
landing MODULAR_IMGLIB_BRANCH
This commit is contained in:
Родитель
0a41929fcc
Коммит
e46017e860
|
@ -25,7 +25,7 @@ LIBRARY_NAME = xfeicons
|
|||
CSRCS = $(ICONS_GEN_SRC)
|
||||
EXPORTS = $(ICONS_GEN_HDR) icondata.h
|
||||
|
||||
REQUIRES = img java jtools layer nspr util xp
|
||||
REQUIRES = img java jtools layer nspr util xp xpcom
|
||||
|
||||
LOCAL_INCLUDES = -I. -I$(OBJDIR)
|
||||
|
||||
|
@ -151,7 +151,9 @@ MKICONS_LIB = \
|
|||
$(DIST)/lib/libnspr21.a \
|
||||
$(DIST)/lib/libjpeg.a \
|
||||
$(DIST)/lib/libutil.a \
|
||||
$(DIST)/lib/libxp.a
|
||||
$(DIST)/lib/libxp.a \
|
||||
$(DIST)/lib/libplc21.a \
|
||||
$(DIST)/lib/libxpcom.a
|
||||
endif
|
||||
|
||||
GARBAGE += $(MKICONS_EXE) \
|
||||
|
@ -169,7 +171,7 @@ MKICONS_EXTRA = $(OS_LIBS) -lm
|
|||
# XXX We need to reach into the Image Library modules's source directory to
|
||||
# get the file if.h
|
||||
$(MKICONS_EXE): mkicons.c $(MKICONS_LIB)
|
||||
$(CCF) -o $@ -I$(DEPTH)/modules/libimg/src $< $(MKICONS_LIB) $(MKICONS_EXTRA)
|
||||
$(CCC) $(CFLAGS) -o $@ -I$(DEPTH)/modules/libimg/src $< $(MKICONS_LIB) $(MKICONS_EXTRA)
|
||||
|
||||
$(ICONLIST): $(ICONS)
|
||||
@echo Adding icons to $@
|
||||
|
|
|
@ -48,12 +48,15 @@ static char* header_comment =
|
|||
" * Questions to malmer@netscape.com.\n"
|
||||
" */\n\n";
|
||||
|
||||
#include "if.h" /* Image Library private header. */
|
||||
|
||||
#include "if.h" /* Image Library private header. */
|
||||
#include "libimg.h" /* Image Library public API. */
|
||||
#include "il_util.h" /* Colormap/colorspace API. */
|
||||
#include "il_strm.h" /* Image Library stream converters. */
|
||||
|
||||
#include "structs.h" /* For MWContext. */
|
||||
#include "ilINetReader.h"
|
||||
#include "ilIURL.h"
|
||||
|
||||
#define MAX_ANIMS 10
|
||||
#define MAX_IMAGES 1000
|
||||
|
@ -66,7 +69,9 @@ void * FE_SetTimeout(TimeoutCallbackFunction func, void * closure,
|
|||
uint32 msecs) { return 0; }
|
||||
void FE_ClearTimeout(void *timer_id) {}
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
void lo_view_title(MWContext *context, char *title_str) {}
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#ifdef MOCHA
|
||||
void LM_SendImageEvent(MWContext *context, LO_ImageStruct *image_data,
|
||||
|
@ -82,7 +87,9 @@ int32 NET_GetMaxMemoryCacheSize(void) { return 1000000; }
|
|||
void NET_FreeURLStruct(URL_Struct * URL_s) {}
|
||||
int NET_InterruptWindow(MWContext * window_id) {return 0;}
|
||||
URL_Struct *NET_CreateURLStruct(const char *url, NET_ReloadMethod reload) { return 0; }
|
||||
PR_BEGIN_EXTERN_C
|
||||
History_entry * SHIST_GetCurrent(History * hist) { return 0; }
|
||||
PR_END_EXTERN_C
|
||||
int NET_GetURL (URL_Struct * URL_s, FO_Present_Types output_format,
|
||||
MWContext * context, Net_GetUrlExitFunc* exit_routine)
|
||||
{ return -1; }
|
||||
|
@ -103,8 +110,13 @@ char * NET_EscapeHTML(const char * string) { return (char *)string; }
|
|||
|
||||
extern int il_first_write(NET_StreamClass *stream, const unsigned char *str, int32 len);
|
||||
|
||||
extern ilIURL *IL_CreateIURL(URL_Struct *urls);
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
char *XP_GetBuiltinString(int16 i);
|
||||
|
||||
char *XP_GetString(int16 i);
|
||||
PR_END_EXTERN_C
|
||||
char *
|
||||
XP_GetString(int16 i)
|
||||
{
|
||||
|
@ -310,11 +322,11 @@ _IMGCB_DisplayPixmap(IMGCB* img_cb, jint op, void* dpy_cx, IL_Pixmap* image,
|
|||
images[total_images].width = img_header->width;
|
||||
images[total_images].height = img_header->height;
|
||||
if (pixmap_depth == 1)
|
||||
images[total_images].mono_bits = image->bits;
|
||||
images[total_images].mono_bits = (char*)image->bits;
|
||||
else
|
||||
images[total_images].color_bits = image->bits;
|
||||
images[total_images].color_bits = (char*)image->bits;
|
||||
if (mask)
|
||||
images[total_images].mask_bits = mask->bits;
|
||||
images[total_images].mask_bits = (char*)mask->bits;
|
||||
|
||||
for (i = 0; i < src_cmap_num_colors; i++)
|
||||
{
|
||||
|
@ -407,9 +419,9 @@ _IMGCB_DisplayPixmap(IMGCB* img_cb, jint op, void* dpy_cx, IL_Pixmap* image,
|
|||
}
|
||||
|
||||
/* Generate monochrome icon from color data. */
|
||||
scanline = image->bits;
|
||||
scanline = (unsigned char*)image->bits;
|
||||
if (mask)
|
||||
mask_scanline = mask->bits;
|
||||
mask_scanline = (unsigned char*)mask->bits;
|
||||
end = scanline + (img_header->widthBytes * img_header->height);
|
||||
row_parity = 0;
|
||||
|
||||
|
@ -468,7 +480,7 @@ _IMGCB_DisplayPixmap(IMGCB* img_cb, jint op, void* dpy_cx, IL_Pixmap* image,
|
|||
/* Mask data */
|
||||
if (mask)
|
||||
{
|
||||
scanline = mask->bits;
|
||||
scanline = (unsigned char*)mask->bits;
|
||||
end = scanline + (mask_header->widthBytes * mask_header->height);
|
||||
fprintf (stdout, "\n /* Mask Data */\n (unsigned char*)\n \"");
|
||||
column = 2;
|
||||
|
@ -503,7 +515,7 @@ _IMGCB_DisplayPixmap(IMGCB* img_cb, jint op, void* dpy_cx, IL_Pixmap* image,
|
|||
fprintf (stdout, "\n /* Color icon */\n (unsigned char*)\n \"");
|
||||
column = 2;
|
||||
|
||||
scanline = image->bits;
|
||||
scanline = (unsigned char*)image->bits;
|
||||
end = scanline + (img_header->widthBytes * img_header->height);
|
||||
for (;scanline < end; scanline += img_header->widthBytes)
|
||||
{
|
||||
|
@ -655,6 +667,8 @@ MKICON_GetImage(char *file)
|
|||
#ifdef __hpux
|
||||
void *imptr;
|
||||
#endif
|
||||
ilINetReader *reader;
|
||||
ilIURL *ilurl;
|
||||
|
||||
memset (&cx, 0, sizeof(cx));
|
||||
|
||||
|
@ -687,7 +701,7 @@ MKICON_GetImage(char *file)
|
|||
transparent. */
|
||||
|
||||
/* The container needs to have a NetContext. */
|
||||
ic->net_cx = IL_NewDummyNetContext(&cx, 0);
|
||||
ic->net_cx = (ilINetContext*)IL_NewDummyNetContext(&cx, (NET_ReloadMethod)0);
|
||||
|
||||
/* Allocate the source image header. */
|
||||
ic->src_header = XP_NEW_ZAP(NI_PixmapHeader);
|
||||
|
@ -743,7 +757,11 @@ MKICON_GetImage(char *file)
|
|||
/* Create a URL structure. */
|
||||
url = XP_NEW_ZAP (URL_Struct);
|
||||
url->address = strdup("\000\000");
|
||||
url->fe_data = ic;
|
||||
|
||||
/* Create a new net reader */
|
||||
reader = IL_NewNetReader(ic);
|
||||
ilurl = IL_CreateIURL(url);
|
||||
ilurl->SetReader(reader);
|
||||
|
||||
/* Read in the file data. */
|
||||
if (stat (file, &st))
|
||||
|
|
|
@ -95,9 +95,9 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
|||
};
|
||||
|
||||
/* Set up two quantization tables using the specified scaling */
|
||||
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
||||
jpeg_add_quant_table(cinfo, 0, (const unsigned int *)std_luminance_quant_tbl,
|
||||
scale_factor, force_baseline);
|
||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||
jpeg_add_quant_table(cinfo, 1, (const unsigned int *)std_chrominance_quant_tbl,
|
||||
scale_factor, force_baseline);
|
||||
}
|
||||
|
||||
|
|
|
@ -885,6 +885,9 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
|
|||
#define jpeg_resync_to_restart jResyncRestart
|
||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default error-management setup */
|
||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error
|
||||
|
@ -1043,6 +1046,9 @@ EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo));
|
|||
EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,
|
||||
int desired));
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* These marker codes are exported since applications and data source modules
|
||||
* are likely to want to use them.
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
|
||||
DEPTH = ../..
|
||||
|
||||
DIRS = png classes public src
|
||||
ifdef STANDALONE_IMAGE_LIB
|
||||
DIRS = png public src
|
||||
else
|
||||
DIRS = png classes public src
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = libzlib.a libpng.a
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ PACKAGE=netscape\libimg
|
|||
JSRCS=ILPixCtl.java ILPix_t.java IMGCBIF.java IMGCB.java PSIMGCB.java \
|
||||
char_t.java int_t.java
|
||||
JMC_EXPORT=IMGCBIF IMGCB PSIMGCB
|
||||
CLASSROOT=D:\builds\clientsrc\ns\modules\libimg\classes
|
||||
CLASSROOT=$(DEPTH)\modules\libimg\classes
|
||||
|
||||
!include $(DEPTH)\config\rules.mak
|
||||
|
|
Двоичные данные
modules/libimg/macbuild/libimg.mcp
Двоичные данные
modules/libimg/macbuild/libimg.mcp
Двоичный файл не отображается.
|
@ -18,6 +18,10 @@
|
|||
#
|
||||
|
||||
DEPTH=..\..
|
||||
DIRS=png classes public src
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
DIRS = png public src
|
||||
!else
|
||||
DIRS = png classes public src
|
||||
!endif
|
||||
|
||||
!include $(DEPTH)\config\rules.mak
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
# This is a list of local files which get copied to the mozilla:dist:libimg directory
|
||||
#
|
||||
|
||||
il_types.h
|
||||
ni_pixmp.h
|
||||
libimg.h
|
||||
MIMGCB.h
|
||||
MIMGCBIF.h
|
||||
MPSIMGCB.h
|
||||
dummy_nc.h
|
||||
ilIImageRenderer.h
|
||||
ilINetContext.h
|
||||
ilINetReader.h
|
||||
ilISystemServices.h
|
||||
ilIURL.h
|
||||
il_icons.h
|
||||
il_strm.h
|
||||
il_types.h
|
||||
il_util.h
|
||||
dummy_nc.h
|
||||
MIMGCBIF.h
|
||||
MIMGCB.h
|
||||
MPSIMGCB.h
|
||||
libimg.h
|
||||
ni_pixmp.h
|
||||
|
|
|
@ -24,19 +24,31 @@ DEPTH = ../../..
|
|||
|
||||
MODULE = img
|
||||
|
||||
ifndef STANDALONE_IMAGE_LIB
|
||||
JMC_GEN = MIMGCBIF MIMGCB MPSIMGCB
|
||||
JMC_GEN_FLAGS = -cimpl -noexc -interface
|
||||
endif
|
||||
|
||||
ifdef STANDALONE_IMAGE_LIB
|
||||
EXPORTS = il_types.h ni_pixmp.h libimg.h il_icons.h il_strm.h il_util.h \
|
||||
ilINetContext.h ilIURL.h ilINetReader.h ilIImageRenderer.h \
|
||||
ilISystemServices.h dummy_nc.h
|
||||
else
|
||||
EXPORTS = il_types.h \
|
||||
ni_pixmp.h \
|
||||
libimg.h \
|
||||
il_icons.h \
|
||||
il_strm.h \
|
||||
il_util.h \
|
||||
ilIImageRenderer.h \
|
||||
ilINetContext.h \
|
||||
ilINetReader.h \
|
||||
ilIURL.h \
|
||||
dummy_nc.h \
|
||||
$(JMC_GEN_DIR)/MIMGCBIF.h \
|
||||
$(JMC_GEN_DIR)/MIMGCB.h \
|
||||
$(JMC_GEN_DIR)/MPSIMGCB.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
|
|
@ -23,18 +23,13 @@
|
|||
#ifndef _DUMMY_NC_H
|
||||
#define _DUMMY_NC_H
|
||||
|
||||
#include "xp_mem.h"
|
||||
#include "prtypes.h"
|
||||
#include "net.h"
|
||||
|
||||
typedef struct {
|
||||
void *cx; /* Opaque pointer to an MWContext. */
|
||||
NET_ReloadMethod cache_reload_policy;
|
||||
} IL_NetContext;
|
||||
typedef void* IL_NetContext;
|
||||
|
||||
typedef URL_Struct IL_URL;
|
||||
typedef NET_StreamClass IL_Stream;
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
extern IL_NetContext *
|
||||
IL_NewDummyNetContext(MWContext *context,
|
||||
NET_ReloadMethod cache_reload_policy);
|
||||
|
@ -42,11 +37,6 @@ IL_NewDummyNetContext(MWContext *context,
|
|||
extern void
|
||||
IL_DestroyDummyNetContext(IL_NetContext *net_cx);
|
||||
|
||||
extern IL_NetContext *
|
||||
IL_CloneDummyNetContext(IL_NetContext *net_cx);
|
||||
|
||||
extern void
|
||||
IL_AddReferer(IL_NetContext *net_cx, URL_Struct *urls);
|
||||
XP_END_PROTOS
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* _DUMMY_NC_H */
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ilIImageRenderer_h___
|
||||
#define ilIImageRenderer_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "libimg.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// IID for the nsIImageRenderer interface
|
||||
#define IL_IIMAGERENDERER_IID \
|
||||
{ 0xec4e9fc0, 0xb1f3, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } };
|
||||
|
||||
/**
|
||||
* Interface to be implemented by image creation and rendering
|
||||
* component plugged into the image library.
|
||||
*/
|
||||
class ilIImageRenderer : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* This is the function invoked for allocating pixmap storage and
|
||||
* platform-specific pixmap resources.
|
||||
*
|
||||
* On entry, the native color space and the original dimensions of the
|
||||
* source image and its mask are initially filled in the two provided
|
||||
* IL_Pixmap arguments. (If no mask or alpha channel is present, the
|
||||
* second pixmap is NULL.)
|
||||
*
|
||||
* The width and height arguments represent the desired dimensions of the
|
||||
* target image. If the implementation supports scaling, then the
|
||||
* storage allocated for the IL_Pixmaps may be based on the original
|
||||
* dimensions of the source image. In this case, the headers of the
|
||||
* IL_Pixmap should not be modified, however, the implementation
|
||||
* should be able to determine the target dimensions of the image for
|
||||
* a given IL_Pixmap. (The opaque client_data pointer in the IL_Pixmap
|
||||
* structure can be used to store the target image dimensions or a scale
|
||||
* factor.)
|
||||
*
|
||||
* If the implementation does not support scaling, the supplied width
|
||||
* and height must be used as the dimensions of the created pixmap storage
|
||||
* and the headers within the IL_Pixmap should be side-effected to reflect
|
||||
* that change.
|
||||
*
|
||||
* The allocator may side-effect the image and mask headers to target
|
||||
* a different colorspace.
|
||||
*
|
||||
* The allocation function should side-effect bits, a member of the
|
||||
* IL_Pixmap structure, to point to allocated storage. If there are
|
||||
* insufficient resources to allocate both the image and mask, neither
|
||||
* should be allocated. (The bits pointers, initially NULL-valued,
|
||||
* should not be altered.)
|
||||
*/
|
||||
virtual void NewPixmap(void* aDisplayContext,
|
||||
PRInt32 aWidth, PRInt32 aHeight,
|
||||
IL_Pixmap* aImage, IL_Pixmap* aMask)=0;
|
||||
|
||||
/**
|
||||
* Inform the implementation that the specified rectangular portion of
|
||||
* the pixmap has been modified. This might be used, for example, to
|
||||
* transfer the altered area to the X server on a unix client.
|
||||
*
|
||||
* x_offset and y_offset are measured in pixels, with the
|
||||
* upper-left-hand corner of the pixmap as the origin, increasing
|
||||
* left-to-right, top-to-bottom.
|
||||
*/
|
||||
virtual void UpdatePixmap(void* aDisplayContext,
|
||||
IL_Pixmap* aImage,
|
||||
PRInt32 aXOffset, PRInt32 aYOffset,
|
||||
PRInt32 aWidth, PRInt32 aHeight)=0;
|
||||
|
||||
/**
|
||||
* Informs the callee that the imagelib has acquired or relinquished
|
||||
* control over the IL_Pixmap's bits. The message argument should be
|
||||
* one of IL_LOCK_BITS, IL_UNLOCK_BITS or IL_RELEASE_BITS.
|
||||
*
|
||||
* The imagelib will issue an IL_LOCK_BITS message whenever it wishes to
|
||||
* alter the bits. When the imaglib has finished altering the bits, it will
|
||||
* issue an IL_UNLOCK_BITS message. These messages are provided so that
|
||||
* the callee may perform memory-management tasks during the time that
|
||||
* the imagelib is not writing to the pixmap's buffer.
|
||||
*
|
||||
* Once the imagelib is sure that it will not modify the pixmap any further
|
||||
* and, therefore, will no longer dereference the bits pointer in the
|
||||
* IL_Pixmap, it will issue an IL_RELEASE_BITS request. (Requests may still
|
||||
* be made to display the pixmap, however, using whatever opaque pixmap
|
||||
* storage the callee may retain.) The IL_RELEASE_BITS message
|
||||
* could be used, for example, by an X11 front-end to free the client-side
|
||||
* image data, preserving only the server pixmap.
|
||||
*/
|
||||
virtual void ControlPixmapBits(void* aDisplayContext,
|
||||
IL_Pixmap* aImage, PRUint32 aControlMsg)=0;
|
||||
|
||||
/**
|
||||
* Release the memory storage and other resources associated with an image
|
||||
* pixmap; the pixmap will never be referenced again. The pixmap's header
|
||||
* information and the IL_Pixmap structure itself will be freed by the Image
|
||||
* Library.
|
||||
*/
|
||||
virtual void DestroyPixmap(void* aDisplayContext, IL_Pixmap* aImage)=0;
|
||||
|
||||
/**
|
||||
* Render a rectangular portion of the given pixmap.
|
||||
*
|
||||
* Render the image using transparency if mask is non-NULL.
|
||||
* x and y are measured in pixels and are in document coordinates.
|
||||
* x_offset and y_offset are with respect to the image origin.
|
||||
*
|
||||
* If the width and height values would otherwise cause the sub-image
|
||||
* to extend off the edge of the source image, the function should
|
||||
* perform tiling of the source image. This is used to draw document,
|
||||
* layer and table cell backdrops. (Note: it is assumed this case will
|
||||
* apply only to images which do not require any scaling.)
|
||||
*
|
||||
* All coordinates are in terms of the target pixmap dimensions, which
|
||||
* may differ from those of the pixmap storage if the callee
|
||||
* supports scaling.
|
||||
*/
|
||||
virtual void DisplayPixmap(void* aDisplayContext,
|
||||
IL_Pixmap* aImage, IL_Pixmap* aMask,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aXOffset, PRInt32 aYOffset,
|
||||
PRInt32 aWidth, PRInt32 aHeight)=0;
|
||||
|
||||
/**
|
||||
* <bold>(Probably temporary and subject to change).</bold>
|
||||
* Display an icon. x and y are in document coordinates.
|
||||
*/
|
||||
virtual void DisplayIcon(void* aDisplayContext,
|
||||
PRInt32 aX, PRInt32 aY, PRUint32 aIconNumber)=0;
|
||||
|
||||
/**
|
||||
* <bold>(Probably temporary and subject to change).</bold>
|
||||
* This method should fill in the targets of the width and
|
||||
* height pointers to indicate icon dimensions
|
||||
*/
|
||||
virtual void GetIconDimensions(void* aDisplayContext,
|
||||
PRInt32 *aWidthPtr, PRInt32 *aHeightPtr,
|
||||
PRUint32 aIconNumber)=0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ilINetContext_h___
|
||||
#define ilINetContext_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "ntypes.h"
|
||||
|
||||
// IID for the ilINetContext interface
|
||||
#define IL_INETCONTEXT_IID \
|
||||
{ 0x425da760, 0xb412, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class ilIURL;
|
||||
class ilINetReader;
|
||||
|
||||
class ilINetContext : public nsISupports {
|
||||
public:
|
||||
|
||||
virtual ilINetContext* Clone()=0;
|
||||
|
||||
virtual NET_ReloadMethod GetReloadPolicy()=0;
|
||||
|
||||
virtual void AddReferer(ilIURL *aUrl)=0;
|
||||
|
||||
virtual void Interrupt()=0;
|
||||
|
||||
virtual ilIURL* CreateURL(const char *aUrl,
|
||||
NET_ReloadMethod aReloadMethod)=0;
|
||||
|
||||
virtual PRBool IsLocalFileURL(char *aAddress)=0;
|
||||
|
||||
virtual PRBool IsURLInMemCache(ilIURL *aUrl)=0;
|
||||
|
||||
virtual PRBool IsURLInDiskCache(ilIURL *aUrl)=0;
|
||||
|
||||
virtual int GetURL (ilIURL * aUrl, NET_ReloadMethod aLoadMethod,
|
||||
ilINetReader *aReader)=0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ilINetReader_h___
|
||||
#define ilINetReader_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "ntypes.h"
|
||||
|
||||
// IID for the ilINetReader interface
|
||||
#define IL_INETREADER_IID \
|
||||
{ 0xbe324220, 0xb416, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class ilIURL;
|
||||
|
||||
|
||||
class ilINetReader : public nsISupports {
|
||||
public:
|
||||
|
||||
virtual unsigned int WriteReady()=0;
|
||||
|
||||
virtual int FirstWrite(const unsigned char *str, int32 len)=0;
|
||||
|
||||
virtual int Write(const unsigned char *str, int32 len)=0;
|
||||
|
||||
virtual void StreamAbort(int status)=0;
|
||||
|
||||
virtual void StreamComplete(PRBool is_multipart)=0;
|
||||
|
||||
virtual void NetRequestDone(ilIURL *urls, int status)=0;
|
||||
|
||||
virtual PRBool StreamCreated(ilIURL *urls, int type)=0;
|
||||
|
||||
virtual PRBool IsMulti()=0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ilISystemServices_h___
|
||||
#define ilISystemServices_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
|
||||
// IID for the ilISystemServices interface
|
||||
#define IL_ISYSTEMSERVICES_IID \
|
||||
{ 0xc14659e0, 0xb9fe, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
typedef void (*ilTimeoutCallbackFunction) (void * closure);
|
||||
|
||||
class ilISystemServices : public nsISupports {
|
||||
public:
|
||||
|
||||
virtual void * SetTimeout(ilTimeoutCallbackFunction aFunc,
|
||||
void * aClosure, PRUint32 aMsecs)=0;
|
||||
|
||||
virtual void ClearTimeout(void *aTimerID)=0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ilIURL_h___
|
||||
#define ilIURL_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "ntypes.h"
|
||||
|
||||
// IID for the ilIURL interface
|
||||
#define IL_IURL_IID \
|
||||
{ 0x6d7a5600, 0xb412, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class ilIURL : public nsISupports {
|
||||
public:
|
||||
virtual void SetReader(ilINetReader *aReader)=0;
|
||||
|
||||
virtual ilINetReader *GetReader()=0;
|
||||
|
||||
virtual int GetContentLength()=0;
|
||||
|
||||
virtual const char* GetAddress()=0;
|
||||
|
||||
virtual time_t GetExpires()=0;
|
||||
|
||||
virtual void SetBackgroundLoad(PRBool aBgload)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il_icons.h --- Image icon enumeration.
|
||||
* $Id: il_icons.h,v 3.1 1998/03/28 03:34:56 ltabb Exp $
|
||||
* $Id: il_icons.h,v 3.2 1998/07/27 16:09:05 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il_strm.h --- Stream converters for the image library.
|
||||
* $Id: il_strm.h,v 3.1 1998/03/28 03:34:57 ltabb Exp $
|
||||
* $Id: il_strm.h,v 3.2 1998/07/27 16:09:06 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -40,13 +40,16 @@
|
|||
#define OPAQUE_CONTEXT MWContext /* The old MWContext. */
|
||||
#endif /* IL_INTERNAL */
|
||||
|
||||
|
||||
#ifndef STANDALONE_IMAGE_LIB
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
/********************** Image Library stream converters. *********************/
|
||||
extern int IL_DisplayMemCacheInfoAsHTML(FO_Present_Types format_out,
|
||||
URL_Struct *urls,
|
||||
OPAQUE_CONTEXT *net_cx);
|
||||
|
||||
/********************** Image Library stream converters. *********************/
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
/* The standard converter for all types of images which are part of an HTML
|
||||
document. */
|
||||
|
@ -63,3 +66,5 @@ extern NET_StreamClass * IL_ViewStream (FO_Present_Types format_out,
|
|||
URL_Struct *urls,
|
||||
OPAQUE_CONTEXT *cx);
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il_types.h --- Image library data types and structures.
|
||||
* $Id: il_types.h,v 3.1 1998/03/28 03:34:57 ltabb Exp $
|
||||
* $Id: il_types.h,v 3.2 1998/07/27 16:09:07 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -27,6 +27,14 @@
|
|||
|
||||
#include "prtypes.h"
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#define IL_EXTERN(__type) PR_EXTERN(__type)
|
||||
#define IL_IMPLEMENT(__type) PR_IMPLEMENT(__type)
|
||||
#else
|
||||
#define IL_EXTERN(__type) __type
|
||||
#define IL_IMPLEMENT(__type) __type
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/************************** Notes ********************************************
|
||||
* 1. Required #defines:
|
||||
* IL_CLIENT - This should only be defined by clients of the Image Library.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il_util.h Colormap and colorspace utilities.
|
||||
*
|
||||
* $Id: il_util.h,v 3.1 1998/03/28 03:34:57 ltabb Exp $
|
||||
* $Id: il_util.h,v 3.2 1998/07/27 16:09:08 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -42,20 +42,20 @@ XP_BEGIN_PROTOS
|
|||
function represents the current state of affairs, and it will eventually
|
||||
be replaced when the Image Library has the capability to dither to an
|
||||
arbitrary palette. */
|
||||
extern IL_ColorMap *
|
||||
IL_EXTERN(IL_ColorMap *)
|
||||
IL_NewCubeColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
||||
uint16 num_colors);
|
||||
|
||||
/* Create an optimal fixed palette of the specified size, starting with
|
||||
the given set of reserved colors.
|
||||
XXX - This will not be implemented initially. */
|
||||
extern IL_ColorMap *
|
||||
IL_EXTERN(IL_ColorMap *)
|
||||
IL_NewOptimalColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
||||
uint16 num_colors);
|
||||
|
||||
/* Create an empty colormap. The caller is responsible for filling in the
|
||||
colormap entries. */
|
||||
extern IL_ColorMap *
|
||||
IL_EXTERN(IL_ColorMap *)
|
||||
IL_NewColorMap(void);
|
||||
|
||||
/* Append the specified color to an existing IL_ColorMap, returning TRUE if
|
||||
|
@ -70,19 +70,19 @@ IL_NewColorMap(void);
|
|||
to the old colormap. Therefore, the current purpose of this function is
|
||||
to add colors (such as a background color for transparent images) which
|
||||
are not a part of the Image Library's color cube. */
|
||||
extern int
|
||||
IL_EXTERN(int)
|
||||
IL_AddColorToColorMap(IL_ColorMap *cmap, IL_IRGB *new_color);
|
||||
|
||||
/* Free all memory associated with a given colormap.
|
||||
Note: This should *not* be used to destroy a colormap once it has been
|
||||
passed into IL_CreatePseudoColorSpace. Use IL_ReleaseColorSpace instead. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DestroyColorMap (IL_ColorMap *cmap);
|
||||
|
||||
/* Reorder the entries in a colormap. new_order is an array mapping the old
|
||||
indices to the new indices.
|
||||
XXX Is this really necessary? */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_ReorderColorMap(IL_ColorMap *cmap, uint16 *new_order);
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ IL_ReorderColorMap(IL_ColorMap *cmap, uint16 *new_order);
|
|||
might be necessary, e.g. for an alpha channel, or for alignment. Note: the
|
||||
contents of the IL_RGBBits structure will be copied, so they need not be
|
||||
preserved after the call to IL_CreateTrueColorSpace. */
|
||||
extern IL_ColorSpace *
|
||||
IL_EXTERN(IL_ColorSpace *)
|
||||
IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth);
|
||||
|
||||
/* Create a new Pseudo-colorspace using the given colormap and set the
|
||||
|
@ -108,7 +108,7 @@ IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth);
|
|||
the colormap, *is* available through the colormap member of the
|
||||
IL_ColorSpace. Memory associated with the colormap will be freed by
|
||||
IL_ReleaseColorSpace when the reference count reaches zero. */
|
||||
extern IL_ColorSpace *
|
||||
IL_EXTERN(IL_ColorSpace *)
|
||||
IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
|
||||
uint8 pixmap_depth);
|
||||
|
||||
|
@ -116,17 +116,17 @@ IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
|
|||
set the reference count to 1. The pixmap_depth is the index_depth plus
|
||||
any additional allowance that might be necessary e.g. for an alpha channel,
|
||||
or for alignment. */
|
||||
extern IL_ColorSpace *
|
||||
IL_EXTERN(IL_ColorSpace *)
|
||||
IL_CreateGreyScaleColorSpace(uint8 index_depth, uint8 pixmap_depth);
|
||||
|
||||
/* Decrements the reference count for an IL_ColorSpace. If the reference
|
||||
count reaches zero, all memory associated with the colorspace (including
|
||||
any colormap associated memory) will be freed. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_ReleaseColorSpace(IL_ColorSpace *color_space);
|
||||
|
||||
/* Increment the reference count for an IL_ColorSpace. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_AddRefToColorSpace(IL_ColorSpace *color_space);
|
||||
|
||||
XP_END_PROTOS
|
||||
|
|
|
@ -18,20 +18,29 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* libimg.h --- API calls to the Image Library.
|
||||
* $Id: libimg.h,v 3.1 1998/03/28 03:34:57 ltabb Exp $
|
||||
* $Id: libimg.h,v 3.2 1998/07/27 16:09:09 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBIMG_H
|
||||
#define _LIBIMG_H
|
||||
#include "xp_core.h" /* For XP_BEGIN_PROTOS/XP_END_PROTOS. */
|
||||
#include "dummy_nc.h" /* Dummy Net Context */
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "il_types.h"
|
||||
|
||||
#include "dummy_nc.h"
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "ilISystemServices.h"
|
||||
#include "ilIImageRenderer.h"
|
||||
#else
|
||||
#include "MIMGCBIF.h" /* JMC generated callback interface. */
|
||||
#include "MIMGCB.h" /* JMC generated callback interface
|
||||
implementation. */
|
||||
#include "MPSIMGCB.h" /* JMC generated callback interface
|
||||
implementation for PostScript Front End. */
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
|
||||
/*********************** Observers and Observables ***************************/
|
||||
|
||||
|
@ -48,21 +57,26 @@
|
|||
|
||||
|
||||
/**************************** Initialization *********************************/
|
||||
XP_BEGIN_PROTOS
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/* One-time image library initialization.
|
||||
- Initialize internal state.
|
||||
- Scan image plug-in directory.
|
||||
- Register individual image decoders with the netlib. */
|
||||
extern int
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
IL_EXTERN(int)
|
||||
IL_Init(ilISystemServices *ss);
|
||||
#else
|
||||
IL_EXTERN(int)
|
||||
IL_Init(void);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/* Used when exiting the client, this code frees all imagelib data structures.
|
||||
This is done for two reasons:
|
||||
- It makes leakage analysis of the heap easier.
|
||||
- It causes resources to be freed on 16-bit Windows that would otherwise
|
||||
persist beyond the program's lifetime. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_Shutdown(void);
|
||||
|
||||
|
||||
|
@ -76,8 +90,15 @@ IL_Shutdown(void);
|
|||
|
||||
The display_context argument is opaque to the image library and is
|
||||
passed back to all of the callbacks in IMGCBIF interface. */
|
||||
extern IL_GroupContext *
|
||||
IL_NewGroupContext(void *display_context, IMGCBIF *image_callbacks);
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
IL_EXTERN(IL_GroupContext *)
|
||||
IL_NewGroupContext(void *display_context,
|
||||
ilIImageRenderer *image_render);
|
||||
#else
|
||||
IL_EXTERN(IL_GroupContext *)
|
||||
IL_NewGroupContext(void *display_context,
|
||||
IMGCBIF *image_callbacks);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/* Free an image context. IL_DestroyGroupContext will make a call
|
||||
to the IMGCBIF_Release callback function of the JMC interface prior to
|
||||
|
@ -85,18 +106,18 @@ IL_NewGroupContext(void *display_context, IMGCBIF *image_callbacks);
|
|||
is expected to decrement the reference count for the IMGCBIF interface,
|
||||
and to free the callback vtable and the interface structure if the
|
||||
reference count is zero. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DestroyGroupContext(IL_GroupContext *image_context);
|
||||
|
||||
/* Add an observer/closure pair to an image group context's observer list.
|
||||
Returns PR_TRUE if the observer is successfully registered. */
|
||||
extern PRBool
|
||||
IL_EXTERN(PRBool)
|
||||
IL_AddGroupObserver(IL_GroupContext *img_cx, XP_ObserverProc observer,
|
||||
void *closure);
|
||||
|
||||
/* Remove an observer/closure pair from an image group context's observer
|
||||
list. Returns PR_TRUE if successful. */
|
||||
extern PRBool
|
||||
IL_EXTERN(PRBool)
|
||||
IL_RemoveGroupObserver(IL_GroupContext *img_cx, XP_ObserverProc observer,
|
||||
void *closure);
|
||||
|
||||
|
@ -135,19 +156,19 @@ IL_RemoveGroupObserver(IL_GroupContext *img_cx, XP_ObserverProc observer,
|
|||
There is also an assumption being made here that there is some way to
|
||||
create a Net Context from this Net Group Context in which Navigator UI
|
||||
(animation, status, progress, etc.) can be suppressed.*/
|
||||
extern IL_ImageReq *
|
||||
IL_EXTERN(IL_ImageReq *)
|
||||
IL_GetImage(const char* url,
|
||||
IL_GroupContext *image_context,
|
||||
XP_ObserverList observer_list,
|
||||
IL_IRGB *background_color,
|
||||
uint32 width, uint32 height,
|
||||
uint32 flags,
|
||||
IL_NetContext *net_context);
|
||||
void *net_context);
|
||||
|
||||
/* Release a reference to an image lib request. If there are no other
|
||||
clients of the request's associated pixmap, any related netlib
|
||||
activity is terminated and pixmap storage may be reclaimed. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DestroyImage (IL_ImageReq *image_req);
|
||||
|
||||
/* XXX - This is a new API call to reload all images associated with a
|
||||
|
@ -156,15 +177,21 @@ IL_DestroyImage (IL_ImageReq *image_req);
|
|||
on memory considerations. This process involves the destruction of the
|
||||
old IL_Pixmap structures and the allocation of new structures corresponding
|
||||
to the new bit depth. */
|
||||
extern void
|
||||
IL_ReloadImages(IL_GroupContext *image_context, IL_NetContext *net_context);
|
||||
IL_EXTERN(void)
|
||||
IL_ReloadImages(IL_GroupContext *image_context, void *net_context);
|
||||
|
||||
/* Halt decoding of images or animation without destroying associated
|
||||
pixmap data. This may abort any associated netlib streams. All
|
||||
IL_ImageReq's created with the given IL_GroupContext are interrupted. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_InterruptContext(IL_GroupContext *image_context);
|
||||
|
||||
/* Halt decoding or animation of a specific image request without
|
||||
destroying associated pixmap data. */
|
||||
|
||||
IL_EXTERN(void)
|
||||
IL_InterruptRequest(IL_ImageReq *image_req);
|
||||
|
||||
/* Display a rectangular portion of an image. x and y refer to the top left
|
||||
corner of the image, measured in pixels, with respect to the document
|
||||
origin. x_offset and y_offset are measured in pixels, with the
|
||||
|
@ -181,17 +208,17 @@ IL_InterruptContext(IL_GroupContext *image_context);
|
|||
be fulfilled or that the image has been delayed, it will notify the client
|
||||
synchronously through the observer mechanism. The client may then choose to
|
||||
request that an icon be drawn instead by making a call to IL_DisplayIcon. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DisplaySubImage(IL_ImageReq *image_req, int x, int y, int x_offset,
|
||||
int y_offset, int width, int height);
|
||||
|
||||
/* Display an icon. x and y refer to the top left corner of the icon, measured
|
||||
in pixels, with respect to the document origin. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DisplayIcon(IL_GroupContext *img_cx, int icon_number, int x, int y);
|
||||
|
||||
/* Return the dimensions of an icon. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_GetIconDimensions(IL_GroupContext *img_cx, int icon_number, int *width,
|
||||
int *height);
|
||||
|
||||
|
@ -199,11 +226,11 @@ IL_GetIconDimensions(IL_GroupContext *img_cx, int icon_number, int *width,
|
|||
/********************* Pixmap access functions *******************************/
|
||||
|
||||
/* Return the image IL_Pixmap associated with an image request. */
|
||||
extern IL_Pixmap *
|
||||
IL_EXTERN(IL_Pixmap *)
|
||||
IL_GetImagePixmap(IL_ImageReq *image_req);
|
||||
|
||||
/* Return the mask IL_Pixmap associated with an image request. */
|
||||
extern IL_Pixmap *
|
||||
IL_EXTERN(IL_Pixmap *)
|
||||
IL_GetMaskPixmap(IL_ImageReq *image_req);
|
||||
|
||||
|
||||
|
@ -211,7 +238,7 @@ IL_GetMaskPixmap(IL_ImageReq *image_req);
|
|||
|
||||
/* Return the natural dimensions of the image. Returns 0,0 if the dimensions
|
||||
are unknown. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_GetNaturalDimensions(IL_ImageReq *image_req, int *width, int *height);
|
||||
|
||||
|
||||
|
@ -234,7 +261,7 @@ IL_GetNaturalDimensions(IL_ImageReq *image_req, int *width, int *height);
|
|||
- color_space - A pointer to the Display FE's colorspace.
|
||||
- progressive_display - Toggle for progressive image display.
|
||||
- dither_mode - IL_ClosestColor, IL_Dither or IL_Auto. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_SetDisplayMode(IL_GroupContext *image_context, uint32 display_flags,
|
||||
IL_DisplayData *display_data);
|
||||
|
||||
|
@ -242,7 +269,7 @@ IL_SetDisplayMode(IL_GroupContext *image_context, uint32 display_flags,
|
|||
/************************ Image format identification ************************/
|
||||
|
||||
/* Determine the type of the image, based on the first few bytes of data. */
|
||||
extern int
|
||||
IL_EXTERN(int)
|
||||
IL_Type(const char *buf, int32 len);
|
||||
|
||||
|
||||
|
@ -250,7 +277,7 @@ IL_Type(const char *buf, int32 len);
|
|||
|
||||
/* Set limit on approximate size, in bytes, of all pixmap storage used by the
|
||||
Image Library. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_SetCacheSize(uint32 new_size);
|
||||
|
||||
|
||||
|
@ -258,7 +285,7 @@ IL_SetCacheSize(uint32 new_size);
|
|||
|
||||
/* Free num_bytes of memory by flushing the Least Recently Used (LRU) images
|
||||
from the image cache. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_FreeMemory(IL_GroupContext *image_context, uint32 num_bytes);
|
||||
|
||||
|
||||
|
@ -268,18 +295,18 @@ IL_FreeMemory(IL_GroupContext *image_context, uint32 num_bytes);
|
|||
cache. The memory won't be released if the image is still in use
|
||||
by one or more clients. XXX - Can we get rid of this call ? Why
|
||||
the hell do we need this ? */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_UnCache(IL_Pixmap *pixmap);
|
||||
|
||||
/* Attempts to release some memory by freeing an image from the image
|
||||
cache. This may not always be possible either because all images
|
||||
in the cache are in use or because the cache is empty. Returns the
|
||||
new approximate size of the imagelib cache. */
|
||||
extern uint32
|
||||
IL_EXTERN(uint32)
|
||||
IL_ShrinkCache(void);
|
||||
|
||||
/* Return the approximate storage consumed by the imagelib cache, in bytes */
|
||||
extern uint32
|
||||
IL_EXTERN(uint32)
|
||||
IL_GetCacheSize(void);
|
||||
|
||||
|
||||
|
@ -287,23 +314,25 @@ IL_GetCacheSize(void);
|
|||
|
||||
/* Returns a pointer to a string containing HTML appropriate for displaying
|
||||
in a DocInfo window. The caller may dispose of the string using XP_FREE. */
|
||||
extern char *
|
||||
IL_EXTERN(char *)
|
||||
IL_HTMLImageInfo(char *url_address);
|
||||
|
||||
#ifndef STANDALONE_IMAGE_LIB
|
||||
/* Wacky netlib callback designed to give precedence to streams that block
|
||||
layout. */
|
||||
extern PRBool
|
||||
IL_PreferredStream(IL_URL *urls);
|
||||
IL_EXTERN(PRBool)
|
||||
IL_PreferredStream(URL_Struct *urls);
|
||||
#endif
|
||||
|
||||
/* This is a legacy "safety-valve" routine, called each time a new HTML page
|
||||
is loaded. It causes remaining references to images in the given group
|
||||
context to be freed, i.e. like calling IL_DestroyImage on each of them.
|
||||
This is primarily required because layout sometimes leaks images, and it
|
||||
should go away when we can fix layout. */
|
||||
extern void
|
||||
IL_EXTERN(void)
|
||||
IL_DestroyImageGroup(IL_GroupContext *image_context);
|
||||
|
||||
XP_END_PROTOS
|
||||
PR_END_EXTERN_C
|
||||
#endif /* _LIBIMG_H */
|
||||
|
||||
|
||||
|
|
|
@ -41,10 +41,13 @@ INSTALL_DIR=$(PUBLIC)\img
|
|||
INSTALL_DIR=$(PUBLIC)\win16
|
||||
!endif
|
||||
|
||||
LCFLAGS = $(LCFLAGS) /TP
|
||||
|
||||
|
||||
MODULE=img
|
||||
DEPTH=..\..\..
|
||||
!ifdef MOZ_JAVA
|
||||
!ifndef STANDALONE_IMAGE_LIB
|
||||
JMC_GEN=MIMGCBIF MIMGCB MPSIMGCB
|
||||
JMC_GEN_FLAGS=-cimpl -noexc -interface
|
||||
EXPORTS=il_types.h ni_pixmp.h libimg.h il_icons.h il_strm.h il_util.h \
|
||||
|
@ -56,10 +59,17 @@ JMC_STUBS=$(JMC_GEN_DIR)\MIMGCBIF.c $(JMC_GEN_DIR)\MIMGCB.c \
|
|||
$(JMC_GEN_DIR)\MPSIMGCB.c
|
||||
JMC_OBJS=.\$(OBJDIR)\MIMGCBIF.obj .\$(OBJDIR)\MIMGCB.obj \
|
||||
.\$(OBJDIR)\MPSIMGCB.obj
|
||||
!endif
|
||||
!else
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
EXPORTS=il_types.h ni_pixmp.h libimg.h il_icons.h il_strm.h il_util.h \
|
||||
ilINetContext.h ilIURL.h ilINetReader.h ilIImageRenderer.h \
|
||||
ilISystemServices.h
|
||||
!else
|
||||
EXPORTS=il_types.h ni_pixmp.h libimg.h il_icons.h il_strm.h il_util.h \
|
||||
dummy_nc.h MIMGCBIF.h MIMGCB.h MPSIMGCB.h
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
|
@ -70,6 +80,7 @@ EXPORTS=il_types.h ni_pixmp.h libimg.h il_icons.h il_strm.h il_util.h \
|
|||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
!ifdef MOZ_JAVA
|
||||
!ifndef STANDALONE_IMAGE_LIB
|
||||
$(JMC_GEN_DIR)\MIMGCBIF.h: $(JMCSRCDIR)\IMGCBIF.class
|
||||
$(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)
|
||||
$(JMC_GEN_DIR)\MIMGCBIF.c: $(JMCSRCDIR)\IMGCBIF.class
|
||||
|
@ -83,6 +94,7 @@ $(JMC_GEN_DIR)\MPSIMGCB.h: $(JMCSRCDIR)\PSIMGCB.class
|
|||
$(JMC_GEN_DIR)\MPSIMGCB.c: $(JMCSRCDIR)\PSIMGCB.class
|
||||
$(JMC) -d $(JMC_GEN_DIR) -module $(JMC_GEN_FLAGS) $(?F:.class=)
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
export:: INSTALL_FILES
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
/*
|
||||
* ni_pixmp.h --- Cross platform pixmap data structure.
|
||||
* $Id: ni_pixmp.h,v 3.1 1998/03/28 03:34:58 ltabb Exp $
|
||||
* $Id: ni_pixmp.h,v 3.2 1998/07/27 16:09:11 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "xp_mem.h"
|
||||
#include "prmem.h"
|
||||
|
||||
/* Include the implementation-specific header: */
|
||||
#include "PIMGCB.h"
|
||||
|
@ -90,7 +90,7 @@ JMC_PUBLIC_API(void)
|
|||
_IMGCB_finalize(struct IMGCB* self, jint op, JMCException* *exc)
|
||||
{
|
||||
/* Override this method and add your own finalization here. */
|
||||
XP_FREEIF(self);
|
||||
PR_FREEIF(self);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -123,7 +123,7 @@ const struct IMGCBInterface IMGCBVtable = {
|
|||
JMC_PUBLIC_API(IMGCB*)
|
||||
IMGCBFactory_Create(JMCException* *exception)
|
||||
{
|
||||
IMGCBImplHeader* impl = (IMGCBImplHeader*)XP_NEW_ZAP(IMGCBImpl);
|
||||
IMGCBImplHeader* impl = (IMGCBImplHeader*)PR_NEWZAP(IMGCBImpl);
|
||||
IMGCB* self;
|
||||
if (impl == NULL) {
|
||||
JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
|
||||
|
@ -134,7 +134,7 @@ IMGCBFactory_Create(JMCException* *exception)
|
|||
impl->refcount = 1;
|
||||
_IMGCB_init(self, exception);
|
||||
if (JMC_EXCEPTION_RETURNED(exception)) {
|
||||
XP_FREE(impl);
|
||||
PR_FREEIF(impl);
|
||||
return NULL;
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "xp_mem.h"
|
||||
#include "prmem.h"
|
||||
|
||||
/* Include the implementation-specific header: */
|
||||
#include "PPSIMGCB.h"
|
||||
|
@ -90,7 +90,7 @@ JMC_PUBLIC_API(void)
|
|||
_PSIMGCB_finalize(struct PSIMGCB* self, jint op, JMCException* *exc)
|
||||
{
|
||||
/* Override this method and add your own finalization here. */
|
||||
XP_FREEIF(self);
|
||||
PR_FREEIF(self);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -123,7 +123,7 @@ const struct PSIMGCBInterface PSIMGCBVtable = {
|
|||
JMC_PUBLIC_API(PSIMGCB*)
|
||||
PSIMGCBFactory_Create(JMCException* *exception)
|
||||
{
|
||||
PSIMGCBImplHeader* impl = (PSIMGCBImplHeader*)XP_NEW_ZAP(PSIMGCBImpl);
|
||||
PSIMGCBImplHeader* impl = (PSIMGCBImplHeader*)PR_NEWZAP(PSIMGCBImpl);
|
||||
PSIMGCB* self;
|
||||
if (impl == NULL) {
|
||||
JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
|
||||
|
@ -134,7 +134,7 @@ PSIMGCBFactory_Create(JMCException* *exception)
|
|||
impl->refcount = 1;
|
||||
_PSIMGCB_init(self, exception);
|
||||
if (JMC_EXCEPTION_RETURNED(exception)) {
|
||||
XP_FREE(impl);
|
||||
PR_FREEIF(impl);
|
||||
return NULL;
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -23,25 +23,58 @@ DEPTH = ../../..
|
|||
MODULE = img
|
||||
LIBRARY_NAME = img
|
||||
|
||||
CSRCS = color.c \
|
||||
colormap.c \
|
||||
dither.c \
|
||||
dummy_nc.c \
|
||||
external.c \
|
||||
gif.c \
|
||||
if.c \
|
||||
ilclient.c \
|
||||
il_util.c \
|
||||
jpeg.c \
|
||||
scale.c \
|
||||
xbm.c \
|
||||
ipng.c \
|
||||
png_png.c \
|
||||
ifdef STANDALONE_IMAGE_LIB
|
||||
|
||||
CPPSRCS = ilNetReader.cpp \
|
||||
xpcompat.cpp \
|
||||
color.cpp \
|
||||
colormap.cpp \
|
||||
dither.cpp \
|
||||
gif.cpp \
|
||||
if.cpp \
|
||||
ilclient.cpp \
|
||||
il_util.cpp \
|
||||
jpeg.cpp \
|
||||
scale.cpp \
|
||||
xbm.cpp \
|
||||
ipng.cpp \
|
||||
png_png.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = PIMGCB.h PPSIMGCB.h
|
||||
|
||||
REQUIRES = jtools java zlib nspr dbm jpeg util img png layer js
|
||||
REQUIRES = zlib nspr jpeg util img png xpcom
|
||||
|
||||
LOCAL_INCLUDES = -I../png -I. -I$(DEPTH)/dist/public/zlib
|
||||
|
||||
EXTRA_LIBS = $(DIST)/lib/libzlib.a $(DIST)/lib/libpng.a $(DIST)/lib/libnspr21.a $(dist)/lib/libjpeg.a $(DIST)/lib/libplc21.a $(DIST)/lib/libutil.a
|
||||
|
||||
symbols::
|
||||
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
|
||||
@echo "LIBRARY is $(LIBRARY)"
|
||||
@echo "DIST is $(DIST)"
|
||||
|
||||
else
|
||||
CPPSRCS = color.cpp \
|
||||
colormap.cpp \
|
||||
dither.cpp \
|
||||
dummy_nc.cpp \
|
||||
external.cpp \
|
||||
gif.cpp \
|
||||
if.cpp \
|
||||
ilclient.cpp \
|
||||
il_util.cpp \
|
||||
jpeg.cpp \
|
||||
scale.cpp \
|
||||
xbm.cpp \
|
||||
ipng.cpp \
|
||||
png_png.cpp \
|
||||
ilNetReader.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = PIMGCB.h PPSIMGCB.h
|
||||
|
||||
REQUIRES = jtools java zlib nspr dbm jpeg util img png layer js xpcom
|
||||
|
||||
LOCAL_INCLUDES = -I../png -I. -I$(DEPTH)/dist/public/zlib
|
||||
|
||||
|
@ -53,5 +86,14 @@ EXTRA_LIBS = $(DIST)/lib/libzlib.a $(DIST)/lib/libpng.a
|
|||
#
|
||||
JMC_GEN = MIMGCB MPSIMGCB
|
||||
JMC_GEN_FLAGS = -cimpl -noexc -module
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
#
|
||||
# This is about as far from the right way of doing things as you can get.
|
||||
# HACK larubbio fix me
|
||||
#
|
||||
ifdef STANDALONE_IMAGE_LIB
|
||||
CC = $(CCC)
|
||||
endif
|
||||
|
|
|
@ -21,15 +21,16 @@
|
|||
Includes dithering for B&W displays, but not dithering
|
||||
for PseudoColor displays which can be found in dither.c.
|
||||
|
||||
$Id: color.c,v 3.1 1998/03/28 03:34:59 ltabb Exp $
|
||||
$Id: color.cpp,v 3.1 1998/07/27 16:09:19 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#include "xp.h"
|
||||
*/
|
||||
#include "if.h"
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "xpcompat.h"
|
||||
#else
|
||||
#include "xp_qsort.h"
|
||||
#endif
|
||||
|
||||
#ifndef NSPR20
|
||||
#if defined(__sun)
|
||||
|
@ -41,6 +42,24 @@
|
|||
#pragma profile on
|
||||
#endif
|
||||
|
||||
uint8 il_identity_index_map[] = { 0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
|
||||
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
||||
88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
|
||||
104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
|
||||
119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
|
||||
134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
|
||||
149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
|
||||
164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
|
||||
179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
|
||||
194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
|
||||
209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
|
||||
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
|
||||
239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253,
|
||||
254, 255 };
|
||||
|
||||
static void
|
||||
ConvertRGBToCI(il_container *ic,
|
||||
|
@ -54,12 +73,13 @@ ConvertRGBToCI(il_container *ic,
|
|||
uint8 XP_HUGE *out = (uint8 XP_HUGE *) vout + x_offset;
|
||||
const uint8 *end = sp + 3*num;
|
||||
IL_ColorMap *cmap = &ic->image->header.color_space->cmap;
|
||||
uint8 *lookup_table = cmap->table;
|
||||
uint8 *lookup_table = (uint8 *)cmap->table;
|
||||
uint8 *index_map = cmap->index;
|
||||
|
||||
XP_ASSERT(index_map);
|
||||
if (!index_map)
|
||||
return;
|
||||
if (index_map == NULL)
|
||||
{
|
||||
index_map = il_identity_index_map;
|
||||
}
|
||||
|
||||
if (!mask)
|
||||
{
|
||||
|
@ -103,9 +123,10 @@ DitherConvertRGBToCI(il_container *ic,
|
|||
const uint8 XP_HUGE *end = out + num;
|
||||
uint8 *index_map = ic->image->header.color_space->cmap.index;
|
||||
|
||||
XP_ASSERT(index_map);
|
||||
if (!index_map)
|
||||
return;
|
||||
if (index_map == NULL)
|
||||
{
|
||||
index_map = il_identity_index_map;
|
||||
}
|
||||
|
||||
il_quantize_fs_dither(ic, mask, sp, x_offset, (uint8 XP_HUGE *) vout, num);
|
||||
if (mask) {
|
||||
|
@ -138,16 +159,16 @@ static struct fs_data *
|
|||
init_fs_dither(il_container *ic)
|
||||
{
|
||||
struct fs_data *fs;
|
||||
fs = XP_NEW_ZAP(struct fs_data);
|
||||
fs = PR_NEWZAP(struct fs_data);
|
||||
if (! fs)
|
||||
return NULL;
|
||||
|
||||
fs->width = ic->image->header.width;
|
||||
fs->direction = 1;
|
||||
fs->err1 = (long*) XP_CALLOC(fs->width+2, sizeof(long));
|
||||
fs->err2 = (long*) XP_CALLOC(fs->width+2, sizeof(long));
|
||||
fs->greypixels = (uint8 *)XP_CALLOC(fs->width+7, 1);
|
||||
fs->bwpixels = (uint8 *)XP_CALLOC(fs->width+7, 1);
|
||||
fs->err1 = (long*) PR_Calloc(fs->width+2, sizeof(long));
|
||||
fs->err2 = (long*) PR_Calloc(fs->width+2, sizeof(long));
|
||||
fs->greypixels = (uint8 *)PR_Calloc(fs->width+7, 1);
|
||||
fs->bwpixels = (uint8 *)PR_Calloc(fs->width+7, 1);
|
||||
#ifdef XP_UNIX
|
||||
{
|
||||
int i;
|
||||
|
@ -379,7 +400,7 @@ ConvertRGBToRGB8(il_container *ic,
|
|||
uint8 XP_HUGE *out = (uint8 XP_HUGE *) vout + x_offset;
|
||||
const uint8 *end = sp + num*3;
|
||||
il_ColorSpaceData *private_data =
|
||||
ic->image->header.color_space->private_data;
|
||||
(il_ColorSpaceData *)ic->image->header.color_space->private_data;
|
||||
uint8 *rm = (uint8*)private_data->r8torgbn;
|
||||
uint8 *gm = (uint8*)private_data->g8torgbn;
|
||||
uint8 *bm = (uint8*)private_data->b8torgbn;
|
||||
|
@ -425,7 +446,7 @@ ConvertRGBToRGB16(il_container *ic,
|
|||
uint16 XP_HUGE *out = (uint16 XP_HUGE *) vout + x_offset;
|
||||
const uint8 *end = sp + num*3;
|
||||
il_ColorSpaceData *private_data =
|
||||
ic->image->header.color_space->private_data;
|
||||
(il_ColorSpaceData *)ic->image->header.color_space->private_data;
|
||||
uint16 *rm = (uint16*)private_data->r8torgbn;
|
||||
uint16 *gm = (uint16*)private_data->g8torgbn;
|
||||
uint16 *bm = (uint16*)private_data->b8torgbn;
|
||||
|
@ -507,7 +528,7 @@ ConvertRGBToRGB32(il_container *ic,
|
|||
uint32 XP_HUGE *out = (uint32 XP_HUGE *) vout + x_offset;
|
||||
const uint8 *end = sp + num*3;
|
||||
il_ColorSpaceData *private_data =
|
||||
ic->image->header.color_space->private_data;
|
||||
(il_ColorSpaceData *)ic->image->header.color_space->private_data;
|
||||
uint32 *rm = (uint32*)private_data->r8torgbn;
|
||||
uint32 *gm = (uint32*)private_data->g8torgbn;
|
||||
uint32 *bm = (uint32*)private_data->b8torgbn;
|
||||
|
@ -570,8 +591,8 @@ unique_map_colors(NI_ColorMap *cmap)
|
|||
|
||||
max_colors = -num_colors;
|
||||
|
||||
XP_ASSERT(max_colors <= 256);
|
||||
XP_ASSERT(map);
|
||||
PR_ASSERT(max_colors <= 256);
|
||||
PR_ASSERT(map);
|
||||
|
||||
/* Convert RGB values into indices. */
|
||||
for (i = 0; i < max_colors; i++) {
|
||||
|
@ -624,9 +645,9 @@ il_init_rgb_depth_tables(IL_ColorSpace *color_space)
|
|||
{
|
||||
uint8 *tmp_map; /* Array type corresponds to pixmap depth. */
|
||||
|
||||
private_data->r8torgbn = XP_ALLOC(256);
|
||||
private_data->g8torgbn = XP_ALLOC(256);
|
||||
private_data->b8torgbn = XP_ALLOC(256);
|
||||
private_data->r8torgbn = PR_MALLOC(256);
|
||||
private_data->g8torgbn = PR_MALLOC(256);
|
||||
private_data->b8torgbn = PR_MALLOC(256);
|
||||
|
||||
if (!(private_data->r8torgbn &&
|
||||
private_data->g8torgbn &&
|
||||
|
@ -660,9 +681,9 @@ il_init_rgb_depth_tables(IL_ColorSpace *color_space)
|
|||
present. */
|
||||
uint16 *tmp_map; /* Array type corresponds to pixmap depth. */
|
||||
|
||||
private_data->r8torgbn = XP_ALLOC(sizeof(uint16) * 256);
|
||||
private_data->g8torgbn = XP_ALLOC(sizeof(uint16) * 256);
|
||||
private_data->b8torgbn = XP_ALLOC(sizeof(uint16) * 256);
|
||||
private_data->r8torgbn = PR_MALLOC(sizeof(uint16) * 256);
|
||||
private_data->g8torgbn = PR_MALLOC(sizeof(uint16) * 256);
|
||||
private_data->b8torgbn = PR_MALLOC(sizeof(uint16) * 256);
|
||||
|
||||
if (!(private_data->r8torgbn &&
|
||||
private_data->g8torgbn &&
|
||||
|
@ -672,7 +693,7 @@ il_init_rgb_depth_tables(IL_ColorSpace *color_space)
|
|||
}
|
||||
|
||||
/* Compensate for Win95's sometimes-weird color quantization. */
|
||||
win95_rounding = (color_space->os_flags & WIN95_ROUNDING) != 0;
|
||||
win95_rounding = (PRBool)((color_space->os_flags & WIN95_ROUNDING) != 0);
|
||||
|
||||
#define _W1(v, b) ((v) - (1 << (7 - (b))))
|
||||
#define WACKY(v, b) ((_W1(v, b) < 0) ? 0 : _W1(v, b))
|
||||
|
@ -706,9 +727,9 @@ il_init_rgb_depth_tables(IL_ColorSpace *color_space)
|
|||
{
|
||||
uint32 *tmp_map; /* Array type corresponds to pixmap depth. */
|
||||
|
||||
private_data->r8torgbn = XP_ALLOC(sizeof(uint32) * 256);
|
||||
private_data->g8torgbn = XP_ALLOC(sizeof(uint32) * 256);
|
||||
private_data->b8torgbn = XP_ALLOC(sizeof(uint32) * 256);
|
||||
private_data->r8torgbn = PR_MALLOC(sizeof(uint32) * 256);
|
||||
private_data->g8torgbn = PR_MALLOC(sizeof(uint32) * 256);
|
||||
private_data->b8torgbn = PR_MALLOC(sizeof(uint32) * 256);
|
||||
|
||||
if (!(private_data->r8torgbn &&
|
||||
private_data->g8torgbn &&
|
||||
|
@ -736,7 +757,7 @@ il_init_rgb_depth_tables(IL_ColorSpace *color_space)
|
|||
default:
|
||||
ILTRACE(0,("il: unsupported truecolor pixmap_depth: %d bpp",
|
||||
pixmap_depth));
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -767,6 +788,7 @@ il_setup_color_space_converter(il_container *ic)
|
|||
if (src_color_space->type == NI_PseudoColor)
|
||||
unique_map_colors(&src_color_space->cmap);
|
||||
|
||||
|
||||
#ifndef M12N /* XXXM12N Fix me. */
|
||||
#ifdef XP_MAC
|
||||
if ((ic->type == IL_GIF) && (ic->image->depth != 1)) {
|
||||
|
@ -797,6 +819,12 @@ il_setup_color_space_converter(il_container *ic)
|
|||
case IL_GreyToPseudo:
|
||||
case IL_PseudoToPseudo:
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
if (src_color_space == img_color_space) {
|
||||
ic->converter = NULL;
|
||||
return PR_TRUE;
|
||||
} else
|
||||
#endif
|
||||
/* Resolve dither_mode if necessary. */
|
||||
if (dither_mode == IL_Auto) {
|
||||
int num_colors = src_color_space->cmap.num_colors;
|
||||
|
@ -807,7 +835,7 @@ il_setup_color_space_converter(il_container *ic)
|
|||
dither_mode = IL_ClosestColor;
|
||||
|
||||
ILTRACE(1,("Dithering turned off; Image has %d colors: %s",
|
||||
num_colors, ic->url ? ic->url->address : ""));
|
||||
num_colors, ic->url ? ic->url_address : ""));
|
||||
}
|
||||
else {
|
||||
dither_mode = IL_Dither;
|
||||
|
@ -861,7 +889,7 @@ il_setup_color_space_converter(il_container *ic)
|
|||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -885,7 +913,7 @@ il_setup_color_space_converter(il_container *ic)
|
|||
|
||||
default:
|
||||
converter = NULL;
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* colormap.c
|
||||
*
|
||||
* $Id: colormap.c,v 3.1 1998/03/28 03:35:00 ltabb Exp $
|
||||
* $Id: colormap.cpp,v 3.1 1998/07/27 16:09:21 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,371 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "if.h"
|
||||
#include "il.h"
|
||||
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jerror.h"
|
||||
#include "jpegint.h"
|
||||
|
||||
|
||||
/* BEGIN code adapted from jpeg library */
|
||||
|
||||
typedef INT32 FSERROR; /* 16 bits should be enough */
|
||||
typedef int LOCFSERROR; /* use 'int' for calculation temps */
|
||||
|
||||
typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */
|
||||
|
||||
typedef struct my_cquantize_str {
|
||||
/* Variables for Floyd-Steinberg dithering */
|
||||
FSERRPTR fserrors[3]; /* accumulated errors */
|
||||
boolean on_odd_row; /* flag to remember which row we are on */
|
||||
} my_cquantize;
|
||||
|
||||
typedef my_cquantize *my_cquantize_ptr;
|
||||
|
||||
static JSAMPLE *the_sample_range_limit = NULL;
|
||||
|
||||
/* allocate and fill in the sample_range_limit table */
|
||||
int
|
||||
il_setup_quantize(void)
|
||||
{
|
||||
JSAMPLE *table;
|
||||
int i;
|
||||
|
||||
if(the_sample_range_limit)
|
||||
return TRUE;
|
||||
|
||||
/* lost for ever */
|
||||
table = (JSAMPLE *)PR_MALLOC((5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
||||
if (!table)
|
||||
{
|
||||
ILTRACE(1,("il: range limit table lossage"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
|
||||
the_sample_range_limit = table;
|
||||
|
||||
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
|
||||
XP_BZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
|
||||
|
||||
/* Main part of "simple" table: limit[x] = x */
|
||||
for (i = 0; i <= MAXJSAMPLE; i++)
|
||||
table[i] = (JSAMPLE) i;
|
||||
|
||||
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
|
||||
|
||||
/* End of simple table, rest of first half of post-IDCT table */
|
||||
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
|
||||
table[i] = MAXJSAMPLE;
|
||||
|
||||
/* Second half of post-IDCT table */
|
||||
XP_BZERO(table + (2 * (MAXJSAMPLE+1)),
|
||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
||||
XP_MEMCPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
|
||||
the_sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Must remain idempotent. Also used to make sure that the ic->quantize has the same
|
||||
colorSpace info as the rest of ic. */
|
||||
int
|
||||
il_init_quantize(il_container *ic)
|
||||
{
|
||||
size_t arraysize;
|
||||
int i, j;
|
||||
my_cquantize_ptr cquantize;
|
||||
|
||||
if (ic->quantize)
|
||||
il_free_quantize(ic);
|
||||
|
||||
ic->quantize = PR_NEWZAP(my_cquantize);
|
||||
if (!ic->quantize)
|
||||
{
|
||||
loser:
|
||||
ILTRACE(0,("il: MEM il_init_quantize"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cquantize = (my_cquantize_ptr) ic->quantize;
|
||||
arraysize = (size_t) ((ic->image->header.width + 2) * SIZEOF(FSERROR));
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
cquantize->fserrors[i] = (FSERRPTR) PR_Calloc(1, arraysize);
|
||||
if (!cquantize->fserrors[i])
|
||||
{
|
||||
/* ran out of memory part way thru */
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
if (cquantize->fserrors[j])
|
||||
{
|
||||
PR_FREEIF(cquantize->fserrors[j]);
|
||||
cquantize->fserrors[j]=0;
|
||||
}
|
||||
}
|
||||
if (cquantize)
|
||||
{
|
||||
PR_FREEIF(cquantize);
|
||||
ic->quantize = 0;
|
||||
}
|
||||
goto loser;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
** Free up quantizer information attached to ic. If this is the last
|
||||
** quantizer then free up the sample range limit table.
|
||||
*/
|
||||
void
|
||||
il_free_quantize(il_container *ic)
|
||||
{
|
||||
my_cquantize_ptr cquantize = (my_cquantize_ptr) ic->quantize;
|
||||
int i;
|
||||
|
||||
if (cquantize)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (il_debug > 5)
|
||||
ILTRACE(1,("il: 0x%x: free quantize", ic));
|
||||
#endif
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (cquantize->fserrors[i])
|
||||
{
|
||||
PR_FREEIF(cquantize->fserrors[i]);
|
||||
cquantize->fserrors[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PR_FREEIF(cquantize);
|
||||
ic->quantize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* floyd-steinberg dithering */
|
||||
|
||||
#ifdef XP_MAC
|
||||
#ifndef powerc
|
||||
#pragma peephole on
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void
|
||||
il_quantize_fs_dither(il_container *ic, const uint8 *mask,
|
||||
const uint8 *input_buf, int x_offset,
|
||||
uint8 XP_HUGE *output_buf, int width)
|
||||
{
|
||||
my_cquantize_ptr cquantize;
|
||||
register LOCFSERROR r_cur, g_cur, b_cur; /* current error or pixel
|
||||
value */
|
||||
LOCFSERROR r_belowerr, g_belowerr, b_belowerr; /* error for pixel below
|
||||
cur */
|
||||
LOCFSERROR r_bpreverr, g_bpreverr, b_bpreverr; /* error for below/prev
|
||||
col */
|
||||
LOCFSERROR r_bnexterr, g_bnexterr, b_bnexterr; /* error for below/next
|
||||
col */
|
||||
LOCFSERROR delta;
|
||||
FSERRPTR r_errorptr, g_errorptr, b_errorptr; /* fserrors[] at column
|
||||
before current */
|
||||
const JSAMPLE* input_ptr;
|
||||
JSAMPLE XP_HUGE * output_ptr;
|
||||
IL_ColorMap *cmap = &ic->image->header.color_space->cmap;
|
||||
IL_RGB *map = cmap->map; /* The colormap array. */
|
||||
IL_RGB *map_entry; /* Current entry in the colormap. */
|
||||
uint8 *lookup_table = (uint8 *)cmap->table; /* Lookup table for the colormap. */
|
||||
const uint8 *maskp;
|
||||
uint8 map_index;
|
||||
int dir; /* 1 for left-to-right, -1 for right-to-left */
|
||||
JDIMENSION col;
|
||||
JSAMPLE *range_limit = the_sample_range_limit;
|
||||
SHIFT_TEMPS
|
||||
|
||||
cquantize = (my_cquantize_ptr) ic->quantize;
|
||||
|
||||
output_buf += x_offset;
|
||||
|
||||
/* Initialize output values to 0 so can process components separately */
|
||||
if (mask) {
|
||||
output_ptr = output_buf;
|
||||
maskp = mask;
|
||||
for (col = width; col > 0; col--)
|
||||
*output_ptr++ &= ~*maskp++;
|
||||
} else {
|
||||
XP_BZERO((void XP_HUGE *) output_buf,
|
||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
||||
}
|
||||
|
||||
input_ptr = input_buf;
|
||||
output_ptr = output_buf;
|
||||
maskp = mask;
|
||||
if (cquantize->on_odd_row) {
|
||||
int total_offset;
|
||||
|
||||
/* work right to left in this row */
|
||||
input_ptr += 3 * width - 1; /* so point to the blue sample of the
|
||||
rightmost pixel */
|
||||
output_ptr += width-1;
|
||||
dir = -1;
|
||||
/* => entry after last column */
|
||||
total_offset = x_offset + (width + 1);
|
||||
r_errorptr = cquantize->fserrors[0] + total_offset;
|
||||
g_errorptr = cquantize->fserrors[1] + total_offset;
|
||||
b_errorptr = cquantize->fserrors[2] + total_offset;
|
||||
maskp += (width - 1);
|
||||
}
|
||||
else {
|
||||
/* work left to right in this row */
|
||||
dir = 1;
|
||||
/* => entry before first column */
|
||||
r_errorptr = cquantize->fserrors[0] + x_offset;
|
||||
g_errorptr = cquantize->fserrors[1] + x_offset;
|
||||
b_errorptr = cquantize->fserrors[2] + x_offset;
|
||||
}
|
||||
|
||||
/* Preset error values: no error propagated to first pixel from left */
|
||||
r_cur = g_cur = b_cur = 0;
|
||||
|
||||
/* and no error propagated to row below yet */
|
||||
r_belowerr = g_belowerr = b_belowerr = 0;
|
||||
r_bpreverr = g_bpreverr = b_bpreverr = 0;
|
||||
|
||||
for (col = width; col > 0; col--) {
|
||||
/* cur holds the error propagated from the previous pixel on the
|
||||
* current line. Add the error propagated from the previous line
|
||||
* to form the complete error correction term for this pixel, and
|
||||
* round the error term (which is expressed * 16) to an integer.
|
||||
* RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct
|
||||
* for either sign of the error value.
|
||||
* Note: errorptr points to *previous* column's array entry.
|
||||
*/
|
||||
r_cur = RIGHT_SHIFT(r_cur + r_errorptr[dir] + 8, 4);
|
||||
g_cur = RIGHT_SHIFT(g_cur + g_errorptr[dir] + 8, 4);
|
||||
b_cur = RIGHT_SHIFT(b_cur + b_errorptr[dir] + 8, 4);
|
||||
|
||||
/* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
|
||||
* The maximum error is +- MAXJSAMPLE; this sets the required size
|
||||
* of the range_limit array.
|
||||
*/
|
||||
if (dir > 0) {
|
||||
r_cur += GETJSAMPLE(*input_ptr);
|
||||
r_cur = GETJSAMPLE(range_limit[r_cur]);
|
||||
input_ptr++;
|
||||
g_cur += GETJSAMPLE(*input_ptr);
|
||||
g_cur = GETJSAMPLE(range_limit[g_cur]);
|
||||
input_ptr++;
|
||||
b_cur += GETJSAMPLE(*input_ptr);
|
||||
b_cur = GETJSAMPLE(range_limit[b_cur]);
|
||||
input_ptr++;
|
||||
}
|
||||
else {
|
||||
b_cur += GETJSAMPLE(*input_ptr);
|
||||
b_cur = GETJSAMPLE(range_limit[b_cur]);
|
||||
input_ptr--;
|
||||
g_cur += GETJSAMPLE(*input_ptr);
|
||||
g_cur = GETJSAMPLE(range_limit[g_cur]);
|
||||
input_ptr--;
|
||||
r_cur += GETJSAMPLE(*input_ptr);
|
||||
r_cur = GETJSAMPLE(range_limit[r_cur]);
|
||||
input_ptr--;
|
||||
}
|
||||
|
||||
/* Select output value, accumulate into output code for this pixel */
|
||||
map_index = COLORMAP_INDEX(lookup_table, r_cur, g_cur, b_cur);
|
||||
if (mask) {
|
||||
if (*maskp)
|
||||
*output_ptr = map_index;
|
||||
maskp += dir;
|
||||
} else {
|
||||
*output_ptr = map_index;
|
||||
}
|
||||
|
||||
/* Compute the actual representation error at this pixel */
|
||||
map_entry = map + map_index;
|
||||
r_cur -= GETJSAMPLE(map_entry->red);
|
||||
g_cur -= GETJSAMPLE(map_entry->green);
|
||||
b_cur -= GETJSAMPLE(map_entry->blue);
|
||||
|
||||
/* Compute error fractions to be propagated to adjacent pixels.
|
||||
* Add these into the running sums, and simultaneously shift the
|
||||
* next-line error sums left by 1 column.
|
||||
*/
|
||||
r_bnexterr = r_cur;
|
||||
delta = r_cur * 2;
|
||||
r_cur += delta; /* form error * 3 */
|
||||
r_errorptr[0] = (FSERROR) (r_bpreverr + r_cur);
|
||||
r_cur += delta; /* form error * 5 */
|
||||
r_bpreverr = r_belowerr + r_cur;
|
||||
r_belowerr = r_bnexterr;
|
||||
r_cur += delta; /* form error * 7 */
|
||||
|
||||
g_bnexterr = g_cur;
|
||||
delta = g_cur * 2;
|
||||
g_cur += delta; /* form error * 3 */
|
||||
g_errorptr[0] = (FSERROR) (g_bpreverr + g_cur);
|
||||
g_cur += delta; /* form error * 5 */
|
||||
g_bpreverr = g_belowerr + g_cur;
|
||||
g_belowerr = g_bnexterr;
|
||||
g_cur += delta; /* form error * 7 */
|
||||
|
||||
b_bnexterr = b_cur;
|
||||
delta = b_cur * 2;
|
||||
b_cur += delta; /* form error * 3 */
|
||||
b_errorptr[0] = (FSERROR) (b_bpreverr + b_cur);
|
||||
b_cur += delta; /* form error * 5 */
|
||||
b_bpreverr = b_belowerr + b_cur;
|
||||
b_belowerr = b_bnexterr;
|
||||
b_cur += delta; /* form error * 7 */
|
||||
|
||||
/* At this point cur contains the 7/16 error value to be propagated
|
||||
* to the next pixel on the current line, and all the errors for the
|
||||
* next line have been shifted over. We are therefore ready to move on.
|
||||
* Note: the input_ptr has already been advanced.
|
||||
*/
|
||||
output_ptr += dir; /* advance output ptr to next column */
|
||||
r_errorptr += dir; /* advance errorptr to current column */
|
||||
g_errorptr += dir; /* advance errorptr to current column */
|
||||
b_errorptr += dir; /* advance errorptr to current column */
|
||||
}
|
||||
|
||||
/* Post-loop cleanup: we must unload the final error value into the
|
||||
* final fserrors[] entry. Note we need not unload belowerr because
|
||||
* it is for the dummy column before or after the actual array.
|
||||
*/
|
||||
r_errorptr[0] = (FSERROR) r_bpreverr; /* unload prev err into array */
|
||||
g_errorptr[0] = (FSERROR) g_bpreverr; /* unload prev err into array */
|
||||
b_errorptr[0] = (FSERROR) b_bpreverr; /* unload prev err into array */
|
||||
|
||||
cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
#ifndef powerc
|
||||
#pragma peephole reset
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* END code adapted from jpeg library */
|
||||
|
|
@ -1,209 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* This is a dummy Net Context which the Image Library uses for network
|
||||
operations in lieu of an MWContext. It will be replaced by a true
|
||||
Net Context when the Network Library is modularized. */
|
||||
|
||||
#include "dummy_nc.h"
|
||||
#include "il_strm.h"
|
||||
#include "if.h"
|
||||
|
||||
typedef struct dum_TitleObsClosure {
|
||||
MWContext *context;
|
||||
XP_ObserverList obs_list;
|
||||
} dum_TitleObsClosure;
|
||||
|
||||
extern void
|
||||
lo_view_title( MWContext *context, char *title_str );
|
||||
|
||||
extern PRBool
|
||||
il_load_image(OPAQUE_CONTEXT *cx, char *image_url, NET_ReloadMethod cache_reload_policy);
|
||||
|
||||
|
||||
IL_NetContext *
|
||||
IL_NewDummyNetContext(MWContext *context, NET_ReloadMethod cache_reload_policy)
|
||||
{
|
||||
IL_NetContext *net_cx;
|
||||
|
||||
net_cx = XP_NEW_ZAP(IL_NetContext);
|
||||
if (!net_cx)
|
||||
return NULL;
|
||||
|
||||
net_cx->cx = context;
|
||||
net_cx->cache_reload_policy = cache_reload_policy;
|
||||
|
||||
return net_cx;
|
||||
}
|
||||
|
||||
void
|
||||
IL_DestroyDummyNetContext(IL_NetContext *net_cx)
|
||||
{
|
||||
XP_FREE(net_cx);
|
||||
}
|
||||
|
||||
IL_NetContext *
|
||||
IL_CloneDummyNetContext(IL_NetContext *net_cx)
|
||||
{
|
||||
return IL_NewDummyNetContext((MWContext *)net_cx->cx,
|
||||
net_cx->cache_reload_policy);
|
||||
}
|
||||
|
||||
#include "shist.h" /* For use with IL_AddReferer */
|
||||
#include "structs.h" /* For use with IL_AddReferer */
|
||||
|
||||
void
|
||||
IL_AddReferer(IL_NetContext *net_cx, URL_Struct *urls)
|
||||
{
|
||||
MWContext *cx = net_cx->cx;
|
||||
History_entry *he = SHIST_GetCurrent (&cx->hist);
|
||||
|
||||
if (urls->referer)
|
||||
XP_FREE (urls->referer);
|
||||
if (he && he->address)
|
||||
urls->referer = XP_STRDUP (he->origin_url
|
||||
? he->origin_url
|
||||
: he->address);
|
||||
else
|
||||
urls->referer = 0;
|
||||
}
|
||||
|
||||
void
|
||||
dum_TitleObserver(XP_Observable observerable, XP_ObservableMsg msg,
|
||||
void *message_data, void *closure){
|
||||
|
||||
IL_MessageData *data = (IL_MessageData*)message_data;
|
||||
MWContext *context;
|
||||
dum_TitleObsClosure *title_obs_closure = (dum_TitleObsClosure *)closure;
|
||||
context = (MWContext *)title_obs_closure->context;
|
||||
|
||||
switch(msg){
|
||||
case IL_DESCRIPTION:
|
||||
lo_view_title(context, data->description);
|
||||
break;
|
||||
|
||||
case IL_IMAGE_DESTROYED:
|
||||
/* Remove ourself from the observer callback list. */
|
||||
XP_RemoveObserver(title_obs_closure->obs_list, dum_TitleObserver,
|
||||
title_obs_closure);
|
||||
XP_FREE(title_obs_closure);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
XP_ObserverList
|
||||
dum_NewTitleObserverList(MWContext *context)
|
||||
{
|
||||
XP_ObserverList title_obs_list; /* List of observer callbacks. */
|
||||
dum_TitleObsClosure *title_obs_closure; /* Closure data to be passed back
|
||||
to lo_ImageObserver. */
|
||||
NS_Error status;
|
||||
|
||||
/* Create an XP_ObserverList for the title */
|
||||
status = XP_NewObserverList(NULL, &title_obs_list);
|
||||
if (status < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Closure data for the image observer. */
|
||||
title_obs_closure = XP_NEW_ZAP(dum_TitleObsClosure);
|
||||
if (!title_obs_closure) {
|
||||
XP_DisposeObserverList(title_obs_list);
|
||||
return NULL;
|
||||
}
|
||||
title_obs_closure->context = context;
|
||||
title_obs_closure->obs_list = title_obs_list;
|
||||
|
||||
/* Add the layout image observer to the observer list. */
|
||||
status = XP_AddObserver(title_obs_list, dum_TitleObserver, title_obs_closure);
|
||||
if (status < 0) {
|
||||
XP_DisposeObserverList(title_obs_list);
|
||||
XP_RemoveObserver(title_obs_closure->obs_list, dum_TitleObserver,
|
||||
title_obs_closure );
|
||||
XP_FREE(title_obs_closure);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return title_obs_list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This function only handles view_images. Note that the title observer
|
||||
created is only used to set the image dimensions and type in the
|
||||
title bar. */
|
||||
|
||||
PRBool
|
||||
il_load_image(MWContext *cx, char *image_url, NET_ReloadMethod cache_reload_policy)
|
||||
{
|
||||
PRBool ret_val = PR_TRUE;
|
||||
XP_ObserverList obs_list;
|
||||
IL_NetContext *net_cx;
|
||||
IL_IRGB *trans_pixel;
|
||||
IL_ImageReq *image_req;
|
||||
|
||||
|
||||
/* Create a new observer list for the image's title. The destruction of this
|
||||
list is managed by the image library once we call IL_GetImage. */
|
||||
obs_list = dum_NewTitleObserverList(cx);
|
||||
if (!obs_list)
|
||||
return PR_FALSE;
|
||||
|
||||
net_cx = IL_NewDummyNetContext(cx, cache_reload_policy);
|
||||
if (!net_cx) {
|
||||
XP_DisposeObserverList(obs_list);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* Determine whether to request a mask if this is a transparent image.
|
||||
In the case of a document backdrop, we ask the image library to fill
|
||||
in the transparent area with a solid color. For all other transparent
|
||||
images, we force the creation of a mask by passing in NULL. */
|
||||
if (cx->type == MWContextPostScript) {
|
||||
trans_pixel = XP_NEW_ZAP(IL_IRGB);
|
||||
if (trans_pixel)
|
||||
trans_pixel->red = trans_pixel->green = trans_pixel->blue = 0xff;
|
||||
}
|
||||
else if (cx->type == MWContextPrint) {
|
||||
trans_pixel = cx->transparent_pixel;
|
||||
}
|
||||
else {
|
||||
trans_pixel = NULL;
|
||||
}
|
||||
|
||||
/* Fetch the image. */
|
||||
image_req = IL_GetImage(image_url, cx->img_cx, obs_list, trans_pixel, 0, 0, 0, net_cx);
|
||||
if (!image_req) {
|
||||
ret_val = PR_FALSE;
|
||||
}
|
||||
|
||||
/* Destroy the transparent pixel if this is a PostScript context. */
|
||||
if ((cx->type == MWContextPostScript) && trans_pixel)
|
||||
XP_FREE(trans_pixel);
|
||||
|
||||
/* The Image Library clones the dummy Net Context, so it safe to destroy
|
||||
it. */
|
||||
IL_DestroyDummyNetContext(net_cx);
|
||||
|
||||
return ret_val;
|
||||
}
|
|
@ -0,0 +1,521 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* This is a dummy Net Context which the Image Library uses for network
|
||||
operations in lieu of an MWContext. It will be replaced by a true
|
||||
Net Context when the Network Library is modularized. */
|
||||
|
||||
#include "dummy_nc.h"
|
||||
#include "il_strm.h"
|
||||
#include "if.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
PR_END_EXTERN_C
|
||||
|
||||
/*
|
||||
* XXX Temporary inclusion of this prototype. It was originally in
|
||||
* libimg.h but needed to be removed since it required C++ compilation.
|
||||
* It should eventually return to libimg.h and may be remove when
|
||||
* a modularized netlib comes around.
|
||||
*/
|
||||
extern ilIURL *
|
||||
IL_CreateIURL(URL_Struct *urls);
|
||||
|
||||
typedef struct dum_TitleObsClosure {
|
||||
MWContext *context;
|
||||
XP_ObserverList obs_list;
|
||||
} dum_TitleObsClosure;
|
||||
|
||||
static NS_DEFINE_IID(kINetContextIID, IL_INETCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIURLIID, IL_IURL_IID);
|
||||
|
||||
class NetContextImpl : public ilINetContext
|
||||
{
|
||||
public:
|
||||
NetContextImpl(MWContext *aContext, NET_ReloadMethod aReloadMethod);
|
||||
~NetContextImpl();
|
||||
|
||||
int operator==(NetContextImpl& aNetContext) const;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual ilINetContext* Clone();
|
||||
|
||||
virtual NET_ReloadMethod GetReloadPolicy();
|
||||
|
||||
virtual void AddReferer(ilIURL *aUrl);
|
||||
|
||||
virtual void Interrupt();
|
||||
|
||||
virtual ilIURL* CreateURL(const char *aUrl,
|
||||
NET_ReloadMethod aReloadMethod);
|
||||
|
||||
virtual PRBool IsLocalFileURL(char *aAddress);
|
||||
|
||||
virtual PRBool IsURLInMemCache(ilIURL *aUrl);
|
||||
|
||||
virtual PRBool IsURLInDiskCache(ilIURL *aUrl);
|
||||
|
||||
virtual int GetURL (ilIURL * aUrl, NET_ReloadMethod aLoadMethod,
|
||||
ilINetReader *aReader);
|
||||
|
||||
private:
|
||||
MWContext *mContext;
|
||||
NET_ReloadMethod mReloadPolicy;
|
||||
};
|
||||
|
||||
class URLImpl : public ilIURL {
|
||||
public:
|
||||
URLImpl();
|
||||
URLImpl(URL_Struct *urls);
|
||||
~URLImpl();
|
||||
|
||||
nsresult Init(const char *aURL, NET_ReloadMethod aReloadMethod);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void SetReader(ilINetReader *aReader);
|
||||
|
||||
virtual ilINetReader *GetReader();
|
||||
|
||||
virtual int GetContentLength();
|
||||
|
||||
virtual const char* GetAddress();
|
||||
|
||||
virtual time_t GetExpires();
|
||||
|
||||
virtual void SetBackgroundLoad(PRBool aBgload);
|
||||
|
||||
URL_Struct *GetURLStruct() { return mURLS; }
|
||||
|
||||
private:
|
||||
ilINetReader *mReader;
|
||||
URL_Struct *mURLS;
|
||||
};
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
extern void
|
||||
lo_view_title( MWContext *context, char *title_str );
|
||||
PR_END_EXTERN_C
|
||||
|
||||
extern PRBool
|
||||
il_load_image(MWContext *cx, char *image_url, NET_ReloadMethod cache_reload_policy);
|
||||
|
||||
NetContextImpl::NetContextImpl(MWContext *aContext,
|
||||
NET_ReloadMethod aReloadPolicy)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mContext = aContext;
|
||||
aReloadPolicy = mReloadPolicy;
|
||||
}
|
||||
|
||||
NetContextImpl::~NetContextImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IL_NetContext *
|
||||
IL_NewDummyNetContext(MWContext *context, NET_ReloadMethod cache_reload_policy)
|
||||
{
|
||||
ilINetContext *cx = new NetContextImpl(context, cache_reload_policy);
|
||||
|
||||
if (cx != NULL) {
|
||||
NS_ADDREF(cx);
|
||||
}
|
||||
|
||||
return (IL_NetContext *)cx;
|
||||
}
|
||||
|
||||
void
|
||||
IL_DestroyDummyNetContext(IL_NetContext *net_cx)
|
||||
{
|
||||
ilINetContext *cx = (ilINetContext *)net_cx;
|
||||
|
||||
if (cx != NULL) {
|
||||
NS_RELEASE(cx);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NetContextImpl, kINetContextIID)
|
||||
|
||||
int
|
||||
NetContextImpl::operator==(NetContextImpl& aNetContext) const
|
||||
{
|
||||
return ((mContext == aNetContext.mContext) &&
|
||||
(mReloadPolicy == aNetContext.mReloadPolicy));
|
||||
}
|
||||
|
||||
ilINetContext *
|
||||
NetContextImpl::Clone()
|
||||
{
|
||||
return (ilINetContext *)IL_NewDummyNetContext(mContext, mReloadPolicy);
|
||||
}
|
||||
|
||||
NET_ReloadMethod
|
||||
NetContextImpl::GetReloadPolicy()
|
||||
{
|
||||
return mReloadPolicy;
|
||||
}
|
||||
|
||||
#include "shist.h" /* For use with IL_AddReferer */
|
||||
#include "structs.h" /* For use with IL_AddReferer */
|
||||
|
||||
void
|
||||
NetContextImpl::AddReferer(ilIURL *url)
|
||||
{
|
||||
History_entry *he = SHIST_GetCurrent (&mContext->hist);
|
||||
URL_Struct *urls = ((URLImpl *)url)->GetURLStruct();
|
||||
|
||||
PR_FREEIF (urls->referer);
|
||||
if (he && he->address)
|
||||
urls->referer = PL_strdup (he->origin_url
|
||||
? he->origin_url
|
||||
: he->address);
|
||||
else
|
||||
urls->referer = 0;
|
||||
}
|
||||
|
||||
void
|
||||
dum_TitleObserver(XP_Observable observerable, XP_ObservableMsg msg,
|
||||
void *message_data, void *closure){
|
||||
|
||||
IL_MessageData *data = (IL_MessageData*)message_data;
|
||||
MWContext *context;
|
||||
dum_TitleObsClosure *title_obs_closure = (dum_TitleObsClosure *)closure;
|
||||
context = (MWContext *)title_obs_closure->context;
|
||||
|
||||
switch(msg){
|
||||
case IL_DESCRIPTION:
|
||||
#ifdef MOZ_NGLAYOUT
|
||||
XP_ASSERT(0);
|
||||
#else
|
||||
lo_view_title(context, data->description);
|
||||
#endif /* MOZ_NGLAYOUT */
|
||||
break;
|
||||
|
||||
case IL_IMAGE_DESTROYED:
|
||||
/* Remove ourself from the observer callback list. */
|
||||
XP_RemoveObserver(title_obs_closure->obs_list, dum_TitleObserver,
|
||||
title_obs_closure);
|
||||
PR_FREEIF(title_obs_closure);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
XP_ObserverList
|
||||
dum_NewTitleObserverList(MWContext *context)
|
||||
{
|
||||
XP_ObserverList title_obs_list; /* List of observer callbacks. */
|
||||
dum_TitleObsClosure *title_obs_closure; /* Closure data to be passed back
|
||||
to lo_ImageObserver. */
|
||||
NS_Error status;
|
||||
|
||||
/* Create an XP_ObserverList for the title */
|
||||
status = XP_NewObserverList(NULL, &title_obs_list);
|
||||
if (status < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Closure data for the image observer. */
|
||||
title_obs_closure = PR_NEWZAP(dum_TitleObsClosure);
|
||||
if (!title_obs_closure) {
|
||||
XP_DisposeObserverList(title_obs_list);
|
||||
return NULL;
|
||||
}
|
||||
title_obs_closure->context = context;
|
||||
title_obs_closure->obs_list = title_obs_list;
|
||||
|
||||
/* Add the layout image observer to the observer list. */
|
||||
status = XP_AddObserver(title_obs_list, dum_TitleObserver, title_obs_closure);
|
||||
if (status < 0) {
|
||||
XP_DisposeObserverList(title_obs_list);
|
||||
XP_RemoveObserver(title_obs_closure->obs_list, dum_TitleObserver,
|
||||
title_obs_closure );
|
||||
PR_FREEIF(title_obs_closure);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return title_obs_list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This function only handles view_images. Note that the title observer
|
||||
created is only used to set the image dimensions and type in the
|
||||
title bar. */
|
||||
|
||||
PRBool
|
||||
il_load_image(MWContext *cx, char *image_url, NET_ReloadMethod cache_reload_policy)
|
||||
{
|
||||
PRBool ret_val = PR_TRUE;
|
||||
XP_ObserverList obs_list;
|
||||
IL_NetContext *net_cx;
|
||||
IL_IRGB *trans_pixel;
|
||||
IL_ImageReq *image_req;
|
||||
|
||||
|
||||
/* Create a new observer list for the image's title. The destruction of this
|
||||
list is managed by the image library once we call IL_GetImage. */
|
||||
obs_list = dum_NewTitleObserverList(cx);
|
||||
if (!obs_list)
|
||||
return PR_FALSE;
|
||||
|
||||
net_cx = IL_NewDummyNetContext(cx, cache_reload_policy);
|
||||
if (!net_cx) {
|
||||
XP_DisposeObserverList(obs_list);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* Determine whether to request a mask if this is a transparent image.
|
||||
In the case of a document backdrop, we ask the image library to fill
|
||||
in the transparent area with a solid color. For all other transparent
|
||||
images, we force the creation of a mask by passing in NULL. */
|
||||
if (cx->type == MWContextPostScript) {
|
||||
trans_pixel = PR_NEWZAP(IL_IRGB);
|
||||
if (trans_pixel)
|
||||
trans_pixel->red = trans_pixel->green = trans_pixel->blue = 0xff;
|
||||
}
|
||||
else if (cx->type == MWContextPrint) {
|
||||
trans_pixel = cx->transparent_pixel;
|
||||
}
|
||||
else {
|
||||
trans_pixel = NULL;
|
||||
}
|
||||
|
||||
/* Fetch the image. */
|
||||
image_req = IL_GetImage(image_url, cx->img_cx, obs_list, trans_pixel, 0, 0, 0, (ilINetContext *)net_cx);
|
||||
if (!image_req) {
|
||||
ret_val = PR_FALSE;
|
||||
}
|
||||
|
||||
/* Destroy the transparent pixel if this is a PostScript context. */
|
||||
if ((cx->type == MWContextPostScript) && trans_pixel)
|
||||
PR_FREEIF(trans_pixel);
|
||||
|
||||
/* The Image Library clones the dummy Net Context, so it safe to destroy
|
||||
it. */
|
||||
IL_DestroyDummyNetContext(net_cx);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
ilIURL *
|
||||
NetContextImpl::CreateURL(const char *url, NET_ReloadMethod reload_method)
|
||||
{
|
||||
URLImpl *iurl;
|
||||
|
||||
iurl = new URLImpl();
|
||||
if (iurl == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (iurl->Init(url, reload_method) != NS_OK) {
|
||||
delete iurl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NS_ADDREF(iurl);
|
||||
|
||||
return (ilIURL *)iurl;
|
||||
}
|
||||
|
||||
void
|
||||
NetContextImpl::Interrupt()
|
||||
{
|
||||
if (mContext != NULL) {
|
||||
NET_InterruptWindow(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
NetContextImpl::IsLocalFileURL(char *address)
|
||||
{
|
||||
return (PRBool)NET_IsLocalFileURL(address);
|
||||
}
|
||||
|
||||
PRBool
|
||||
NetContextImpl::IsURLInMemCache(ilIURL *aURL)
|
||||
{
|
||||
if (aURL != NULL) {
|
||||
return (PRBool)NET_IsURLInMemCache(((URLImpl *)aURL)->GetURLStruct());
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
NetContextImpl::IsURLInDiskCache(ilIURL *aURL)
|
||||
{
|
||||
if (aURL != NULL) {
|
||||
return (PRBool)NET_IsURLInDiskCache(((URLImpl *)aURL)->GetURLStruct());
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
il_netgeturldone(URL_Struct *URL_s, int status, OPAQUE_CONTEXT *cx)
|
||||
{
|
||||
ilIURL *iurl = (ilIURL *)URL_s->fe_data;
|
||||
ilINetReader *reader;
|
||||
|
||||
if (iurl != NULL) {
|
||||
reader = iurl->GetReader();
|
||||
if (reader != NULL) {
|
||||
reader->NetRequestDone(iurl, status);
|
||||
NS_RELEASE(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/* for mac */
|
||||
if (status == MK_OUT_OF_MEMORY)
|
||||
NET_InterruptWindow((MWContext *)cx);
|
||||
}
|
||||
|
||||
int
|
||||
NetContextImpl::GetURL (ilIURL *aURL,
|
||||
NET_ReloadMethod aLoadMethod,
|
||||
ilINetReader *aReader)
|
||||
{
|
||||
URL_Struct *urls = ((URLImpl *)aURL)->GetURLStruct();
|
||||
FO_Present_Types type = (aLoadMethod == NET_CACHE_ONLY_RELOAD) ?
|
||||
FO_ONLY_FROM_CACHE_AND_INTERNAL_IMAGE :
|
||||
FO_CACHE_AND_INTERNAL_IMAGE;
|
||||
aURL->SetReader(aReader);
|
||||
|
||||
return NET_GetURL (urls, type, mContext,
|
||||
(Net_GetUrlExitFunc*)&il_netgeturldone);
|
||||
}
|
||||
|
||||
|
||||
URLImpl::URLImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mReader = NULL;
|
||||
mURLS = NULL;
|
||||
}
|
||||
|
||||
URLImpl::URLImpl(URL_Struct *urls)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mReader = NULL;
|
||||
mURLS = urls;
|
||||
urls->fe_data = this;
|
||||
}
|
||||
|
||||
URLImpl::~URLImpl()
|
||||
{
|
||||
if (mURLS != NULL) {
|
||||
NET_FreeURLStruct(mURLS);
|
||||
}
|
||||
|
||||
if (mReader != NULL) {
|
||||
NS_RELEASE(mReader);
|
||||
}
|
||||
}
|
||||
|
||||
/* This is only used for the UNIX icon hack in
|
||||
cmd/xfe/mkicons.cpp */
|
||||
ilIURL *
|
||||
IL_CreateIURL(URL_Struct *urls)
|
||||
{
|
||||
ilIURL *iurl = new URLImpl(urls);
|
||||
NS_ADDREF(iurl);
|
||||
|
||||
return iurl;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(URLImpl, kIURLIID)
|
||||
|
||||
nsresult
|
||||
URLImpl::Init(const char *url, NET_ReloadMethod reload_method)
|
||||
{
|
||||
mURLS = NET_CreateURLStruct(url, reload_method);
|
||||
if (mURLS == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mURLS->fe_data = this;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
URLImpl::SetReader(ilINetReader *aReader)
|
||||
{
|
||||
NS_ADDREF(aReader);
|
||||
mReader = aReader;
|
||||
}
|
||||
|
||||
ilINetReader *
|
||||
URLImpl::GetReader()
|
||||
{
|
||||
NS_ADDREF(mReader);
|
||||
return mReader;
|
||||
}
|
||||
|
||||
int
|
||||
URLImpl::GetContentLength()
|
||||
{
|
||||
if (mURLS) {
|
||||
return mURLS->content_length;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
URLImpl::GetAddress()
|
||||
{
|
||||
if (mURLS) {
|
||||
return (const char *)mURLS->address;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
time_t
|
||||
URLImpl::GetExpires()
|
||||
{
|
||||
if (mURLS) {
|
||||
return mURLS->expires;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
URLImpl::SetBackgroundLoad(PRBool bgload)
|
||||
{
|
||||
if (mURLS) {
|
||||
mURLS->load_background = bgload;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,419 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "if.h"
|
||||
#include "dummy_nc.h"
|
||||
|
||||
extern PRBool
|
||||
il_load_image(MWContext *cx, char *image_url, NET_ReloadMethod cache_reload_policy);
|
||||
|
||||
#include "merrors.h"
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "xpcompat.h"
|
||||
#else
|
||||
/* for XP_GetString() */
|
||||
#include "xpgetstr.h"
|
||||
#endif
|
||||
|
||||
#include "il_strm.h" /* Stream converters. */
|
||||
|
||||
static unsigned int
|
||||
il_view_write_ready(NET_StreamClass *stream)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
|
||||
/* For some reason, the imagelib can't deliver the image.
|
||||
Trigger il_view_write(), which will abort the stream. */
|
||||
|
||||
/* This originally returned (ic!=0) to trigger il_view_write()
|
||||
which would set the read_size to something reasonable. But in mkmailbox.c
|
||||
ReadMessageSock() uses the return value of one as the read_size and does not
|
||||
call il_view_write() until it has filled up the buffer one byte
|
||||
at a time. This should be addressed correctly in later versions. */
|
||||
|
||||
return (reader != 0) * MAX_WRITE_READY;
|
||||
}
|
||||
|
||||
/* Abort the stream if we get this far */
|
||||
static int
|
||||
il_view_write(NET_StreamClass *stream, const unsigned char *str, int32 len)
|
||||
{
|
||||
void *dobj=stream->data_object;
|
||||
/* If this assert fires, chances are that the provided URL was malformed.*/
|
||||
PR_ASSERT(dobj == (void*)1);
|
||||
|
||||
/* Should be MK_DATA_LOADED, but netlib ignores that. */
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
static void
|
||||
il_view_complete(NET_StreamClass *stream)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
il_view_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
il_stream_complete(NET_StreamClass *stream)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
|
||||
reader->StreamComplete((PRBool)stream->is_multipart);
|
||||
}
|
||||
|
||||
void
|
||||
il_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
|
||||
reader->StreamAbort(status);
|
||||
stream->data_object = 0;
|
||||
}
|
||||
|
||||
/* Only for internal-external-reconnect. */
|
||||
void
|
||||
il_stream_reconnect_complete(NET_StreamClass *stream)
|
||||
{
|
||||
/* Get reader before calling il_stream_complete because it
|
||||
may set stream->data_object to NULL. */
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
PR_ASSERT(reader);
|
||||
|
||||
il_stream_complete(stream);
|
||||
|
||||
NS_RELEASE(reader);
|
||||
stream->data_object = NULL;
|
||||
}
|
||||
|
||||
/* Only for internal-external-reconnect. */
|
||||
void
|
||||
il_reconnect_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
/* Get reader before calling il_abort because it
|
||||
may set stream->data_object to NULL. */
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
PR_ASSERT(reader);
|
||||
|
||||
il_abort(stream,status);
|
||||
|
||||
NS_RELEASE(reader);
|
||||
stream->data_object = NULL;
|
||||
}
|
||||
unsigned int
|
||||
il_write_ready(NET_StreamClass *stream)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
|
||||
return reader->WriteReady();
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
il_write(NET_StreamClass *stream, const unsigned char *str, int32 len)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
|
||||
return reader->Write(str, len);
|
||||
}
|
||||
|
||||
int
|
||||
il_first_write(NET_StreamClass *stream, const unsigned char *str, int32 len)
|
||||
{
|
||||
ilINetReader *reader = (ilINetReader *)stream->data_object;
|
||||
int ret_val;
|
||||
|
||||
ret_val = reader->FirstWrite(str, len);
|
||||
if (ret_val != 0) {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
stream->put_block = (MKStreamWriteFunc)il_write;
|
||||
/* do first write */
|
||||
return stream->put_block(stream, (const char*) str, len);
|
||||
}
|
||||
|
||||
/* there can be only one, highlander */
|
||||
static NET_StreamClass *unconnected_stream = 0;
|
||||
static URL_Struct *unconnected_urls = 0;
|
||||
|
||||
void
|
||||
il_reconnect(il_container *ic)
|
||||
{
|
||||
if (unconnected_stream)
|
||||
{
|
||||
/* Will be freed in il_stream_reconnect_complete or il_reconnect_abort */
|
||||
ilINetReader *reader = IL_NewNetReader(ic);
|
||||
|
||||
if (reader != NULL) {
|
||||
unconnected_stream->complete = il_stream_reconnect_complete;
|
||||
unconnected_stream->abort = il_reconnect_abort;
|
||||
unconnected_stream->is_write_ready = il_write_ready;
|
||||
unconnected_stream->data_object = (void *)reader;
|
||||
unconnected_stream->put_block = (MKStreamWriteFunc)il_first_write;
|
||||
|
||||
ic->type = IL_UNKNOWN;
|
||||
ic->state = IC_STREAM;
|
||||
|
||||
/* unconnected_urls->fe_data no longer has a ponter to an ilIURL,
|
||||
it wasn't used anyway. */
|
||||
ic->content_length = unconnected_urls->content_length;
|
||||
}
|
||||
|
||||
unconnected_stream = 0;
|
||||
unconnected_urls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* We aren't going to reconnect after all. Cause the stream to abort */
|
||||
void
|
||||
il_abort_reconnect()
|
||||
{
|
||||
if (unconnected_stream) {
|
||||
unconnected_stream->data_object = (void *)1;
|
||||
|
||||
unconnected_stream = 0;
|
||||
unconnected_urls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static char fakehtml[] = "<IMG SRC=\"%s\">";
|
||||
|
||||
NET_StreamClass *
|
||||
IL_ViewStream(FO_Present_Types format_out, void *newshack, URL_Struct *urls,
|
||||
OPAQUE_CONTEXT *cx)
|
||||
{
|
||||
NET_StreamClass *stream = nil,
|
||||
*viewstream = nil;
|
||||
il_container *ic = nil;
|
||||
ilINetReader *reader = nil;
|
||||
ilIURL *iurl;
|
||||
char *org_content_type;
|
||||
char *image_url;
|
||||
|
||||
/* multi-part reconnect hack */
|
||||
iurl = (ilIURL *)urls->fe_data;
|
||||
if (iurl) {
|
||||
reader = iurl->GetReader();
|
||||
if(reader)
|
||||
{
|
||||
#if 0
|
||||
/* This change is not fully merged from the MODULAR_IMGLIB_BRANCH landing. */
|
||||
/* Extreme editor hack! This value is used when loading images
|
||||
so we use the converter we did in 4.06 code.
|
||||
If we don't, this code triggers parsing of the image URL,
|
||||
which has very bad effects in the editor! */
|
||||
if((urls && urls->owner_id == 0x000000ED) || (ic && ic->multi))
|
||||
#endif
|
||||
if(reader->IsMulti()) {
|
||||
NS_RELEASE(reader);
|
||||
return IL_NewStream(format_out, IL_UNKNOWN, urls, cx);
|
||||
}
|
||||
NS_RELEASE(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create stream object */
|
||||
if (!(stream = PR_NEWZAP(NET_StreamClass))) {
|
||||
ILTRACE(1,("il: IL_ViewStream memory lossage"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
stream->name = "image view";
|
||||
stream->complete = il_view_complete;
|
||||
stream->abort = il_view_abort;
|
||||
stream->is_write_ready = il_view_write_ready;
|
||||
stream->data_object = NULL;
|
||||
stream->window_id = (MWContext *)cx;
|
||||
stream->put_block = (MKStreamWriteFunc)il_view_write;
|
||||
|
||||
ILTRACE(0,("il: new view stream, %s", urls->address));
|
||||
|
||||
PR_ASSERT(!unconnected_stream);
|
||||
/* Note that this URL_Struct does not have a iURL wrapper around
|
||||
it anymore. It doesn't need it and we wouldn't have any good place
|
||||
to free it anyway. */
|
||||
unconnected_stream = stream;
|
||||
unconnected_urls = urls;
|
||||
|
||||
if(!newshack)
|
||||
{
|
||||
char *buffer;
|
||||
|
||||
org_content_type = urls->content_type;
|
||||
urls->content_type = 0;
|
||||
StrAllocCopy(urls->content_type, TEXT_HTML);
|
||||
urls->is_binary = 1; /* secret flag for mail-to save as */
|
||||
|
||||
/* Force layout to discard the old document and start a new one.
|
||||
We do this so that the pre-fetched image request won't be
|
||||
destroyed by a layout call to IL_DestroyImageGroup. */
|
||||
|
||||
viewstream = NET_StreamBuilder(format_out, urls, (MWContext *)cx);
|
||||
if (!viewstream) {
|
||||
PR_FREEIF(stream);
|
||||
return NULL;
|
||||
}
|
||||
buffer = PL_strdup("<HTML>");
|
||||
if (!buffer) {
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(viewstream);
|
||||
return NULL;
|
||||
}
|
||||
(*viewstream->put_block)(viewstream, buffer,
|
||||
PL_strlen(buffer)+1);
|
||||
PR_FREEIF(buffer);
|
||||
|
||||
} /* !newshack */
|
||||
|
||||
/* Prefetch the image. We do this so that the image library can
|
||||
process image data even if the parser is blocked on the fake IMG
|
||||
tag that we send. Note that this image request will persist until
|
||||
the document is destroyed (when IL_DestroyImageGroup will be called.) */
|
||||
image_url = (char*) PR_MALLOC(PL_strlen(urls->address) + 29);
|
||||
if (!image_url) {
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(viewstream);
|
||||
return NULL;
|
||||
}
|
||||
XP_SPRINTF(image_url, "internal-external-reconnect:%s", urls->address);
|
||||
if (!il_load_image((MWContext *)cx, image_url, urls->force_reload)) {
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(viewstream);
|
||||
return NULL;
|
||||
}
|
||||
PR_FREEIF(image_url);
|
||||
|
||||
if (!newshack) {
|
||||
if (viewstream) {
|
||||
char *buffer = (char*)
|
||||
PR_MALLOC(PL_strlen(fakehtml) + PL_strlen(urls->address) + 1);
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
XP_SPRINTF(buffer, fakehtml, urls->address);
|
||||
(*viewstream->put_block)(viewstream,
|
||||
buffer, PL_strlen(buffer));
|
||||
PR_FREEIF(buffer);
|
||||
}
|
||||
(*viewstream->complete)(viewstream);
|
||||
}
|
||||
|
||||
/* this has to be set back for abort to work correctly */
|
||||
PR_FREEIF(urls->content_type);
|
||||
urls->content_type = org_content_type;
|
||||
} /* !newshack */
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
NET_StreamClass *
|
||||
IL_NewStream (FO_Present_Types format_out,
|
||||
void *type,
|
||||
URL_Struct *urls,
|
||||
OPAQUE_CONTEXT *cx)
|
||||
{
|
||||
NET_StreamClass *stream = nil;
|
||||
il_container *ic = nil;
|
||||
ilINetReader *reader = nil;
|
||||
ilIURL *iurl = nil;
|
||||
|
||||
/* recover the container */
|
||||
iurl = (ilIURL *)urls->fe_data;
|
||||
reader = iurl->GetReader();
|
||||
|
||||
PR_ASSERT(reader);
|
||||
|
||||
if (reader->StreamCreated(iurl, (int)type) == PR_FALSE) {
|
||||
NS_RELEASE(reader);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Create stream object */
|
||||
if (!(stream = PR_NEWZAP(NET_StreamClass)))
|
||||
{
|
||||
ILTRACE(0,("il: MEM il_newstream"));
|
||||
NS_RELEASE(reader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
stream->name = "image decode";
|
||||
stream->complete = il_stream_complete;
|
||||
stream->abort = il_abort;
|
||||
stream->is_write_ready = il_write_ready;
|
||||
stream->data_object = (void *)reader;
|
||||
stream->window_id = (MWContext *)cx;
|
||||
stream->put_block = (MKStreamWriteFunc) il_first_write;
|
||||
|
||||
// Careful not to call NS_RELEASE until the end, because it sets reader=NULL.
|
||||
NS_RELEASE(reader);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
IL_IMPLEMENT(PRBool)
|
||||
IL_PreferredStream(URL_Struct *urls)
|
||||
{
|
||||
il_container *ic = 0;
|
||||
IL_ImageReq *image_req;
|
||||
ilIURL *iurl;
|
||||
ilINetReader *reader;
|
||||
|
||||
PR_ASSERT(urls);
|
||||
if (urls) {
|
||||
/* xxx this MUST be an image stream */
|
||||
iurl = (ilIURL *)urls->fe_data;
|
||||
reader = iurl->GetReader();
|
||||
ic = IL_GetNetReaderContainer(reader);
|
||||
NS_RELEASE(reader);
|
||||
|
||||
PR_ASSERT(ic);
|
||||
if (ic) {
|
||||
/*
|
||||
* It could be that layout aborted image loading by
|
||||
* calling IL_FreeImage before the netlib finished
|
||||
* transferring data. Don't do anything.
|
||||
*/
|
||||
if (ic->state == IC_ABORT_PENDING)
|
||||
return PR_FALSE;
|
||||
|
||||
/* discover if layout is blocked on this image */
|
||||
for (image_req = ic->clients; image_req;
|
||||
image_req = image_req->next) {
|
||||
#ifdef MOZ_NGLAYOUT
|
||||
XP_ASSERT(0);
|
||||
#else
|
||||
#ifndef M12N /* XXXM12N Fixme. Observer for layout?
|
||||
Query mechanism for FE? */
|
||||
if ((LO_BlockedOnImage(c->cx,
|
||||
(LO_ImageStruct*)c->client) == TRUE) ||
|
||||
FE_ImageOnScreen(c->cx, (LO_ImageStruct*)c->client) )
|
||||
#endif /* M12N */
|
||||
#endif /* MOZ_NGLAYOUT */
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* if.h --- Top-level image library internal routines
|
||||
*
|
||||
* $Id: if.h,v 3.1 1998/03/28 03:35:01 ltabb Exp $
|
||||
* $Id: if.h,v 3.2 1998/07/27 16:09:30 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#ifndef _if_h
|
||||
|
@ -28,10 +28,25 @@
|
|||
|
||||
#define IL_INTERNAL
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prtime.h"
|
||||
#include "prlong.h"
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "xpcompat.h"
|
||||
#else
|
||||
#include "xp_mcom.h" /* XP definitions and types. */
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
#include "ntypes.h" /* typedefs for commonly used Netscape data
|
||||
structures */
|
||||
|
||||
#ifndef STANDALONE_IMAGE_LIB
|
||||
#include "net.h"
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
typedef struct _IL_GroupContext IL_GroupContext;
|
||||
typedef struct _IL_ImageReq IL_ImageReq;
|
||||
|
@ -43,9 +58,16 @@ typedef struct il_container_struct il_container;
|
|||
#include "libimg.h" /* Public API to Image Library. */
|
||||
#include "il_utilp.h" /* Private header for colormap/colorspaces. */
|
||||
#include "il_util.h" /* Public API for colormaps/colorspaces. */
|
||||
#include "ilINetContext.h"
|
||||
#include "ilIURL.h"
|
||||
#include "ilINetReader.h"
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "ilIImageRenderer.h"
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/*****************************XXXM12N Get rid of this. ***********************/
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
typedef void
|
||||
(*TimeoutCallbackFunction) (void * closure);
|
||||
|
||||
|
@ -53,6 +75,7 @@ extern void *
|
|||
FE_SetTimeout(TimeoutCallbackFunction func, void * closure, uint32 msecs);
|
||||
extern void
|
||||
FE_ClearTimeout(void *timer_id);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
/*********************************XXXM12N*************************************/
|
||||
|
||||
|
@ -63,24 +86,22 @@ FE_ClearTimeout(void *timer_id);
|
|||
/* #define DEBUG_GROUP_OBSERVER */
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef XP_MAC
|
||||
#define Debug 1
|
||||
#else
|
||||
extern int Debug;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#define _USD 1 /* scanlines upside-down */
|
||||
#endif
|
||||
|
||||
extern PRLogModuleInfo *il_log_module;
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ILTRACE(l,t) { if(il_debug>l) {XP_TRACE(t);} }
|
||||
#define ILTRACE(l,t) { if(il_debug>l) {PR_LOG(il_log_module, 1, t);} }
|
||||
#else
|
||||
#define ILTRACE(l,t) {}
|
||||
#endif
|
||||
|
||||
#define FREE_IF_NOT_NULL(x) do {if (x) {XP_FREE(x); (x) = NULL;}} while (0)
|
||||
#define FREE_IF_NOT_NULL(x) do {if (x) {PR_FREEIF(x); (x) = NULL;}} while (0)
|
||||
|
||||
#ifndef NSPR20
|
||||
#include "prosdep.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
|
||||
|
@ -178,7 +199,7 @@ struct il_container_struct {
|
|||
il_container *next; /* Cache bidirectional linked list */
|
||||
il_container *prev;
|
||||
|
||||
IL_URL *url;
|
||||
ilIURL *url;
|
||||
char *url_address; /* Same as url->address if there is no redirection*/
|
||||
|
||||
uint32 hash;
|
||||
|
@ -225,8 +246,6 @@ struct il_container_struct {
|
|||
int pass; /* pass (scan #) of a multi-pass image.
|
||||
Used for interlaced GIFs & p-JPEGs */
|
||||
|
||||
NET_StreamClass *stream; /* back pointer to the stream */
|
||||
|
||||
int forced;
|
||||
uint32 content_length;
|
||||
|
||||
|
@ -255,8 +274,12 @@ struct il_container_struct {
|
|||
Used during image decoding only. */
|
||||
IL_DisplayType display_type; /* Type of display for which the container
|
||||
is created. */
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
ilIImageRenderer *img_cb;
|
||||
#else
|
||||
IMGCBIF *img_cb; /* JMC callback interface. */
|
||||
IL_NetContext *net_cx; /* Context which initiated this transfer. */
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
ilINetContext *net_cx; /* Context which initiated this transfer. */
|
||||
|
||||
IL_ImageReq *clients; /* List of clients of this container. */
|
||||
IL_ImageReq *lclient; /* Last client in the client list. */
|
||||
|
@ -274,7 +297,7 @@ struct il_container_struct {
|
|||
time_t expires; /* Expiration date for the corresponding URL */
|
||||
|
||||
#ifdef DEBUG
|
||||
time_t start_time;
|
||||
PRTime start_time;
|
||||
#endif
|
||||
char *fetch_url; /* actual url address used */
|
||||
};
|
||||
|
@ -291,7 +314,11 @@ typedef enum il_draw_mode
|
|||
|
||||
/* A context for a group of images. */
|
||||
struct _IL_GroupContext {
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
ilIImageRenderer *img_cb;
|
||||
#else
|
||||
IMGCBIF *img_cb; /* JMC callback interface to front ends. */
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
void *dpy_cx; /* An opaque pointer passed back to all
|
||||
callbacks in the interface vtable. */
|
||||
|
||||
|
@ -340,7 +367,7 @@ struct _IL_ImageReq {
|
|||
|
||||
IL_GroupContext *img_cx; /* The group context to which this request
|
||||
belongs. */
|
||||
IL_NetContext *net_cx; /* A clone of the net context which the image
|
||||
ilINetContext *net_cx; /* A clone of the net context which the image
|
||||
library was given when this image handle was
|
||||
created. This serves as a backup in case
|
||||
the image container's net_cx becomes invalid,
|
||||
|
@ -357,6 +384,7 @@ struct _IL_ImageReq {
|
|||
|
||||
|
||||
extern int il_debug;
|
||||
extern uint8 il_identity_index_map[];
|
||||
|
||||
extern void il_delete_container(il_container *ic);
|
||||
extern il_container *il_removefromcache(il_container *ic);
|
||||
|
@ -364,10 +392,30 @@ extern void il_image_abort(il_container *ic);
|
|||
extern void il_image_complete(il_container *ic);
|
||||
extern PRBool il_image_stopped(il_container *ic);
|
||||
|
||||
extern unsigned int il_write_ready(NET_StreamClass *stream);
|
||||
extern int il_first_write(NET_StreamClass *stream, const unsigned char *str, int32 len);
|
||||
extern void il_abort(NET_StreamClass *stream, int status);
|
||||
extern void il_stream_complete(NET_StreamClass *stream);
|
||||
extern ilINetReader *IL_NewNetReader(il_container *ic);
|
||||
extern il_container *IL_GetNetReaderContainer(ilINetReader *reader);
|
||||
|
||||
#ifndef M12N_NEW_DEPENDENCIES /* XXXM12N */
|
||||
extern unsigned int IL_StreamWriteReady(il_container *ic);
|
||||
extern int IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len);
|
||||
extern int IL_StreamWrite(il_container *ic, const unsigned char *str, int32 len);
|
||||
extern void IL_StreamAbort(il_container *ic, int status);
|
||||
extern void IL_StreamComplete(il_container *ic, PRBool is_multipart);
|
||||
extern void IL_NetRequestDone(il_container *ic, ilIURL *urls, int status);
|
||||
extern PRBool IL_StreamCreated(il_container *ic, ilIURL *urls, int type);
|
||||
#else
|
||||
extern jint
|
||||
il_write_ready(NET_StreamClass *stream, jint op, struct JMCException* *exceptionThrown);
|
||||
extern jint
|
||||
il_first_write(NET_StreamClass *stream, jint op, jbyte* str, jsize len,
|
||||
struct JMCException* *exceptionThrown);
|
||||
extern void
|
||||
il_abort(NET_StreamClass *stream, jint op, jint status,
|
||||
struct JMCException* *exceptionThrown);
|
||||
extern void
|
||||
il_stream_complete(NET_StreamClass *stream, jint op,
|
||||
struct JMCException* *exceptionThrown);
|
||||
#endif /* M12N_NEW_DEPENDENCIES */
|
||||
|
||||
extern int il_gif_init(il_container *ic);
|
||||
extern int il_gif_write(il_container *, const uint8 *, int32);
|
||||
|
@ -451,7 +499,11 @@ extern il_container
|
|||
|
||||
/* Destroy an IL_Pixmap. */
|
||||
extern void
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
il_destroy_pixmap(ilIImageRenderer *img_cb, IL_Pixmap *pixmap);
|
||||
#else
|
||||
il_destroy_pixmap(IMGCBIF *img_cb, IL_Pixmap *pixmap);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
extern uint32 il_hash(const char *ubuf);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il.h --- Exported image library interface
|
||||
*
|
||||
* $Id: il.h,v 3.1 1998/03/28 03:35:02 ltabb Exp $
|
||||
* $Id: il.h,v 3.2 1998/07/27 16:09:31 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
@ -78,80 +78,6 @@ struct IL_RGB_struct {
|
|||
#endif /* M12N */
|
||||
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
#ifndef M12N /* Get rid of these prototypes */
|
||||
extern Bool IL_ReplaceImage (MWContext *context, LO_ImageStruct *new_lo_image,
|
||||
LO_ImageStruct *old_lo_image);
|
||||
|
||||
extern IL_IRGB *IL_UpdateColorMap(MWContext *context, IL_IRGB *in,
|
||||
int in_colors, int free_colors,
|
||||
int *out_colors, IL_IRGB *transparent);
|
||||
extern int IL_RealizeDefaultColormap(MWContext *context, IL_IRGB *bgcolor,
|
||||
int max_colors);
|
||||
|
||||
extern int IL_EnableTrueColor(MWContext *context, int bitsperpixel,
|
||||
int rshift, int gshift, int bshift,
|
||||
int rbits, int gbits, int bbits,
|
||||
IL_IRGB *transparent,
|
||||
int wild_wacky_rounding);
|
||||
extern int IL_GreyScale(MWContext *context, int depth, IL_IRGB *transparent);
|
||||
extern int IL_InitContext(MWContext *cx);
|
||||
|
||||
extern void IL_StartPage(MWContext *context);
|
||||
extern void IL_EndPage(MWContext *context);
|
||||
|
||||
extern void IL_DeleteImages(MWContext *cx);
|
||||
|
||||
extern void IL_SamePage(MWContext *cx);
|
||||
|
||||
extern int IL_Type(const char *buf, int32 len);
|
||||
|
||||
extern void IL_DisableScaling(MWContext *cx);
|
||||
|
||||
extern void IL_DisableLowSrc(MWContext *cx);
|
||||
|
||||
extern void IL_SetByteOrder(MWContext *cx, Bool ls_bit_first,
|
||||
Bool ls_byte_first);
|
||||
|
||||
extern int IL_SetTransparent(MWContext *cx, IL_IRGB *transparent);
|
||||
|
||||
extern void IL_NoMoreImages(MWContext *cx);
|
||||
|
||||
extern uint32 IL_ShrinkCache(void);
|
||||
extern uint32 IL_GetCacheSize(void);
|
||||
extern void IL_Shutdown(void);
|
||||
|
||||
extern int IL_ColormapTag(const char *image_url, MWContext* cx);
|
||||
|
||||
extern int IL_DisplayMemCacheInfoAsHTML(FO_Present_Types format_out,
|
||||
URL_Struct *urls,
|
||||
OPAQUE_CONTEXT *net_cx);
|
||||
extern void IL_ScourContext(MWContext *cx);
|
||||
extern void IL_SetImageCacheSize(uint32 new_size);
|
||||
|
||||
extern char *IL_HTMLImageInfo(char *url_address);
|
||||
extern void IL_UseDefaultColormapThisPage(MWContext *cx);
|
||||
|
||||
extern Bool IL_AreThereLoopingImagesForContext(MWContext *cx);
|
||||
|
||||
|
||||
|
||||
extern Bool IL_FreeImage (MWContext *context, IL_Image *portableImage,
|
||||
LO_ImageStruct *lo_image);
|
||||
extern void IL_SetColorRenderMode(MWContext *cx,
|
||||
IL_ColorRenderMode color_render_mode);
|
||||
extern NET_StreamClass * IL_NewStream (FO_Present_Types format_out,
|
||||
void *data_obj, URL_Struct *URL_s,
|
||||
MWContext *context);
|
||||
|
||||
extern NET_StreamClass * IL_ViewStream (FO_Present_Types format_out,
|
||||
void *data_obj, URL_Struct *URL_s,
|
||||
MWContext *context);
|
||||
#endif /* M12N */
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif /* _IL_H */
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "if.h"
|
||||
#include "ilINetReader.h"
|
||||
|
||||
static NS_DEFINE_IID(kINetReaderIID, IL_INETREADER_IID);
|
||||
|
||||
class NetReaderImpl : public ilINetReader {
|
||||
public:
|
||||
|
||||
NetReaderImpl(il_container *aContainer);
|
||||
~NetReaderImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual unsigned int WriteReady();
|
||||
|
||||
virtual int FirstWrite(const unsigned char *str, int32 len);
|
||||
|
||||
virtual int Write(const unsigned char *str, int32 len);
|
||||
|
||||
virtual void StreamAbort(int status);
|
||||
|
||||
virtual void StreamComplete(PRBool is_multipart);
|
||||
|
||||
virtual void NetRequestDone(ilIURL *urls, int status);
|
||||
|
||||
virtual PRBool StreamCreated(ilIURL *urls, int type);
|
||||
|
||||
virtual PRBool IsMulti();
|
||||
|
||||
il_container *GetContainer() {return mContainer;}
|
||||
|
||||
private:
|
||||
il_container *mContainer;
|
||||
};
|
||||
|
||||
NetReaderImpl::NetReaderImpl(il_container *aContainer)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mContainer = aContainer;
|
||||
}
|
||||
|
||||
NetReaderImpl::~NetReaderImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(NetReaderImpl, kINetReaderIID)
|
||||
|
||||
unsigned int
|
||||
NetReaderImpl::WriteReady()
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
return IL_StreamWriteReady(mContainer);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
NetReaderImpl::FirstWrite(const unsigned char *str, int32 len)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
return IL_StreamFirstWrite(mContainer, str, len);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
NetReaderImpl::Write(const unsigned char *str, int32 len)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
return IL_StreamWrite(mContainer, str, len);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetReaderImpl::StreamAbort(int status)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
IL_StreamAbort(mContainer, status);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetReaderImpl::StreamComplete(PRBool is_multipart)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
IL_StreamComplete(mContainer, is_multipart);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetReaderImpl::NetRequestDone(ilIURL *urls, int status)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
IL_NetRequestDone(mContainer, urls, status);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
NetReaderImpl::StreamCreated(ilIURL *urls, int type)
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
return IL_StreamCreated(mContainer, urls, type);
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
NetReaderImpl::IsMulti()
|
||||
{
|
||||
if (mContainer != NULL) {
|
||||
return (PRBool)(mContainer->multi > 0);
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ilINetReader *
|
||||
IL_NewNetReader(il_container *ic)
|
||||
{
|
||||
ilINetReader *reader = new NetReaderImpl(ic);
|
||||
|
||||
if (reader != NULL) {
|
||||
NS_ADDREF(reader);
|
||||
}
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
il_container *
|
||||
IL_GetNetReaderContainer(ilINetReader *reader)
|
||||
{
|
||||
if (reader != NULL) {
|
||||
return ((NetReaderImpl *)reader)->GetContainer();
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
|
@ -19,14 +19,22 @@
|
|||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* il_util.c Colormap and colorspace utilities.
|
||||
*
|
||||
* $Id: il_util.c,v 3.1 1998/03/28 03:35:02 ltabb Exp $
|
||||
* $Id: il_util.cpp,v 3.1 1998/07/27 16:09:35 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "xpcompat.h"
|
||||
#else
|
||||
#include "xp_mcom.h" /* XP definitions and types. */
|
||||
#endif
|
||||
#include "ntypes.h" /* typedefs for commonly used Netscape data
|
||||
structures. */
|
||||
#ifndef STANDALONE_IMAGE_LIB
|
||||
#include "xp_core.h"
|
||||
#endif
|
||||
#include "prtypes.h"
|
||||
#include "prmem.h"
|
||||
|
||||
/* mwh this is for Win 16 comipler. */
|
||||
#ifndef TRUE
|
||||
|
@ -82,15 +90,15 @@ il_NewColorCube(uint32 red_size, uint32 green_size, uint32 blue_size,
|
|||
|
||||
/* We may want to add entries to the map array subsequently, so always
|
||||
allocate space for a full palette. */
|
||||
map = (IL_RGB *)XP_CALLOC(256, sizeof(IL_RGB));
|
||||
map = (IL_RGB *)PR_Calloc(256, sizeof(IL_RGB));
|
||||
if (!map)
|
||||
return FALSE;
|
||||
|
||||
lookup_table = (uint8 *)XP_CALLOC(LOOKUP_TABLE_SIZE, 1);
|
||||
lookup_table = (uint8 *)PR_Calloc(LOOKUP_TABLE_SIZE, 1);
|
||||
if (!lookup_table)
|
||||
return FALSE;
|
||||
|
||||
done = (uint8 *)XP_CALLOC(size, 1);
|
||||
done = (uint8 *)PR_Calloc(size, 1);
|
||||
if (!done)
|
||||
return FALSE;
|
||||
|
||||
|
@ -125,13 +133,13 @@ il_NewColorCube(uint32 red_size, uint32 green_size, uint32 blue_size,
|
|||
/* Fill in the lookup table entry with the colormap index. */
|
||||
*ptr++ = map_index;
|
||||
}
|
||||
XP_FREE(done);
|
||||
PR_FREEIF(done);
|
||||
|
||||
|
||||
cmap = XP_NEW_ZAP(IL_ColorMap);
|
||||
cmap = PR_NEWZAP(IL_ColorMap);
|
||||
if (!cmap) {
|
||||
XP_FREE(map);
|
||||
XP_FREE(lookup_table);
|
||||
PR_FREEIF(map);
|
||||
PR_FREEIF(lookup_table);
|
||||
return NULL;
|
||||
}
|
||||
cmap->num_colors = size;
|
||||
|
@ -208,7 +216,7 @@ select_ncolors(int Ncolors[],
|
|||
function represents the current state of affairs, and it will eventually
|
||||
be replaced when the Image Library has the capability to dither to an
|
||||
arbitrary palette. */
|
||||
IL_ColorMap *
|
||||
IL_IMPLEMENT(IL_ColorMap *)
|
||||
IL_NewCubeColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
||||
uint16 num_colors)
|
||||
{
|
||||
|
@ -239,7 +247,7 @@ IL_NewCubeColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
|||
|
||||
/* Create an optimal fixed palette of the specified size, starting with
|
||||
the given set of reserved colors. */
|
||||
IL_ColorMap *
|
||||
IL_IMPLEMENT(IL_ColorMap *)
|
||||
IL_NewOptimalColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
||||
uint16 num_colors)
|
||||
{
|
||||
|
@ -249,20 +257,20 @@ IL_NewOptimalColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
|
|||
|
||||
/* Create an empty colormap. The caller is responsible for filling in the
|
||||
colormap entries. */
|
||||
IL_ColorMap *
|
||||
IL_IMPLEMENT(IL_ColorMap *)
|
||||
IL_NewColorMap(void)
|
||||
{
|
||||
IL_RGB *map;
|
||||
IL_ColorMap *cmap;
|
||||
|
||||
cmap = XP_NEW_ZAP(IL_ColorMap);
|
||||
cmap = PR_NEWZAP(IL_ColorMap);
|
||||
if (!cmap)
|
||||
return NULL;
|
||||
|
||||
/* We always allocate space for a full palette. */
|
||||
map = (IL_RGB *)XP_CALLOC(256, sizeof(IL_RGB));
|
||||
map = (IL_RGB *)PR_Calloc(256, sizeof(IL_RGB));
|
||||
if (!map) {
|
||||
XP_FREE(cmap);
|
||||
PR_FREEIF(cmap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -286,7 +294,7 @@ IL_NewColorMap(void)
|
|||
to the old colormap. Therefore, the current purpose of this function is
|
||||
to add colors (such as a background color for transparent images) which
|
||||
are not a part of the Image Library's color cube. */
|
||||
int
|
||||
IL_IMPLEMENT(int)
|
||||
IL_AddColorToColorMap(IL_ColorMap *cmap, IL_IRGB *new_color)
|
||||
{
|
||||
int max_colors = 256;
|
||||
|
@ -312,23 +320,20 @@ IL_AddColorToColorMap(IL_ColorMap *cmap, IL_IRGB *new_color)
|
|||
/* Free all memory associated with a given colormap.
|
||||
Note: This should *not* be used to destroy a colormap once it has been
|
||||
passed into IL_CreatePseudoColorSpace. Use IL_ReleaseColorSpace instead */
|
||||
void
|
||||
IL_IMPLEMENT(void)
|
||||
IL_DestroyColorMap (IL_ColorMap *cmap)
|
||||
{
|
||||
if (cmap) {
|
||||
if (cmap->map)
|
||||
XP_FREE(cmap->map);
|
||||
if (cmap->index)
|
||||
XP_FREE(cmap->index);
|
||||
if (cmap->table)
|
||||
XP_FREE(cmap->table);
|
||||
XP_FREE(cmap);
|
||||
PR_FREEIF(cmap->map);
|
||||
PR_FREEIF(cmap->index);
|
||||
PR_FREEIF(cmap->table);
|
||||
PR_FREEIF(cmap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reorder the entries in a colormap. new_order is an array mapping the old
|
||||
indices to the new indices. */
|
||||
void
|
||||
IL_IMPLEMENT(void)
|
||||
IL_ReorderColorMap(IL_ColorMap *cmap, uint16 *new_order)
|
||||
{
|
||||
}
|
||||
|
@ -342,12 +347,12 @@ IL_ReorderColorMap(IL_ColorMap *cmap, uint16 *new_order)
|
|||
might be necessary, e.g. for an alpha channel, or for alignment. Note: the
|
||||
contents of the IL_RGBBits structure will be copied, so they need not be
|
||||
preserved after the call to IL_CreateTrueColorSpace. */
|
||||
IL_ColorSpace *
|
||||
IL_IMPLEMENT(IL_ColorSpace *)
|
||||
IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth)
|
||||
{
|
||||
IL_ColorSpace *color_space;
|
||||
|
||||
color_space = XP_NEW_ZAP(IL_ColorSpace);
|
||||
color_space = PR_NEWZAP(IL_ColorSpace);
|
||||
if (!color_space)
|
||||
return NULL;
|
||||
|
||||
|
@ -359,9 +364,9 @@ IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth)
|
|||
color_space->pixmap_depth = pixmap_depth; /* Destination image depth. */
|
||||
|
||||
/* Create the private part of the color_space */
|
||||
color_space->private_data = (void *)XP_NEW_ZAP(il_ColorSpaceData);
|
||||
color_space->private_data = (void *)PR_NEWZAP(il_ColorSpaceData);
|
||||
if (!color_space->private_data) {
|
||||
XP_FREE(color_space);
|
||||
PR_FREEIF(color_space);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -380,13 +385,13 @@ IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth)
|
|||
the colormap, *is* available through the colormap member of the
|
||||
IL_ColorSpace. Memory associated with the colormap will be freed by
|
||||
IL_ReleaseColorSpace when the reference count reaches zero. */
|
||||
IL_ColorSpace *
|
||||
IL_IMPLEMENT(IL_ColorSpace *)
|
||||
IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
|
||||
uint8 pixmap_depth)
|
||||
{
|
||||
IL_ColorSpace *color_space;
|
||||
|
||||
color_space = XP_NEW_ZAP(IL_ColorSpace);
|
||||
color_space = PR_NEWZAP(IL_ColorSpace);
|
||||
if (!color_space)
|
||||
return NULL;
|
||||
|
||||
|
@ -397,12 +402,12 @@ IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
|
|||
/* Copy the contents of the IL_ColorMap structure. This copies the map
|
||||
and table pointers, not the arrays themselves. */
|
||||
XP_MEMCPY(&color_space->cmap, cmap, sizeof(IL_ColorMap));
|
||||
XP_FREE(cmap);
|
||||
PR_FREEIF(cmap);
|
||||
|
||||
/* Create the private part of the color_space */
|
||||
color_space->private_data = (void *)XP_NEW_ZAP(il_ColorSpaceData);
|
||||
color_space->private_data = (void *)PR_NEWZAP(il_ColorSpaceData);
|
||||
if (!color_space->private_data) {
|
||||
XP_FREE(color_space);
|
||||
PR_FREEIF(color_space);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -414,12 +419,12 @@ IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
|
|||
set the reference count to 1. The pixmap_depth is the index_depth plus
|
||||
any additional allowance that might be necessary e.g. for an alpha channel,
|
||||
or for alignment. */
|
||||
IL_ColorSpace *
|
||||
IL_IMPLEMENT(IL_ColorSpace *)
|
||||
IL_CreateGreyScaleColorSpace(uint8 index_depth, uint8 pixmap_depth)
|
||||
{
|
||||
IL_ColorSpace *color_space;
|
||||
|
||||
color_space = XP_NEW_ZAP(IL_ColorSpace);
|
||||
color_space = PR_NEWZAP(IL_ColorSpace);
|
||||
if (!color_space)
|
||||
return NULL;
|
||||
|
||||
|
@ -429,9 +434,9 @@ IL_CreateGreyScaleColorSpace(uint8 index_depth, uint8 pixmap_depth)
|
|||
color_space->cmap.num_colors = (1 << index_depth);
|
||||
|
||||
/* Create the private part of the color_space */
|
||||
color_space->private_data = (void *)XP_NEW_ZAP(il_ColorSpaceData);
|
||||
color_space->private_data = (void *)PR_NEWZAP(il_ColorSpaceData);
|
||||
if (!color_space->private_data) {
|
||||
XP_FREE(color_space);
|
||||
PR_FREEIF(color_space);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -442,7 +447,7 @@ IL_CreateGreyScaleColorSpace(uint8 index_depth, uint8 pixmap_depth)
|
|||
/* Decrements the reference count for an IL_ColorSpace. If the reference
|
||||
count reaches zero, all memory associated with the colorspace (including
|
||||
any colormap associated memory) will be freed. */
|
||||
void
|
||||
IL_IMPLEMENT(void)
|
||||
IL_ReleaseColorSpace(IL_ColorSpace *color_space)
|
||||
{
|
||||
color_space->ref_count--;
|
||||
|
@ -454,15 +459,15 @@ IL_ReleaseColorSpace(IL_ColorSpace *color_space)
|
|||
|
||||
/* Free any colormap associated memory. */
|
||||
if (cmap->map) {
|
||||
XP_FREE(cmap->map);
|
||||
PR_FREEIF(cmap->map);
|
||||
cmap->map = NULL;
|
||||
}
|
||||
if (cmap->index) {
|
||||
XP_FREE(cmap->index);
|
||||
PR_FREEIF(cmap->index);
|
||||
cmap->index = NULL;
|
||||
}
|
||||
if (cmap->table) {
|
||||
XP_FREE(cmap->table);
|
||||
PR_FREEIF(cmap->table);
|
||||
cmap->table = NULL;
|
||||
}
|
||||
|
||||
|
@ -470,31 +475,31 @@ IL_ReleaseColorSpace(IL_ColorSpace *color_space)
|
|||
|
||||
/* Free any RGB depth conversion maps. */
|
||||
if (private_data->r8torgbn) {
|
||||
XP_FREE(private_data->r8torgbn);
|
||||
PR_FREEIF(private_data->r8torgbn);
|
||||
private_data->r8torgbn = NULL;
|
||||
}
|
||||
if (private_data->g8torgbn) {
|
||||
XP_FREE(private_data->g8torgbn);
|
||||
PR_FREEIF(private_data->g8torgbn);
|
||||
private_data->g8torgbn = NULL;
|
||||
}
|
||||
if (private_data->b8torgbn) {
|
||||
XP_FREE(private_data->b8torgbn);
|
||||
PR_FREEIF(private_data->b8torgbn);
|
||||
private_data->b8torgbn = NULL;
|
||||
}
|
||||
|
||||
/* Free the il_ColorSpaceData */
|
||||
XP_FREE(private_data);
|
||||
PR_FREEIF(private_data);
|
||||
color_space->private_data = NULL;
|
||||
}
|
||||
|
||||
/* Free the IL_ColorSpace structure. */
|
||||
XP_FREE(color_space);
|
||||
PR_FREEIF(color_space);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Increment the reference count for an IL_ColorSpace. */
|
||||
void
|
||||
IL_IMPLEMENT(void)
|
||||
IL_AddRefToColorSpace(IL_ColorSpace *color_space)
|
||||
{
|
||||
color_space->ref_count++;
|
|
@ -20,7 +20,7 @@
|
|||
* il_utilp.h Colormap and colorspace utilities - types and definitions
|
||||
* private to Image Library.
|
||||
*
|
||||
* $Id: il_utilp.h,v 3.1 1998/03/28 03:35:02 ltabb Exp $
|
||||
* $Id: il_utilp.h,v 3.2 1998/07/27 16:09:36 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -26,7 +26,6 @@
|
|||
|
||||
|
||||
|
||||
void read_png(il_container *ic, IL_Stream *stream, unsigned int sig_read);
|
||||
|
||||
void png_get_info(const unsigned char *buf, png_structp png_ptr, png_infop info_ptr);
|
||||
void png_read_strm( png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
|
@ -57,13 +56,10 @@ int
|
|||
il_png_init(il_container *ic)
|
||||
{
|
||||
|
||||
png_structp read_ptr, write_ptr;
|
||||
png_infop read_info_ptr, write_info_ptr, end_info_ptr;
|
||||
|
||||
ipng_struct *ipngs;
|
||||
NI_ColorSpace *src_color_space = ic->src_header->color_space;
|
||||
|
||||
ipngs = XP_NEW_ZAP(ipng_struct);
|
||||
ipngs = PR_NEWZAP(ipng_struct);
|
||||
if (ipngs)
|
||||
{
|
||||
ic->ds = ipngs;
|
||||
|
@ -93,8 +89,6 @@ int il_png_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
||||
int status, done;
|
||||
|
||||
/*------*/
|
||||
|
||||
|
||||
|
@ -109,7 +103,7 @@ int il_png_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
|
||||
return !OK;
|
||||
}
|
||||
png_set_progressive_read_fn(png_ptr, buf,
|
||||
png_set_progressive_read_fn(png_ptr, (void *)buf,
|
||||
info_callback, row_callback, end_callback);
|
||||
}
|
||||
else{
|
||||
|
@ -118,7 +112,7 @@ int il_png_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
}
|
||||
/* note addition of ic to png structure.... */
|
||||
png_ptr->io_ptr = ic;
|
||||
png_process_data( png_ptr, info_ptr, buf, len );
|
||||
png_process_data( png_ptr, info_ptr, (unsigned char *)buf, len );
|
||||
|
||||
ipng_ptr->state = PNG_CONTINUE;
|
||||
|
||||
|
@ -137,7 +131,7 @@ png_set_dims( il_container *ic, png_structp png_ptr)
|
|||
src_hdr->height = img_hdr->height = png_ptr->height;
|
||||
|
||||
if((png_ptr->channels > 3 )||(png_ptr->trans)){
|
||||
il_create_alpha_mask( png_ptr->io_ptr, 0, png_ptr->width, png_ptr->height);
|
||||
il_create_alpha_mask( (il_container *)png_ptr->io_ptr, 0, png_ptr->width, png_ptr->height);
|
||||
ic->image->header.is_interleaved_alpha = TRUE;
|
||||
il_init_image_transparent_pixel(ic);
|
||||
|
||||
|
@ -159,7 +153,7 @@ il_png_init_transparency(png_structp png_ptr, il_container *ic, int index)
|
|||
IL_IRGB *img_trans_pixel;
|
||||
|
||||
if (ic->src_header) {
|
||||
ic->src_header->transparent_pixel = XP_NEW_ZAP(IL_IRGB);
|
||||
ic->src_header->transparent_pixel = PR_NEWZAP(IL_IRGB);
|
||||
}
|
||||
src_trans_pixel = ic->src_header->transparent_pixel;
|
||||
|
||||
|
@ -196,7 +190,7 @@ il_png_destroy_transparency(il_container *ic)
|
|||
|
||||
if (src_header->transparent_pixel) {
|
||||
/* Destroy the source image's transparent pixel. */
|
||||
XP_FREE(src_header->transparent_pixel);
|
||||
PR_FREEIF(src_header->transparent_pixel);
|
||||
src_header->transparent_pixel = NULL;
|
||||
|
||||
/* Destroy the destination image's transparent pixel. */
|
||||
|
@ -210,7 +204,7 @@ png_delay_time_callback(void *closure)
|
|||
{
|
||||
ipng_struct *ipng_ptr = (ipng_struct *)closure;
|
||||
|
||||
XP_ASSERT(ipng_ptr->state == PNG_DELAY);
|
||||
PR_ASSERT(ipng_ptr->state == PNG_DELAY);
|
||||
|
||||
ipng_ptr->delay_time = NULL;
|
||||
|
||||
|
@ -226,7 +220,7 @@ void il_png_complete(il_container *ic)
|
|||
{
|
||||
ipng_structp ipng_ptr;
|
||||
|
||||
ipng_ptr = ic->ds;
|
||||
ipng_ptr = (ipng_structp)ic->ds;
|
||||
|
||||
il_png_abort(ic);
|
||||
|
|
@ -18,17 +18,18 @@
|
|||
|
||||
/*
|
||||
* jpeg.c --- Glue code to Independent JPEG Group decoder library
|
||||
* $Id: jpeg.c,v 3.1 1998/03/28 03:35:03 ltabb Exp $
|
||||
* $Id: jpeg.cpp,v 3.1 1998/07/27 16:09:43 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#include "xp.h"
|
||||
*/
|
||||
|
||||
#include "if.h"
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#include "xpcompat.h"
|
||||
#else
|
||||
#include "xp_core.h"
|
||||
#endif
|
||||
#include "merrors.h"
|
||||
|
||||
#include "il.h"
|
||||
|
@ -38,11 +39,13 @@
|
|||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jerror.h"
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#ifdef XP_OS2_HACK
|
||||
/* IBM-MAS: We removed setjmp.h from XP_core.h, now we need it here. */
|
||||
|
@ -147,7 +150,7 @@ il_error_exit (j_common_ptr cinfo)
|
|||
/* Create the message */
|
||||
(*cinfo->err->format_message) (cinfo, buffer);
|
||||
|
||||
XP_TRACE(("%s\n", buffer));
|
||||
ILTRACE(1,("%s\n", buffer));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -264,9 +267,9 @@ fill_input_buffer (j_decompress_ptr jd)
|
|||
roundup_buflen = ((new_backtrack_buflen + 15) >> 4) << 4;
|
||||
if (src->backtrack_buffer_size) {
|
||||
src->backtrack_buffer =
|
||||
(JOCTET *)XP_REALLOC(src->backtrack_buffer, roundup_buflen);
|
||||
(JOCTET *)PR_REALLOC(src->backtrack_buffer, roundup_buflen);
|
||||
} else {
|
||||
src->backtrack_buffer = (JOCTET*)XP_ALLOC(roundup_buflen);
|
||||
src->backtrack_buffer = (JOCTET*)PR_MALLOC(roundup_buflen);
|
||||
}
|
||||
|
||||
/* Check for OOM */
|
||||
|
@ -298,7 +301,7 @@ fill_input_buffer (j_decompress_ptr jd)
|
|||
goto suspend;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -362,9 +365,9 @@ setup_jpeg_src (j_decompress_ptr jd, jpeg_struct *js)
|
|||
il_source_mgr *src;
|
||||
|
||||
if (jd->src == NULL) {
|
||||
src = XP_NEW_ZAP(il_source_mgr);
|
||||
src = PR_NEWZAP(il_source_mgr);
|
||||
if (!src) {
|
||||
XP_TRACE(("il:jpeg: src manager memory lossage"));
|
||||
ILTRACE(1,("il:jpeg: src manager memory lossage"));
|
||||
return FALSE;
|
||||
}
|
||||
jd->src = (struct jpeg_source_mgr *) src;
|
||||
|
@ -456,9 +459,8 @@ il_jpeg_COM_handler (j_decompress_ptr cinfo)
|
|||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
length -= 2; /* discount the length word itself */
|
||||
|
||||
if (ic->comment)
|
||||
XP_FREE(ic->comment);
|
||||
comment = ic->comment = (char *)XP_ALLOC(length + 1);
|
||||
PR_FREEIF(ic->comment);
|
||||
comment = ic->comment = (char *)PR_MALLOC(length + 1);
|
||||
ic->comment_length = length;
|
||||
|
||||
if (!ic->comment) {
|
||||
|
@ -497,9 +499,9 @@ int il_jpeg_init(il_container *ic)
|
|||
NI_ColorSpace *src_color_space = ic->src_header->color_space;
|
||||
NI_RGBBits *rgb = &src_color_space->bit_alloc.rgb;
|
||||
|
||||
js = XP_NEW_ZAP(jpeg_struct);
|
||||
js = PR_NEWZAP(jpeg_struct);
|
||||
if (!js) {
|
||||
XP_TRACE(("il:jpeg: jpeg_struct memory lossage"));
|
||||
ILTRACE(1,("il:jpeg: jpeg_struct memory lossage"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -534,7 +536,7 @@ int il_jpeg_init(il_container *ic)
|
|||
|
||||
/* Setup jpeg data source object */
|
||||
if (!setup_jpeg_src(jd, js)) {
|
||||
XP_TRACE(("il:jpeg: jpeg source memory lossage"));
|
||||
ILTRACE(1,("il:jpeg: jpeg source memory lossage"));
|
||||
/* Free up all the data structures */
|
||||
il_jpeg_abort(ic);
|
||||
return FALSE;
|
||||
|
@ -728,10 +730,10 @@ il_jpeg_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
|
||||
/* If this assert fires, chances are the netlib
|
||||
continued to send data after the image stream was closed. */
|
||||
XP_ASSERT(js);
|
||||
PR_ASSERT(js);
|
||||
if (!js) {
|
||||
#ifdef DEBUG
|
||||
XP_TRACE(("Netlib sent data after the image stream was closed\n"));
|
||||
ILTRACE(1,("Netlib sent data after the image stream was closed\n"));
|
||||
#endif
|
||||
return MK_IMAGE_LOSSAGE;
|
||||
}
|
||||
|
@ -762,7 +764,7 @@ il_jpeg_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
ic->src_header->width = jd->image_width;
|
||||
ic->src_header->height = jd->image_height;
|
||||
if ((status = il_size(ic))) {
|
||||
XP_TRACE(("il:jpeg: MEM il_size"));
|
||||
ILTRACE(1,("il:jpeg: MEM il_size"));
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -922,7 +924,7 @@ il_jpeg_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -945,10 +947,10 @@ il_jpeg_abort(il_container *ic)
|
|||
*/
|
||||
if (src) {
|
||||
if (src->backtrack_buffer) {
|
||||
XP_FREE(src->backtrack_buffer);
|
||||
PR_FREEIF(src->backtrack_buffer);
|
||||
src->backtrack_buffer = NULL;
|
||||
}
|
||||
XP_FREE(src);
|
||||
PR_FREEIF(src);
|
||||
js->jd.src = NULL;
|
||||
}
|
||||
|
||||
|
@ -968,7 +970,7 @@ il_jpeg_abort(il_container *ic)
|
|||
js->samples3 = NULL;
|
||||
|
||||
/* Finally, free up our private decoder structure. */
|
||||
XP_FREE(js);
|
||||
PR_FREEIF(js);
|
||||
ic->ds = NULL;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,9 @@ LOCAL_JMC_SUBDIR = .
|
|||
|
||||
|
||||
#LIBRARY_NAME = img$(MOZ_BITS)
|
||||
!ifndef STANDALONE_IMAGE_LIB
|
||||
IMGSRC= $(DEPTH)\modules\libimg\src\_jmc
|
||||
!endif
|
||||
|
||||
#
|
||||
# Make sure we have MOZILLA_CLIENT defined so we get the
|
||||
|
@ -42,52 +44,129 @@ LCFLAGS = $(LCFLAGS) -DMOZILLA_CLIENT
|
|||
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
|
||||
!endif
|
||||
|
||||
LCFLAGS = $(LCFLAGS) /TP
|
||||
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
LLIBS=$(DIST)\lib\png.lib \
|
||||
$(LIBNSPR) \
|
||||
$(LIBJPEG) \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\zip$(MOZ_BITS)$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(NULL)
|
||||
!else
|
||||
LLIBS=$(DIST)\lib\png.lib \
|
||||
$(NULL)
|
||||
!endif
|
||||
|
||||
MISCDEP=$(LLIBS)
|
||||
!ifndef STANDALONE_IMAGE_LIB
|
||||
OBJS=.\$(OBJDIR)\MIMGCB.obj \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = \
|
||||
_jmc\MIMGCB.c \
|
||||
$(NULL)
|
||||
|
||||
!endif
|
||||
|
||||
#LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
LIBRARY_SUFFIX = $(MOZ_BITS)$(VERSION_NUMBER)
|
||||
!else
|
||||
LIBRARY_SUFFIX = $(MOZ_BITS)
|
||||
!endif
|
||||
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DLLNAME=img$(MOZ_BITS)$(VERSION_NUMBER)
|
||||
DLL1NAME=img$(MOZ_BITS)$(VERSION_NUMBER)
|
||||
PDBFILE=$(DLLNAME).pdb
|
||||
MAPFILE=$(DLLNAME).map
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
!ifdef NSPR20
|
||||
DEFFILE=$(DLL1NAME).def
|
||||
!else
|
||||
DEFFILE=$(DLLNAME).def
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
MAPFILE= $(DLLNAME).map
|
||||
|
||||
!endif
|
||||
|
||||
|
||||
MODULE=img
|
||||
DEPTH=..\..\..
|
||||
JMC_GEN=MIMGCB MPSIMGCB
|
||||
LOCAL_INCLUDES=-I../png -I. -I$(DEPTH)/dist/public/zlib
|
||||
JMC_GEN_FLAGS=-cimpl -noexc -module
|
||||
LIBRARY_NAME=img
|
||||
EXTRA_LIBS=$(DIST)/lib/libzlib.a $(DIST)/lib/libpng.a
|
||||
CSRCS=color.c colormap.c dither.c dummy_nc.c external.c gif.c if.c \
|
||||
ilclient.c il_util.c jpeg.c scale.c xbm.c ipng.c png_png.c
|
||||
REQUIRES=jtools java zlib nspr dbm jpeg util img png layer js
|
||||
|
||||
### STANDALONE_IMAGE_LIB
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
CPPSRCS=color.cpp colormap.cpp dither.cpp gif.cpp if.cpp ilclient.cpp il_util.cpp \
|
||||
ilNetReader.cpp jpeg.cpp scale.cpp xbm.cpp ipng.cpp png_png.cpp xpcompat.cpp
|
||||
REQUIRES=zlib nspr jpeg util img png xpcom
|
||||
CPP_OBJS=.\$(OBJDIR)\color.obj .\$(OBJDIR)\colormap.obj \
|
||||
.\$(OBJDIR)\dither.obj .\$(OBJDIR)\gif.obj .\$(OBJDIR)\if.obj \
|
||||
.\$(OBJDIR)\ilclient.obj .\$(OBJDIR)\il_util.obj \
|
||||
.\$(OBJDIR)\ilNetReader.obj .\$(OBJDIR)\jpeg.obj \
|
||||
.\$(OBJDIR)\scale.obj .\$(OBJDIR)\xbm.obj \
|
||||
.\$(OBJDIR)\ipng.obj .\$(OBJDIR)\png_png.obj .\$(OBJDIR)\xpcompat.obj \
|
||||
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\zlib -I$(XPDIST)\public\nspr \
|
||||
-I$(XPDIST)\public\jpeg -I$(XPDIST)\public\util -I$(XPDIST)\public\img \
|
||||
-I$(XPDIST)\public\png -I$(XPDIST)\public\xpcom
|
||||
!endif
|
||||
|
||||
### non-STANDALONE_IMAGE_LIB
|
||||
!else
|
||||
CPPSRCS=color.cpp colormap.cpp dither.cpp dummy_nc.cpp external.cpp gif.cpp if.cpp \
|
||||
ilclient.cpp il_util.cpp jpeg.cpp scale.cpp xbm.cpp ipng.cpp png_png.cpp ilNetReader.cpp
|
||||
REQUIRES=jtools java zlib nspr dbm jpeg util img png layer js xpcom
|
||||
EXPORTS=PIMGCB.h PPSIMGCB.h
|
||||
JMC_HEADERS=$(JMC_GEN_DIR)\MIMGCB.h $(JMC_GEN_DIR)\MPSIMGCB.h
|
||||
JMC_STUBS=$(JMC_GEN_DIR)\MIMGCB.c $(JMC_GEN_DIR)\MPSIMGCB.c
|
||||
JMC_OBJS=.\$(OBJDIR)\MIMGCB.obj .\$(OBJDIR)\MPSIMGCB.obj
|
||||
C_OBJS=.\$(OBJDIR)\color.obj .\$(OBJDIR)\colormap.obj \
|
||||
JMC_GEN=MIMGCB MPSIMGCB
|
||||
JMC_GEN_FLAGS=-cimpl -noexc -module
|
||||
CPP_OBJS=.\$(OBJDIR)\color.obj .\$(OBJDIR)\colormap.obj \
|
||||
.\$(OBJDIR)\dither.obj .\$(OBJDIR)\dummy_nc.obj \
|
||||
.\$(OBJDIR)\external.obj .\$(OBJDIR)\gif.obj .\$(OBJDIR)\if.obj \
|
||||
.\$(OBJDIR)\ilclient.obj .\$(OBJDIR)\il_util.obj \
|
||||
.\$(OBJDIR)\jpeg.obj .\$(OBJDIR)\scale.obj .\$(OBJDIR)\xbm.obj \
|
||||
.\$(OBJDIR)\ipng.obj .\$(OBJDIR)\png_png.obj
|
||||
.\$(OBJDIR)\ipng.obj .\$(OBJDIR)\png_png.obj .\$(OBJDIR)\ilNetReader.obj
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\jtools -I$(XPDIST)\public\java \
|
||||
-I$(XPDIST)\public\zlib -I$(XPDIST)\public\nspr \
|
||||
-I$(XPDIST)\public\dbm -I$(XPDIST)\public\jpeg \
|
||||
-I$(XPDIST)\public\util -I$(XPDIST)\public\img \
|
||||
-I$(XPDIST)\public\png -I$(XPDIST)\public\layer \
|
||||
-I$(XPDIST)\public\js
|
||||
-I$(XPDIST)\public\js -I$(XPDIST)\public\xpcom
|
||||
!endif
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
!else
|
||||
$(JMC_GEN_DIR)\MIMGCB.h: $(JMCSRCDIR)\IMGCB.class
|
||||
$(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)
|
||||
$(JMC_GEN_DIR)\MIMGCB.c: $(JMCSRCDIR)\IMGCB.class
|
||||
|
@ -103,3 +182,4 @@ export:: $(LIBRARY)
|
|||
symbols::
|
||||
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
|
||||
@echo "LIBRARY is $(LIBRARY)"
|
||||
!endif
|
||||
|
|
|
@ -122,7 +122,7 @@ void info_callback(png_structp png_ptr, png_infop info)
|
|||
png_read_update_info(png_ptr, info);
|
||||
|
||||
/* Set the ic values */
|
||||
png_set_dims(png_ptr->io_ptr, png_ptr);
|
||||
png_set_dims((il_container *)png_ptr->io_ptr, png_ptr);
|
||||
|
||||
/* if(png_ptr->num_trans)
|
||||
il_png_init_transparency( png_ptr, png_ptr->io_ptr, png_ptr->trans_values.index);
|
||||
|
@ -138,7 +138,7 @@ il_create_alpha_mask( il_container *ic ,/* png_bytep mask, int srcwidth, */int x
|
|||
if (!ic->mask) {
|
||||
NI_PixmapHeader *mask_header;
|
||||
|
||||
if (!(ic->mask = XP_NEW_ZAP(IL_Pixmap))) {
|
||||
if (!(ic->mask = PR_NEWZAP(IL_Pixmap))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,8 @@ void row_callback( png_structp png_ptr, png_bytep new_row,
|
|||
il_container *ic = (il_container *)png_ptr->io_ptr;
|
||||
|
||||
if(new_row){
|
||||
il_emit_row( png_ptr->io_ptr , 0, new_row,
|
||||
0, png_ptr->width, row_num,
|
||||
il_emit_row( (il_container *)png_ptr->io_ptr , 0,
|
||||
new_row, 0, png_ptr->width, row_num,
|
||||
1, ilErase /* ilOverlay */, png_ptr->pass );
|
||||
/* il_flush_image_data(png_ptr->io_ptr); */
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ void end_callback(png_structp png_ptr, png_infop info)
|
|||
* Most people won't do much here, perhaps setting a flag that
|
||||
* marks the image as finished.
|
||||
*/
|
||||
il_flush_image_data(png_ptr->io_ptr);
|
||||
il_flush_image_data((il_container *)png_ptr->io_ptr);
|
||||
}
|
||||
|
||||
|
|
@ -22,9 +22,6 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
#include "xp.h" Cross-platform definitions
|
||||
*/
|
||||
|
||||
#include "if.h" /* Image library internal declarations */
|
||||
#include "il.h" /* Image library external API */
|
||||
|
@ -179,20 +176,43 @@ il_flush_image_data(il_container *ic)
|
|||
* it to the server.)
|
||||
*/
|
||||
for (;row < (end_row - row_interval); row += row_interval) {
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->UpdatePixmap(img_cx->dpy_cx, image, 0, row,
|
||||
img_header->width, row_interval);
|
||||
#else
|
||||
IMGCBIF_UpdatePixmap(img_cx->img_cb, img_cx->dpy_cx, image, 0, row,
|
||||
img_header->width, row_interval);
|
||||
if (mask)
|
||||
#endif
|
||||
if (mask) {
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->UpdatePixmap(img_cx->dpy_cx, mask, 0, row,
|
||||
mask_header->width, row_interval);
|
||||
#else
|
||||
IMGCBIF_UpdatePixmap(img_cx->img_cb, img_cx->dpy_cx, mask, 0, row,
|
||||
mask_header->width, row_interval);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
}
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
/* Draw whatever is leftover after sending the chunks */
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->UpdatePixmap(img_cx->dpy_cx, image,
|
||||
0, row, img_header->width, end_row - row + 1);
|
||||
#else
|
||||
IMGCBIF_UpdatePixmap(img_cx->img_cb, img_cx->dpy_cx, image, 0, row,
|
||||
img_header->width, end_row - row + 1);
|
||||
if (mask)
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
if (mask) {
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->UpdatePixmap(img_cx->dpy_cx, mask, 0, row,
|
||||
mask_header->width, end_row - row + 1);
|
||||
#else
|
||||
IMGCBIF_UpdatePixmap(img_cx->img_cb, img_cx->dpy_cx, mask, 0, row,
|
||||
mask_header->width, end_row - row + 1);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
}
|
||||
|
||||
/* Update the displayable area of the pixmap. */
|
||||
ic->displayable_rect.x_origin = 0;
|
||||
|
@ -230,8 +250,8 @@ il_scale_RGB_row(
|
|||
uint8 *dest_end = dest + (3 * dest_len);
|
||||
int n = 0;
|
||||
|
||||
XP_ASSERT(dest);
|
||||
XP_ASSERT(src_len != dest_len);
|
||||
PR_ASSERT(dest);
|
||||
PR_ASSERT(src_len != dest_len);
|
||||
|
||||
/* Two cases */
|
||||
|
||||
|
@ -281,8 +301,8 @@ il_scale_CI_row(
|
|||
uint8 *dest_end = dest + dest_len;
|
||||
int n = 0;
|
||||
|
||||
XP_ASSERT(dest);
|
||||
XP_ASSERT(src_len != dest_len);
|
||||
PR_ASSERT(dest);
|
||||
PR_ASSERT(src_len != dest_len);
|
||||
|
||||
/* Two cases */
|
||||
|
||||
|
@ -354,7 +374,7 @@ il_alpha_mask(
|
|||
uint32 *m = ((uint32*)maskp) + (x_offset >> 5);
|
||||
mask_bit = ~x_offset & 0x1f;
|
||||
|
||||
XP_ASSERT(mask_len);
|
||||
PR_ASSERT(mask_len);
|
||||
|
||||
/* Handle case in which we have a mask for a non-transparent
|
||||
image. This can happen when we have a LOSRC that is a transparent
|
||||
|
@ -457,7 +477,7 @@ il_generate_scaled_transparency_mask(
|
|||
uint32 *m = ((uint32*)maskp) + (x_offset >> 5);
|
||||
mask_bit = ~x_offset & 0x1f;
|
||||
|
||||
XP_ASSERT(mask_len);
|
||||
PR_ASSERT(mask_len);
|
||||
|
||||
/* Handle case in which we have a mask for a non-transparent
|
||||
image. This can happen when we have a LOSRC that is a transparent
|
||||
|
@ -535,8 +555,9 @@ il_reset_background_pixels(
|
|||
NI_PixmapHeader *img_header = &ic->image->header;
|
||||
int src_trans_pixel_index = ic->src_header->transparent_pixel->index;
|
||||
int img_trans_pixel_index = img_header->transparent_pixel->index;
|
||||
int dpy_trans_pixel_index =
|
||||
img_header->color_space->cmap.index[img_trans_pixel_index];
|
||||
int dpy_trans_pixel_index = img_header->color_space->cmap.index ?
|
||||
img_header->color_space->cmap.index[img_trans_pixel_index] :
|
||||
il_identity_index_map[img_trans_pixel_index];
|
||||
|
||||
/* Two cases */
|
||||
|
||||
|
@ -684,7 +705,7 @@ il_emit_row(
|
|||
int drow_start, drow_end, row_count, color_index, dup, do_dither;
|
||||
int dcolumn_start, dcolumn_end, column_count, offset, src_len, dest_len;
|
||||
|
||||
XP_ASSERT(row >= 0);
|
||||
PR_ASSERT(row >= 0);
|
||||
|
||||
if(row >= src_header->height) {
|
||||
ILTRACE(2,("il: ignoring extra row (%d)", row));
|
||||
|
@ -760,10 +781,15 @@ il_emit_row(
|
|||
|
||||
/* Bug, we retain the mask from a transparent
|
||||
LOSRC GIF when the SRC is a JPEG. */
|
||||
/* XP_ASSERT(cbuf); */
|
||||
/* PR_ASSERT(cbuf); */
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, mask,
|
||||
IL_LOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, mask,
|
||||
IL_LOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
#ifdef _USD
|
||||
maskp = (uint8 XP_HUGE *)mask->bits +
|
||||
|
@ -796,25 +822,39 @@ il_emit_row(
|
|||
}
|
||||
|
||||
}
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, mask,
|
||||
IL_UNLOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, mask,
|
||||
IL_UNLOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
}
|
||||
|
||||
if (!ic->converter) {
|
||||
|
||||
#ifndef M12N /* XXXM12N fixme */
|
||||
#ifdef M12N
|
||||
int i;
|
||||
int src_trans_pixel_index;
|
||||
uint8 XP_HUGE * dest;
|
||||
uint8 *indirect_map = ic->cs->current_indirect_map;/* XXXM12N fixme */
|
||||
uint8 *indirect_map = src_color_space->cmap.index;
|
||||
|
||||
if (indirect_map == NULL) {
|
||||
indirect_map = il_identity_index_map;
|
||||
}
|
||||
|
||||
if ((draw_mode == ilErase) || !src_header->transparent_pixel)
|
||||
src_trans_pixel_index = -1; /* no transparency */
|
||||
else
|
||||
src_trans_pixel_index = src_header->transparent_pixel->index;
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, image,
|
||||
IL_LOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, image,
|
||||
IL_LOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/* No converter, image is already rendered in pseudocolor. */
|
||||
#ifdef _USD
|
||||
|
@ -839,8 +879,13 @@ il_emit_row(
|
|||
dest[i] = indirect_map[cbuf[i]];
|
||||
}
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, image,
|
||||
IL_UNLOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, image,
|
||||
IL_UNLOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
#endif /* M12N */
|
||||
|
||||
} else {
|
||||
|
@ -920,8 +965,13 @@ il_emit_row(
|
|||
il_scale_RGB_row(src, src_len, dest, dest_len);
|
||||
}
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, image,
|
||||
IL_LOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, image,
|
||||
IL_LOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
#ifdef _USD
|
||||
out = (uint8 XP_HUGE *)image->bits +
|
||||
|
@ -947,8 +997,13 @@ il_emit_row(
|
|||
(*ic->converter)(ic, byte_mask, srcbuf, dcolumn_start,
|
||||
column_count, out);
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
img_cx->img_cb->ControlPixmapBits(img_cx->dpy_cx, image,
|
||||
IL_UNLOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(img_cx->img_cb, img_cx->dpy_cx, image,
|
||||
IL_UNLOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
/*
|
||||
* Have to reset transparent pixels to background color
|
|
@ -18,13 +18,10 @@
|
|||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* xbm.c --- Decoding of X bit-map format images
|
||||
* $Id: xbm.c,v 3.1 1998/03/28 03:35:04 ltabb Exp $
|
||||
* $Id: xbm.cpp,v 3.1 1998/07/27 16:09:52 hardts%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#include "xp.h"
|
||||
*/
|
||||
|
||||
#include "if.h"
|
||||
|
||||
|
@ -34,7 +31,9 @@
|
|||
|
||||
#include "il.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
PR_END_EXTERN_C
|
||||
|
||||
typedef enum {
|
||||
xbm_gather,
|
||||
|
@ -103,7 +102,7 @@ int il_xbm_init(il_container *ic)
|
|||
if (!hex_table_initialized)
|
||||
il_init_hex_table();
|
||||
|
||||
xs = XP_NEW_ZAP (xbm_struct);
|
||||
xs = PR_NEWZAP (xbm_struct);
|
||||
if (xs)
|
||||
{
|
||||
xs->state = xbm_init;
|
||||
|
@ -128,7 +127,7 @@ il_xbm_init_transparency(il_container *ic)
|
|||
IL_IRGB *img_trans_pixel;
|
||||
|
||||
if (!src_trans_pixel) {
|
||||
src_trans_pixel = XP_NEW_ZAP(IL_IRGB);
|
||||
src_trans_pixel = PR_NEWZAP(IL_IRGB);
|
||||
if (!src_trans_pixel)
|
||||
return FALSE;
|
||||
ic->src_header->transparent_pixel = src_trans_pixel;
|
||||
|
@ -160,7 +159,7 @@ il_xbm_init_transparency(il_container *ic)
|
|||
static void
|
||||
ConvertDefault(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
|
||||
*xs->p = val;
|
||||
xs->p++;
|
||||
|
@ -170,7 +169,7 @@ static void
|
|||
ConvertBWToRGB8(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
unsigned int bit_mask;
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
uint8 *ptr = (uint8 *)xs->p;
|
||||
|
||||
for (bit_mask = 128; bit_mask >= last_bit_mask; bit_mask >>= 1) {
|
||||
|
@ -187,7 +186,7 @@ static void
|
|||
ConvertBWToRGB16(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
unsigned int bit_mask;
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
uint16 *ptr = (uint16 *)xs->p;
|
||||
|
||||
for (bit_mask = 128; bit_mask >= last_bit_mask; bit_mask >>= 1) {
|
||||
|
@ -204,7 +203,7 @@ static void
|
|||
ConvertBWToRGB24(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
unsigned int bit_mask;
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
uint8 *ptr = (uint8 *)xs->p;
|
||||
|
||||
for (bit_mask = 128; bit_mask >= last_bit_mask; bit_mask >>= 1) {
|
||||
|
@ -226,7 +225,7 @@ static void
|
|||
ConvertBWToRGB32(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
unsigned int bit_mask;
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
uint32 *ptr = (uint32 *)xs->p;
|
||||
|
||||
for (bit_mask = 128; bit_mask >= last_bit_mask; bit_mask >>= 1) {
|
||||
|
@ -243,7 +242,7 @@ static void
|
|||
ConvertBWToCI(void *ds, unsigned char val, unsigned int last_bit_mask)
|
||||
{
|
||||
unsigned int bit_mask;
|
||||
xbm_struct *xs = ds;
|
||||
xbm_struct *xs = (xbm_struct *)ds;
|
||||
uint8 *ptr = (uint8 *)xs->p;
|
||||
uint8 bg_pixel = xs->bg_pixel;
|
||||
uint8 fg_pixel = xs->fg_pixel;
|
||||
|
@ -277,7 +276,7 @@ il_xbm_setup_color_space_converter(il_container *ic)
|
|||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -301,7 +300,7 @@ il_xbm_setup_color_space_converter(il_container *ic)
|
|||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -311,7 +310,7 @@ il_xbm_setup_color_space_converter(il_container *ic)
|
|||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -340,10 +339,10 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
|
||||
/* If this assert fires, chances are the netlib screwed up and
|
||||
continued to send data after the image stream was closed. */
|
||||
XP_ASSERT(xs);
|
||||
PR_ASSERT(xs);
|
||||
if (!xs) {
|
||||
#ifdef DEBUG
|
||||
XP_TRACE(("Netlib just took a shit on the imagelib\n"));
|
||||
ILTRACE(1,("Netlib just took a shit on the imagelib\n"));
|
||||
#endif
|
||||
return MK_IMAGE_LOSSAGE;
|
||||
}
|
||||
|
@ -380,12 +379,19 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
colorspace converters to be modelled along the
|
||||
lines of (and hence bundled with) the per-scanline
|
||||
colorspace converters in the core image library. */
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
ic->img_cx->img_cb->ControlPixmapBits(ic->img_cx->dpy_cx,
|
||||
ic->image, IL_LOCK_BITS);
|
||||
ic->img_cx->img_cb->ControlPixmapBits(ic->img_cx->dpy_cx,
|
||||
ic->mask, IL_LOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(ic->img_cx->img_cb,
|
||||
ic->img_cx->dpy_cx,
|
||||
ic->image, IL_LOCK_BITS);
|
||||
IMGCBIF_ControlPixmapBits(ic->img_cx->img_cb,
|
||||
ic->img_cx->dpy_cx,
|
||||
ic->mask, IL_LOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
#ifdef _USD
|
||||
xs->p = (unsigned char *)image->bits +
|
||||
|
@ -413,12 +419,19 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
if (num_pixels <= 8) {
|
||||
xs->converter((void*)xs, val, 1<<(8-num_pixels));
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
ic->img_cx->img_cb->ControlPixmapBits(ic->img_cx->dpy_cx,
|
||||
ic->image, IL_UNLOCK_BITS);
|
||||
ic->img_cx->img_cb->ControlPixmapBits(ic->img_cx->dpy_cx,
|
||||
ic->mask, IL_UNLOCK_BITS);
|
||||
#else
|
||||
IMGCBIF_ControlPixmapBits(ic->img_cx->img_cb,
|
||||
ic->img_cx->dpy_cx,
|
||||
ic->image, IL_UNLOCK_BITS);
|
||||
IMGCBIF_ControlPixmapBits(ic->img_cx->img_cb,
|
||||
ic->img_cx->dpy_cx,
|
||||
ic->mask, IL_UNLOCK_BITS);
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
xs->xpos=0;
|
||||
xs->ypos++;
|
||||
|
@ -491,8 +504,9 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
if (img_header->color_space->type == NI_PseudoColor) {
|
||||
xs->bg_pixel =
|
||||
img_header->transparent_pixel->index;
|
||||
xs->fg_pixel =
|
||||
img_header->color_space->cmap.index[0];
|
||||
xs->fg_pixel = img_header->color_space->cmap.index ?
|
||||
img_header->color_space->cmap.index[0] :
|
||||
il_identity_index_map[0];
|
||||
}
|
||||
|
||||
if (ic->mask) {
|
||||
|
@ -500,7 +514,7 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
mask_header = &mask->header;
|
||||
}
|
||||
|
||||
if((map = (IL_RGB*)XP_CALLOC(2, sizeof(IL_RGB)))!=0)
|
||||
if((map = (IL_RGB*)PR_Calloc(2, sizeof(IL_RGB)))!=0)
|
||||
{
|
||||
src_header->color_space->cmap.map = map;
|
||||
map++; /* first index is black */
|
||||
|
@ -622,7 +636,7 @@ int il_xbm_write(il_container *ic, const unsigned char *buf, int32 len)
|
|||
|
||||
default:
|
||||
ILTRACE(0,("il:xbm: unknown state %d", xs->state));
|
||||
XP_ASSERT(0);
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -635,7 +649,7 @@ il_xbm_abort(il_container *ic)
|
|||
if (ic->ds)
|
||||
{
|
||||
xbm_struct *xs = (xbm_struct*) ic->ds;
|
||||
XP_FREE(xs);
|
||||
PR_FREEIF(xs);
|
||||
ic->ds = 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,776 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The purpose of this file is to help phase out XP_ library
|
||||
* from the image library. In general, XP_ data structures and
|
||||
* functions will be replaced with the PR_ or PL_ equivalents.
|
||||
* In cases where the PR_ or PL_ equivalents don't yet exist,
|
||||
* this file (and its header equivalent) will play the role
|
||||
* of the XP_ library.
|
||||
*/
|
||||
#include "xpcompat.h"
|
||||
#include <stdlib.h>
|
||||
/* BSDI did not have this header and we do not need it here. -slamm */
|
||||
/* #include <search.h> */
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "ilISystemServices.h"
|
||||
|
||||
extern ilISystemServices *il_ss;
|
||||
|
||||
#if 0
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <limits.h>
|
||||
#endif /* XP_PC */
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
int MK_UNABLE_TO_LOCATE_FILE = -1;
|
||||
int MK_OUT_OF_MEMORY = -2;
|
||||
|
||||
int XP_MSG_IMAGE_PIXELS = -7;
|
||||
int XP_MSG_IMAGE_NOT_FOUND = -8;
|
||||
int XP_MSG_XBIT_COLOR = -9;
|
||||
int XP_MSG_1BIT_MONO = -10;
|
||||
int XP_MSG_XBIT_GREYSCALE = -11;
|
||||
int XP_MSG_XBIT_RGB = -12;
|
||||
int XP_MSG_DECODED_SIZE = -13;
|
||||
int XP_MSG_WIDTH_HEIGHT = -14;
|
||||
int XP_MSG_SCALED_FROM = -15;
|
||||
int XP_MSG_IMAGE_DIM = -16;
|
||||
int XP_MSG_COLOR = -17;
|
||||
int XP_MSG_NB_COLORS = -18;
|
||||
int XP_MSG_NONE = -19;
|
||||
int XP_MSG_COLORMAP = -20;
|
||||
int XP_MSG_BCKDRP_VISIBLE = -21;
|
||||
int XP_MSG_SOLID_BKGND = -22;
|
||||
int XP_MSG_JUST_NO = -23;
|
||||
int XP_MSG_TRANSPARENCY = -24;
|
||||
int XP_MSG_COMMENT = -25;
|
||||
int XP_MSG_UNKNOWN = -26;
|
||||
int XP_MSG_COMPRESS_REMOVE = -27;
|
||||
PR_END_EXTERN_C
|
||||
|
||||
char *XP_GetString(int i)
|
||||
{
|
||||
return ("XP_GetString replacement needed");
|
||||
}
|
||||
|
||||
/* We need this because Solaris' version of qsort is broken and
|
||||
* causes array bounds reads.
|
||||
*/
|
||||
#if defined(SOLARIS) || defined(XP_MAC)
|
||||
|
||||
|
||||
/* prototypes for local routines */
|
||||
static void shortsort(char *lo, char *hi, unsigned width,
|
||||
int ( *comp)(const void *, const void *));
|
||||
static void swap(char *p, char *q, unsigned int width);
|
||||
|
||||
/* this parameter defines the cutoff between using quick sort and
|
||||
insertion sort for arrays; arrays with lengths shorter or equal to the
|
||||
below value use insertion sort */
|
||||
|
||||
#define CUTOFF 8 /* testing shows that this is good value */
|
||||
|
||||
|
||||
/***
|
||||
*XP_QSORT(base, num, wid, comp) - quicksort function for sorting arrays
|
||||
*
|
||||
*Purpose:
|
||||
* quicksort the array of elements
|
||||
* side effects: sorts in place
|
||||
*
|
||||
*Entry:
|
||||
* char *base = pointer to base of array
|
||||
* unsigned num = number of elements in the array
|
||||
* unsigned width = width in bytes of each array element
|
||||
* int (*comp)() = pointer to function returning analog of strcmp for
|
||||
* strings, but supplied by user for comparing the array elements.
|
||||
* it accepts 2 pointers to elements and returns neg if 1<2, 0 if
|
||||
* 1=2, pos if 1>2.
|
||||
*
|
||||
*Exit:
|
||||
* returns void
|
||||
*
|
||||
*Exceptions:
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
/* sort the array between lo and hi (inclusive) */
|
||||
|
||||
void XP_QSORT (
|
||||
void *base,
|
||||
unsigned num,
|
||||
unsigned width,
|
||||
int ( *comp)(const void *, const void *)
|
||||
)
|
||||
{
|
||||
char *lo, *hi; /* ends of sub-array currently sorting */
|
||||
char *mid; /* points to middle of subarray */
|
||||
char *loguy, *higuy; /* traveling pointers for partition step */
|
||||
unsigned size; /* size of the sub-array */
|
||||
char *lostk[30], *histk[30];
|
||||
int stkptr; /* stack for saving sub-array to be processed */
|
||||
|
||||
/* Note: the number of stack entries required is no more than
|
||||
1 + log2(size), so 30 is sufficient for any array */
|
||||
|
||||
if (num < 2 || width == 0)
|
||||
return; /* nothing to do */
|
||||
|
||||
stkptr = 0; /* initialize stack */
|
||||
|
||||
lo = (char*)base;
|
||||
hi = (char *)base + width * (num-1); /* initialize limits */
|
||||
|
||||
/* this entry point is for pseudo-recursion calling: setting
|
||||
lo and hi and jumping to here is like recursion, but stkptr is
|
||||
prserved, locals aren't, so we preserve stuff on the stack */
|
||||
recurse:
|
||||
|
||||
size = (hi - lo) / width + 1; /* number of el's to sort */
|
||||
|
||||
/* below a certain size, it is faster to use a O(n^2) sorting method */
|
||||
if (size <= CUTOFF) {
|
||||
shortsort(lo, hi, width, comp);
|
||||
}
|
||||
else {
|
||||
/* First we pick a partititioning element. The efficiency of the
|
||||
algorithm demands that we find one that is approximately the
|
||||
median of the values, but also that we select one fast. Using
|
||||
the first one produces bad performace if the array is already
|
||||
sorted, so we use the middle one, which would require a very
|
||||
wierdly arranged array for worst case performance. Testing shows
|
||||
that a median-of-three algorithm does not, in general, increase
|
||||
performance. */
|
||||
|
||||
mid = lo + (size / 2) * width; /* find middle element */
|
||||
swap(mid, lo, width); /* swap it to beginning of array */
|
||||
|
||||
/* We now wish to partition the array into three pieces, one
|
||||
consisiting of elements <= partition element, one of elements
|
||||
equal to the parition element, and one of element >= to it. This
|
||||
is done below; comments indicate conditions established at every
|
||||
step. */
|
||||
|
||||
loguy = lo;
|
||||
higuy = hi + width;
|
||||
|
||||
/* Note that higuy decreases and loguy increases on every iteration,
|
||||
so loop must terminate. */
|
||||
for (;;) {
|
||||
/* lo <= loguy < hi, lo < higuy <= hi + 1,
|
||||
A[i] <= A[lo] for lo <= i <= loguy,
|
||||
A[i] >= A[lo] for higuy <= i <= hi */
|
||||
|
||||
do {
|
||||
loguy += width;
|
||||
} while (loguy <= hi && comp(loguy, lo) <= 0);
|
||||
|
||||
/* lo < loguy <= hi+1, A[i] <= A[lo] for lo <= i < loguy,
|
||||
either loguy > hi or A[loguy] > A[lo] */
|
||||
|
||||
do {
|
||||
higuy -= width;
|
||||
} while (higuy > lo && comp(higuy, lo) >= 0);
|
||||
|
||||
/* lo-1 <= higuy <= hi, A[i] >= A[lo] for higuy < i <= hi,
|
||||
either higuy <= lo or A[higuy] < A[lo] */
|
||||
|
||||
if (higuy < loguy)
|
||||
break;
|
||||
|
||||
/* if loguy > hi or higuy <= lo, then we would have exited, so
|
||||
A[loguy] > A[lo], A[higuy] < A[lo],
|
||||
loguy < hi, highy > lo */
|
||||
|
||||
swap(loguy, higuy, width);
|
||||
|
||||
/* A[loguy] < A[lo], A[higuy] > A[lo]; so condition at top
|
||||
of loop is re-established */
|
||||
}
|
||||
|
||||
/* A[i] >= A[lo] for higuy < i <= hi,
|
||||
A[i] <= A[lo] for lo <= i < loguy,
|
||||
higuy < loguy, lo <= higuy <= hi
|
||||
implying:
|
||||
A[i] >= A[lo] for loguy <= i <= hi,
|
||||
A[i] <= A[lo] for lo <= i <= higuy,
|
||||
A[i] = A[lo] for higuy < i < loguy */
|
||||
|
||||
swap(lo, higuy, width); /* put partition element in place */
|
||||
|
||||
/* OK, now we have the following:
|
||||
A[i] >= A[higuy] for loguy <= i <= hi,
|
||||
A[i] <= A[higuy] for lo <= i < higuy
|
||||
A[i] = A[lo] for higuy <= i < loguy */
|
||||
|
||||
/* We've finished the partition, now we want to sort the subarrays
|
||||
[lo, higuy-1] and [loguy, hi].
|
||||
We do the smaller one first to minimize stack usage.
|
||||
We only sort arrays of length 2 or more.*/
|
||||
|
||||
if ( higuy - 1 - lo >= hi - loguy ) {
|
||||
if (lo + width < higuy) {
|
||||
lostk[stkptr] = lo;
|
||||
histk[stkptr] = higuy - width;
|
||||
++stkptr;
|
||||
} /* save big recursion for later */
|
||||
|
||||
if (loguy < hi) {
|
||||
lo = loguy;
|
||||
goto recurse; /* do small recursion */
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (loguy < hi) {
|
||||
lostk[stkptr] = loguy;
|
||||
histk[stkptr] = hi;
|
||||
++stkptr; /* save big recursion for later */
|
||||
}
|
||||
|
||||
if (lo + width < higuy) {
|
||||
hi = higuy - width;
|
||||
goto recurse; /* do small recursion */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We have sorted the array, except for any pending sorts on the stack.
|
||||
Check if there are any, and do them. */
|
||||
|
||||
--stkptr;
|
||||
if (stkptr >= 0) {
|
||||
lo = lostk[stkptr];
|
||||
hi = histk[stkptr];
|
||||
goto recurse; /* pop subarray from stack */
|
||||
}
|
||||
else
|
||||
return; /* all subarrays done */
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*shortsort(hi, lo, width, comp) - insertion sort for sorting short arrays
|
||||
*
|
||||
*Purpose:
|
||||
* sorts the sub-array of elements between lo and hi (inclusive)
|
||||
* side effects: sorts in place
|
||||
* assumes that lo < hi
|
||||
*
|
||||
*Entry:
|
||||
* char *lo = pointer to low element to sort
|
||||
* char *hi = pointer to high element to sort
|
||||
* unsigned width = width in bytes of each array element
|
||||
* int (*comp)() = pointer to function returning analog of strcmp for
|
||||
* strings, but supplied by user for comparing the array elements.
|
||||
* it accepts 2 pointers to elements and returns neg if 1<2, 0 if
|
||||
* 1=2, pos if 1>2.
|
||||
*
|
||||
*Exit:
|
||||
* returns void
|
||||
*
|
||||
*Exceptions:
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
static void shortsort (
|
||||
char *lo,
|
||||
char *hi,
|
||||
unsigned width,
|
||||
int ( *comp)(const void *, const void *)
|
||||
)
|
||||
{
|
||||
char *p, *max;
|
||||
|
||||
/* Note: in assertions below, i and j are alway inside original bound of
|
||||
array to sort. */
|
||||
|
||||
while (hi > lo) {
|
||||
/* A[i] <= A[j] for i <= j, j > hi */
|
||||
max = lo;
|
||||
for (p = lo+width; p <= hi; p += width) {
|
||||
/* A[i] <= A[max] for lo <= i < p */
|
||||
if (comp(p, max) > 0) {
|
||||
max = p;
|
||||
}
|
||||
/* A[i] <= A[max] for lo <= i <= p */
|
||||
}
|
||||
|
||||
/* A[i] <= A[max] for lo <= i <= hi */
|
||||
|
||||
swap(max, hi, width);
|
||||
|
||||
/* A[i] <= A[hi] for i <= hi, so A[i] <= A[j] for i <= j, j >= hi */
|
||||
|
||||
hi -= width;
|
||||
|
||||
/* A[i] <= A[j] for i <= j, j > hi, loop top condition established */
|
||||
}
|
||||
/* A[i] <= A[j] for i <= j, j > lo, which implies A[i] <= A[j] for i < j,
|
||||
so array is sorted */
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*swap(a, b, width) - swap two elements
|
||||
*
|
||||
*Purpose:
|
||||
* swaps the two array elements of size width
|
||||
*
|
||||
*Entry:
|
||||
* char *a, *b = pointer to two elements to swap
|
||||
* unsigned width = width in bytes of each array element
|
||||
*
|
||||
*Exit:
|
||||
* returns void
|
||||
*
|
||||
*Exceptions:
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
static void swap (
|
||||
char *a,
|
||||
char *b,
|
||||
unsigned width
|
||||
)
|
||||
{
|
||||
char tmp;
|
||||
|
||||
if ( a != b )
|
||||
/* Do the swap one character at a time to avoid potential alignment
|
||||
problems. */
|
||||
while ( width-- ) {
|
||||
tmp = *a;
|
||||
*a++ = *b;
|
||||
*b++ = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SOLARIS or XP_MAC */
|
||||
|
||||
|
||||
/* Allocate a new copy of a block of binary data, and returns it
|
||||
*/
|
||||
char *
|
||||
NET_BACopy (char **destination, const char *source, size_t length)
|
||||
{
|
||||
if(*destination)
|
||||
{
|
||||
PR_FREEIF(*destination);
|
||||
*destination = 0;
|
||||
}
|
||||
|
||||
if (! source)
|
||||
{
|
||||
*destination = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*destination = (char *) PR_MALLOC (length);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
XP_MEMCPY(*destination, source, length);
|
||||
}
|
||||
return *destination;
|
||||
}
|
||||
|
||||
/* binary block Allocate and Concatenate
|
||||
*
|
||||
* destination_length is the length of the existing block
|
||||
* source_length is the length of the block being added to the
|
||||
* destination block
|
||||
*/
|
||||
char *
|
||||
NET_BACat (char **destination,
|
||||
size_t destination_length,
|
||||
const char *source,
|
||||
size_t source_length)
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (*destination)
|
||||
{
|
||||
*destination = (char *) PR_REALLOC (*destination, destination_length + source_length);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
|
||||
XP_MEMMOVE (*destination + destination_length, source, source_length);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
*destination = (char *) PR_MALLOC (source_length);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
|
||||
XP_MEMCPY(*destination, source, source_length);
|
||||
}
|
||||
}
|
||||
|
||||
return *destination;
|
||||
}
|
||||
|
||||
/* Very similar to strdup except it free's too
|
||||
*/
|
||||
char *
|
||||
NET_SACopy (char **destination, const char *source)
|
||||
{
|
||||
if(*destination)
|
||||
{
|
||||
PR_FREEIF(*destination);
|
||||
*destination = 0;
|
||||
}
|
||||
if (! source)
|
||||
{
|
||||
*destination = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*destination = (char *) PR_MALLOC (PL_strlen(source) + 1);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
|
||||
PL_strcpy (*destination, source);
|
||||
}
|
||||
return *destination;
|
||||
}
|
||||
|
||||
/* Again like strdup but it concatinates and free's and uses Realloc
|
||||
*/
|
||||
char *
|
||||
NET_SACat (char **destination, const char *source)
|
||||
{
|
||||
if (source && *source)
|
||||
{
|
||||
if (*destination)
|
||||
{
|
||||
int length = PL_strlen (*destination);
|
||||
*destination = (char *) PR_REALLOC (*destination, length + PL_strlen(source) + 1);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
|
||||
PL_strcpy (*destination + length, source);
|
||||
}
|
||||
else
|
||||
{
|
||||
*destination = (char *) PR_MALLOC (PL_strlen(source) + 1);
|
||||
if (*destination == NULL)
|
||||
return(NULL);
|
||||
|
||||
PL_strcpy (*destination, source);
|
||||
}
|
||||
}
|
||||
return *destination;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#include <windows.h>
|
||||
#include <limits.h>
|
||||
|
||||
static void wfe_ProcessTimeouts(DWORD dwNow);
|
||||
|
||||
// structure to keep track of FE_SetTimeOut objects
|
||||
typedef struct WinTimeStruct {
|
||||
TimeoutCallbackFunction fn;
|
||||
void * closure;
|
||||
DWORD dwFireTime;
|
||||
struct WinTimeStruct * pNext;
|
||||
} WinTime;
|
||||
|
||||
// the one and only list of objects waiting for FE_SetTimeOut
|
||||
WinTime *gTimeOutList = NULL;
|
||||
|
||||
// Process timeouts now.
|
||||
// Called once per round of fire.
|
||||
UINT uTimeoutTimer = 0;
|
||||
DWORD dwNextFire = (DWORD)-1;
|
||||
DWORD dwSyncHack = 0;
|
||||
|
||||
void CALLBACK FireTimeout(HWND hWnd, UINT uMessage, UINT uTimerID, DWORD dwTime)
|
||||
{
|
||||
static BOOL bCanEnter = TRUE;
|
||||
|
||||
// Don't allow old timer messages in here.
|
||||
if(uMessage != WM_TIMER) {
|
||||
PR_ASSERT(0);
|
||||
return;
|
||||
}
|
||||
if(uTimerID != uTimeoutTimer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Block only one entry into this function, or else.
|
||||
if(bCanEnter) {
|
||||
bCanEnter = FALSE;
|
||||
// see if we need to fork off any timeout functions
|
||||
if(gTimeOutList) {
|
||||
wfe_ProcessTimeouts(dwTime);
|
||||
}
|
||||
bCanEnter = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to correctly have the timer be set.
|
||||
void SyncTimeoutPeriod(DWORD dwTickCount)
|
||||
{
|
||||
// May want us to set tick count ourselves.
|
||||
if(dwTickCount == 0) {
|
||||
if(dwSyncHack == 0) {
|
||||
dwTickCount = GetTickCount();
|
||||
}
|
||||
else {
|
||||
dwTickCount = dwSyncHack;
|
||||
}
|
||||
}
|
||||
|
||||
// If there's no list, we should clear the timer.
|
||||
if(!gTimeOutList) {
|
||||
if(uTimeoutTimer) {
|
||||
::KillTimer(NULL, uTimeoutTimer);
|
||||
uTimeoutTimer = 0;
|
||||
dwNextFire = (DWORD)-1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// See if we need to clear the current timer.
|
||||
// Curcumstances are that if the timer will not
|
||||
// fire on time for the next timeout.
|
||||
BOOL bSetTimer = FALSE;
|
||||
WinTime *pTimeout = gTimeOutList;
|
||||
if(uTimeoutTimer) {
|
||||
if(pTimeout->dwFireTime != dwNextFire) {
|
||||
// There is no need to kill the timer if we are just going to set it again.
|
||||
// Windows will simply respect the new time interval passed in.
|
||||
::KillTimer(NULL, uTimeoutTimer);
|
||||
uTimeoutTimer = 0;
|
||||
dwNextFire = (DWORD)-1;
|
||||
|
||||
// Set the timer.
|
||||
bSetTimer = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No timer set, attempt.
|
||||
bSetTimer = TRUE;
|
||||
}
|
||||
|
||||
if(bSetTimer) {
|
||||
DWORD dwFireWhen = pTimeout->dwFireTime > dwTickCount ?
|
||||
pTimeout->dwFireTime - dwTickCount : 0;
|
||||
UINT uFireWhen = (UINT)dwFireWhen;
|
||||
|
||||
PR_ASSERT(uTimeoutTimer == 0);
|
||||
uTimeoutTimer = ::SetTimer(
|
||||
NULL,
|
||||
0,
|
||||
uFireWhen,
|
||||
(TIMERPROC)FireTimeout);
|
||||
|
||||
if(uTimeoutTimer) {
|
||||
// Set the fire time.
|
||||
dwNextFire = pTimeout->dwFireTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* this function should register a function that will
|
||||
* be called after the specified interval of time has
|
||||
* elapsed. This function should return an id
|
||||
* that can be passed to FE_ClearTimeout to cancel
|
||||
* the Timeout request.
|
||||
*
|
||||
* A) Timeouts never fail to trigger, and
|
||||
* B) Timeouts don't trigger *before* their nominal timestamp expires, and
|
||||
* C) Timeouts trigger in the same ordering as their timestamps
|
||||
*
|
||||
* After the function has been called it is unregistered
|
||||
* and will not be called again unless re-registered.
|
||||
*
|
||||
* func: The function to be invoked upon expiration of
|
||||
* the Timeout interval
|
||||
* closure: Data to be passed as the only argument to "func"
|
||||
* msecs: The number of milli-seconds in the interval
|
||||
*/
|
||||
void *
|
||||
FE_SetTimeout(TimeoutCallbackFunction func, void * closure, uint32 msecs)
|
||||
{
|
||||
WinTime * pTime = new WinTime;
|
||||
if(!pTime)
|
||||
return(NULL);
|
||||
|
||||
// fill it out
|
||||
DWORD dwNow = GetTickCount();
|
||||
pTime->fn = func;
|
||||
pTime->closure = closure;
|
||||
pTime->dwFireTime = (DWORD) msecs + dwNow;
|
||||
//CLM: Always clear this else the last timer added will have garbage!
|
||||
// (Win16 revealed this bug!)
|
||||
pTime->pNext = NULL;
|
||||
|
||||
// add it to the list
|
||||
if(!gTimeOutList) {
|
||||
// no list add it
|
||||
gTimeOutList = pTime;
|
||||
} else {
|
||||
|
||||
// is it before everything else on the list?
|
||||
if(pTime->dwFireTime < gTimeOutList->dwFireTime) {
|
||||
|
||||
pTime->pNext = gTimeOutList;
|
||||
gTimeOutList = pTime;
|
||||
|
||||
} else {
|
||||
|
||||
WinTime * pPrev = gTimeOutList;
|
||||
WinTime * pCurrent = gTimeOutList;
|
||||
|
||||
while(pCurrent && (pCurrent->dwFireTime <= pTime->dwFireTime)) {
|
||||
pPrev = pCurrent;
|
||||
pCurrent = pCurrent->pNext;
|
||||
}
|
||||
|
||||
PR_ASSERT(pPrev);
|
||||
|
||||
// insert it after pPrev (this could be at the end of the list)
|
||||
pTime->pNext = pPrev->pNext;
|
||||
pPrev->pNext = pTime;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Sync the timer fire period.
|
||||
SyncTimeoutPeriod(dwNow);
|
||||
|
||||
return(pTime);
|
||||
}
|
||||
|
||||
|
||||
/* This function cancels a Timeout that has previously been
|
||||
* set.
|
||||
* Callers should not pass in NULL or a timer_id that
|
||||
* has already expired.
|
||||
*/
|
||||
void
|
||||
FE_ClearTimeout(void * pStuff)
|
||||
{
|
||||
WinTime * pTimer = (WinTime *) pStuff;
|
||||
|
||||
if(!pTimer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(gTimeOutList == pTimer) {
|
||||
|
||||
// first element in the list lossage
|
||||
gTimeOutList = pTimer->pNext;
|
||||
|
||||
} else {
|
||||
|
||||
// walk until no next pointer
|
||||
for(WinTime * p = gTimeOutList; p && p->pNext && (p->pNext != pTimer); p = p->pNext)
|
||||
;
|
||||
|
||||
// if we found something valid pull it out of the list
|
||||
if(p && p->pNext && p->pNext == pTimer) {
|
||||
p->pNext = pTimer->pNext;
|
||||
|
||||
} else {
|
||||
// get out before we delete something that looks bogus
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if we got here it must have been a valid element so trash it
|
||||
delete pTimer;
|
||||
|
||||
// If there's now no be sure to clear the timer.
|
||||
SyncTimeoutPeriod(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Walk down the timeout list and launch anyone appropriate
|
||||
// Cleaned up logic 04-30-96 GAB
|
||||
//
|
||||
static void wfe_ProcessTimeouts(DWORD dwNow)
|
||||
{
|
||||
WinTime *p = gTimeOutList;
|
||||
if(dwNow == 0) {
|
||||
dwNow = GetTickCount();
|
||||
}
|
||||
|
||||
BOOL bCalledSync = FALSE;
|
||||
|
||||
// Set the hack, such that when FE_ClearTimeout
|
||||
// calls SyncTimeoutPeriod, that GetTickCount()
|
||||
// overhead is not incurred.
|
||||
dwSyncHack = dwNow;
|
||||
|
||||
// loop over all entries
|
||||
while(p) {
|
||||
// send it
|
||||
if(p->dwFireTime < dwNow) {
|
||||
// Fire it.
|
||||
(*p->fn) (p->closure);
|
||||
|
||||
// Clear the timer.
|
||||
// Period synced.
|
||||
FE_ClearTimeout(p);
|
||||
bCalledSync = TRUE;
|
||||
|
||||
// Reset the loop (can't look at p->pNext now, and called
|
||||
// code may have added/cleared timers).
|
||||
// (could do this by going recursive and returning).
|
||||
p = gTimeOutList;
|
||||
} else {
|
||||
// Make sure we fire an timer.
|
||||
// Also, we need to check to see if things are backing up (they
|
||||
// may be asking to be fired long before we ever get to them,
|
||||
// and we don't want to pass in negative values to the real
|
||||
// timer code, or it takes days to fire....
|
||||
if(bCalledSync == FALSE) {
|
||||
SyncTimeoutPeriod(dwNow);
|
||||
bCalledSync = TRUE;
|
||||
}
|
||||
// Get next timer.
|
||||
p = p->pNext;
|
||||
}
|
||||
}
|
||||
dwSyncHack = 0;
|
||||
}
|
||||
#else
|
||||
void *
|
||||
FE_SetTimeout(TimeoutCallbackFunction func, void * closure, uint32 msecs)
|
||||
{
|
||||
return il_ss->SetTimeout((ilTimeoutCallbackFunction)func,
|
||||
closure, msecs);
|
||||
}
|
||||
|
||||
void
|
||||
FE_ClearTimeout(void *timer_id)
|
||||
{
|
||||
il_ss->ClearTimeout(timer_id);
|
||||
}
|
||||
#endif /* XP_PC */
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The purpose of this file is to help phase out XP_ library
|
||||
* from the image library. In general, XP_ data structures and
|
||||
* functions will be replaced with the PR_ or PL_ equivalents.
|
||||
* In cases where the PR_ or PL_ equivalents don't yet exist,
|
||||
* this file (and its source equivalent) will play the role
|
||||
* of the XP_ library.
|
||||
*/
|
||||
|
||||
#ifndef xpcompat_h___
|
||||
#define xpcompat_h___
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
/*
|
||||
* This will probably go away after we stop using 16-bit compilers
|
||||
* for Win16.
|
||||
*/
|
||||
#ifdef XP_WIN16
|
||||
#define XP_HUGE __huge
|
||||
#define XP_HUGE_ALLOC(SIZE) halloc(SIZE,1)
|
||||
#define XP_HUGE_FREE(SIZE) hfree(SIZE)
|
||||
#define XP_HUGE_MEMCPY(DEST, SOURCE, LEN) hmemcpy(DEST, SOURCE, LEN)
|
||||
#else
|
||||
#define XP_HUGE
|
||||
#define XP_HUGE_ALLOC(SIZE) malloc(SIZE)
|
||||
#define XP_HUGE_FREE(SIZE) free(SIZE)
|
||||
#define XP_HUGE_MEMCPY(DEST, SOURCE, LEN) memcpy(DEST, SOURCE, LEN)
|
||||
#endif
|
||||
|
||||
#define XP_HUGE_CHAR_PTR char XP_HUGE *
|
||||
|
||||
/*
|
||||
* These will be replaced with their PL_ equivalents.
|
||||
*/
|
||||
#define XP_MEMCPY(d, s, n) memcpy((d), (s), (n))
|
||||
|
||||
/* NOTE: XP_MEMMOVE gurantees that overlaps will be properly handled */
|
||||
#if defined( __sun) && !defined(__svr4__)
|
||||
#define XP_MEMMOVE(Dest,Src,Len) bcopy((Src),(Dest),(Len))
|
||||
#else
|
||||
#define XP_MEMMOVE(Dest,Src,Len) memmove((Dest),(Src),(Len))
|
||||
#endif /* __sun */
|
||||
|
||||
#define XP_MEMSET memset
|
||||
#define XP_BZERO(a,b) memset(a,0,b)
|
||||
|
||||
/* NOTE: XP_BCOPY gurantees that overlaps will be properly handled */
|
||||
#ifdef XP_WIN16
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
extern void WIN16_bcopy(char *, char *, unsigned long);
|
||||
XP_END_PROTOS
|
||||
|
||||
#define XP_BCOPY(PTR_FROM, PTR_TO, LEN) \
|
||||
(WIN16_bcopy((char *) (PTR_FROM), (char *)(PTR_TO), (LEN)))
|
||||
|
||||
#else
|
||||
|
||||
#define XP_BCOPY(Src,Dest,Len) XP_MEMMOVE((Dest),(Src),(Len))
|
||||
|
||||
#endif /* XP_WIN16 */
|
||||
|
||||
#define XP_SPRINTF sprintf
|
||||
#define XP_SAFE_SPRINTF PR_snprintf
|
||||
#define XP_MEMCMP memcmp
|
||||
#define XP_VSPRINTF vsprintf
|
||||
|
||||
#ifdef XP_WIN
|
||||
#define XP_RANDOM rand
|
||||
#define XP_SRANDOM(seed) srand((seed))
|
||||
#endif
|
||||
#ifdef XP_OS2
|
||||
#define XP_RANDOM rand
|
||||
#define XP_SRANDOM(seed) srand((seed))
|
||||
#endif
|
||||
#ifdef XP_MAC
|
||||
#define XP_RANDOM rand
|
||||
#define XP_SRANDOM(seed) srand((seed))
|
||||
#endif
|
||||
#ifdef XP_UNIX
|
||||
#if !defined(XP_RANDOM) || !defined(XP_SRANDOM) /* defined in both xp_mcom.h and xp_str.h */
|
||||
#if defined(UNIXWARE) || defined(_INCLUDE_HPUX_SOURCE) || (defined(__sun) && defined(__svr4__)) || defined(SNI) || defined(NCR)
|
||||
#define XP_RANDOM rand
|
||||
#define XP_SRANDOM(seed) srand((seed))
|
||||
#else
|
||||
#define XP_RANDOM random
|
||||
#define XP_SRANDOM(seed) srandom((seed))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef void
|
||||
(*TimeoutCallbackFunction) (void * closure);
|
||||
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* XP_GetString is a mechanism for getting localized strings from a
|
||||
* resource file. It needs to be replaced with a PR_ equivalent.
|
||||
*/
|
||||
extern char *XP_GetString(int i);
|
||||
|
||||
/*
|
||||
* I don't know if qsort will ever be in NSPR, so this might have
|
||||
* to stay here indefinitely.
|
||||
*/
|
||||
#if defined(SOLARIS) || defined(XP_MAC)
|
||||
extern void XP_QSORT(void *, size_t, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
#elif defined(XP_OS2)
|
||||
#define XP_QSORT(base, nel, width, compar) qsort((base),(nel),(width),(int(_Optlink*)(const void*,const void*))(compar))
|
||||
#else
|
||||
#define XP_QSORT(base, nel, width, compar) qsort((base),(nel),(width),(compar))
|
||||
#endif
|
||||
|
||||
#define BlockAllocCopy(dest, src, src_length) NET_BACopy((char**)&(dest), src, src_length)
|
||||
#define BlockAllocCat(dest, dest_length, src, src_length) NET_BACat(&(dest), dest_length, src, src_length)
|
||||
extern char * NET_BACopy (char **dest, const char *src, size_t src_length);
|
||||
extern char * NET_BACat (char **dest, size_t dest_length, const char *src, size_t src_length);
|
||||
|
||||
/*
|
||||
* Malloc'd string manipulation
|
||||
*
|
||||
* notice that they are dereferenced by the define!
|
||||
*/
|
||||
#define StrAllocCopy(dest, src) NET_SACopy (&(dest), src)
|
||||
#define StrAllocCat(dest, src) NET_SACat (&(dest), src)
|
||||
extern char * NET_SACopy (char **dest, const char *src);
|
||||
extern char * NET_SACat (char **dest, const char *src);
|
||||
|
||||
extern void *
|
||||
FE_SetTimeout(TimeoutCallbackFunction func, void * closure, uint32 msecs);
|
||||
|
||||
extern void
|
||||
FE_ClearTimeout(void *timer_id);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif
|
|
@ -28,6 +28,7 @@ typedef int NS_Error;
|
|||
#endif
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prlog.h"
|
||||
|
||||
typedef struct OpaqueObserverList *XP_ObserverList;
|
||||
typedef void* XP_Observable;
|
||||
|
@ -42,7 +43,7 @@ typedef void (*XP_ObserverProc) (
|
|||
|
||||
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
Creates a new XP_ObserverList, with an assoicated XP_Observabe,
|
||||
|
@ -152,7 +153,7 @@ XP_IsObserverNotificationEnabled(
|
|||
XP_ObserverList inObserverList );
|
||||
|
||||
|
||||
XP_END_PROTOS
|
||||
PR_END_EXTERN_C
|
||||
|
||||
|
||||
#endif /* #ifdef _xp_observer_h_ */
|
||||
|
|
|
@ -29,3 +29,8 @@ LINCS=-I$(XPDIST)\public\nspr -I$(XPDIST)\public\util
|
|||
!endif
|
||||
|
||||
!include $(DEPTH)\config\rules.mak
|
||||
|
||||
!ifdef STANDALONE_IMAGE_LIB
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib\
|
||||
!endif
|
||||
|
|
|
@ -20,15 +20,18 @@
|
|||
#include "platform.h"
|
||||
#include "coremem.h"
|
||||
#else
|
||||
#include "xp_mem.h"
|
||||
#include "prmem.h"
|
||||
#endif
|
||||
|
||||
#include "xp_obs.h"
|
||||
#include "prclist.h"
|
||||
#include "xpassert.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#ifdef STANDALONE_IMAGE_LIB
|
||||
#define MK_OUT_OF_MEMORY -1
|
||||
#else
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
#endif /* STANDALONE_IMAGE_LIB */
|
||||
|
||||
typedef struct Observer
|
||||
{
|
||||
|
@ -63,8 +66,8 @@ XP_NewObserverList(
|
|||
{
|
||||
NS_Error result = 0;
|
||||
|
||||
XP_ASSERT(outObserverList != NULL);
|
||||
*outObserverList = XP_ALLOC(sizeof(struct OpaqueObserverList));
|
||||
PR_ASSERT(outObserverList != NULL);
|
||||
*outObserverList = PR_MALLOC(sizeof(struct OpaqueObserverList));
|
||||
|
||||
if (*outObserverList != NULL)
|
||||
{
|
||||
|
@ -90,7 +93,7 @@ XP_DisposeObserverList(
|
|||
{
|
||||
Observer *obs, *next = NULL;
|
||||
|
||||
XP_ASSERT(inObserverList != NULL);
|
||||
PR_ASSERT(inObserverList != NULL);
|
||||
for (obs = inObserverList->mObserverList; obs != NULL; )
|
||||
{
|
||||
|
||||
|
@ -101,12 +104,12 @@ XP_DisposeObserverList(
|
|||
|
||||
PR_REMOVE_LINK(ObserverLinks(obs));
|
||||
inObserverList->mObserverList = next;
|
||||
XP_FREE(obs);
|
||||
PR_FREEIF(obs);
|
||||
obs = inObserverList->mObserverList;
|
||||
}
|
||||
|
||||
|
||||
XP_FREE(inObserverList);
|
||||
PR_FREEIF(inObserverList);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -116,7 +119,7 @@ XP_Observable
|
|||
XP_GetObserverListObservable(
|
||||
XP_ObserverList inObserverList)
|
||||
{
|
||||
XP_ASSERT(inObserverList != NULL);
|
||||
PR_ASSERT(inObserverList != NULL);
|
||||
|
||||
return inObserverList->mObservable;
|
||||
}
|
||||
|
@ -127,7 +130,7 @@ XP_SetObserverListObservable(
|
|||
XP_ObserverList inObserverList,
|
||||
XP_Observable inObservable )
|
||||
{
|
||||
XP_ASSERT(inObserverList != NULL);
|
||||
PR_ASSERT(inObserverList != NULL);
|
||||
|
||||
inObserverList->mObservable = inObservable;
|
||||
}
|
||||
|
@ -148,12 +151,12 @@ XP_AddObserver(
|
|||
Observer* obs;
|
||||
NS_Error result = 0;
|
||||
|
||||
XP_ASSERT(inObserverList != NULL);
|
||||
PR_ASSERT(inObserverList != NULL);
|
||||
if (inObserverList == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
obs = XP_ALLOC(sizeof (Observer));
|
||||
obs = PR_MALLOC(sizeof (Observer));
|
||||
if (obs != NULL)
|
||||
{
|
||||
obs->mCallback = inObserver;
|
||||
|
@ -208,7 +211,7 @@ XP_RemoveObserver(
|
|||
inObserverList->mObserverList = (next != obs) ? next : NULL;
|
||||
}
|
||||
|
||||
XP_FREE(obs);
|
||||
PR_FREEIF(obs);
|
||||
result = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче