Bug 418104: Remove non-cairo Windows gfx code from the tree, removal of all obsolete files, r=alfredkayser, sr=pavlov, a=beltzner

This commit is contained in:
mozilla@weilbacher.org 2008-03-30 03:12:50 -07:00
Родитель a34213dedf
Коммит b57f450293
24 изменённых файлов: 0 добавлений и 16389 удалений

Просмотреть файл

@ -1,309 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Tomas Mšller.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tomas Mšller
* Tim Rowley <tor@cs.brown.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h>
#include <stdio.h>
#include "imgScaler.h"
// Scaling code from Graphics Gems book III
// http://www.acm.org/pubs/tog/GraphicsGems/gemsiii/fastBitmap.c
//
// License states - "All code here can be used without restrictions."
// http://www.acm.org/pubs/tog/GraphicsGems/
/*
Fast Bitmap Stretching
Tomas Mšller
*/
static void
Stretch32(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void
Stretch24(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void
Stretch8(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void
Stretch1(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
/**********************************************************
RectStretch enlarges or diminishes a source rectangle of a bitmap to
a destination rectangle. The source rectangle is selected by the two
points (xs1,ys1) and (xs2,ys2), and the destination rectangle by
(xd1,yd1) and (xd2,yd2). Since readability of source-code is wanted,
some optimizations have been left out for the reader: It's possible
to read one line at a time, by first stretching in x-direction and
then stretching that bitmap in y-direction.
Entry:
aSrcWidth, aSrcHeight - size of entire original image
aDstWidth, aDstHeight - size of entire scaled image
aStartColumn, aStartRow - upper corner of desired area (inclusive)
aEndColumn, aEndRow - bottom corner of desired area (inclusive)
unsigned char *aSrcImage, aSrcStride - start of original image data
unsigned char *aDstStride, aDstStride - start of desired area image data
unsigned aDepth - bit depth of image (24, 8, or 1)
**********************************************************/
NS_GFX_(void)
RectStretch(unsigned aSrcWidth, unsigned aSrcHeight,
unsigned aDstWidth, unsigned aDstHeight,
unsigned aStartColumn, unsigned aStartRow,
unsigned aEndColumn, unsigned aEndRow,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth)
{
int e;
unsigned dx, dy;
void (*Stretch)(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn,
unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
unsigned xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
xs1 = ys1 = xd1 = yd1 = 0;
xs2 = aSrcWidth - 1;
ys2 = aSrcHeight - 1;
xd2 = aDstWidth - 1;
yd2 = aDstHeight - 1;
// fprintf(stderr, "RS (%d %d)-(%d %d) (%d %d)-(%d %d) %d %d %d\n",
// xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2,
// aSrcStride, aDstStride, aDepth);
switch (aDepth) {
case 32:
Stretch = Stretch32;
break;
case 24:
Stretch = Stretch24;
break;
case 8:
Stretch = Stretch8;
break;
case 1:
Stretch = Stretch1;
break;
default:
return;
}
dx = yd2 - yd1;
dy = ys2 - ys1;
e = dy - dx;
dy += 1;
if (!dx)
dx = 1;
for (yd1 = 0; yd1 <= aEndRow; yd1++) {
if (yd1 >= aStartRow)
Stretch(xd1, xd2, xs1, xs2, ys1, yd1,
aStartRow, aStartColumn, aEndColumn,
aSrcImage, aSrcStride, aDstImage, aDstStride);
while (e >= 0) {
ys1++;
e -= dx;
}
e += dy;
}
}
/**********************************************************
Stretches a horizontal source line onto a horizontal destination
line. Used by RectStretch.
Entry:
x1,x2 - x-coordinates of the destination line
y1,y2 - x-coordinates of the source line
yr - y-coordinate of source line
yw - y-coordinate of destination line
**********************************************************/
static void
Stretch32(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
int e;
unsigned dx, dy, d;
unsigned char *src, *dst;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
src = aSrcImage + yr * aSrcStride + 4 * y1;
dst = aDstImage + (yw - aStartRow) * aDstStride;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if (d >= aStartColumn) {
*dst++ = src[0];
*dst++ = src[1];
*dst++ = src[2];
*dst++ = src[3];
}
while (e >= 0) {
src += 4;
e -= dx;
}
e += dy;
}
}
static void
Stretch24(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
int e;
unsigned dx, dy, d;
unsigned char *src, *dst;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
src = aSrcImage + yr * aSrcStride + 3 * y1;
dst = aDstImage + (yw - aStartRow) * aDstStride;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if (d >= aStartColumn) {
*dst++ = src[0];
*dst++ = src[1];
*dst++ = src[2];
}
while (e >= 0) {
src += 3;
e -= dx;
}
e += dy;
}
}
static void
Stretch8(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
int e;
unsigned dx, dy, d;
unsigned char *src, *dst;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
src = aSrcImage + yr * aSrcStride + y1;
dst = aDstImage + (yw - aStartRow) * aDstStride;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if (d >= aStartColumn) {
*dst = *src;
dst++;
}
while (e >= 0) {
src++;
e -= dx;
}
e += dy;
}
}
static void
Stretch1(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
int e;
unsigned dx, dy, d;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if ((d >= aStartColumn) &&
(*(aSrcImage + yr * aSrcStride + (y1 >> 3)) & 1 << (7 - y1 & 0x7)))
*(aDstImage +
(yw - aStartRow) * aDstStride +
((x1 - aStartColumn) >> 3))
|= 1 << (7 - x1 & 0x7);
while (e >= 0) {
y1++;
e -= dx;
}
x1++;
e += dy;
}
}

Просмотреть файл

@ -1,48 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Tomas Mšller.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tomas Mšller
* Tim Rowley <tor@cs.brown.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gfxCore.h"
NS_GFX_(void)
RectStretch(unsigned aSrcWidth, unsigned aSrcHeight,
unsigned aDstWidth, unsigned aDstHeight,
unsigned aStartColumn, unsigned aStartRow,
unsigned aEndColumn, unsigned aEndRowe,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth);

Просмотреть файл

@ -1,127 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfxwin
LIBRARY_NAME = gkgfxwin
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsGfxModule
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
REQUIRES = xpcom \
string \
gfx \
widget \
intl \
view \
pref \
uconv \
unicharutil \
locale \
necko \
content \
layout \
dom \
debug \
imglib2 \
windowwatcher \
$(NULL)
CPPSRCS = \
nsDeviceContextWin.cpp \
nsDrawingSurfaceWin.cpp \
nsRenderingContextWin.cpp \
nsFontMetricsWin.cpp \
nsImageWin.cpp \
nsRegionWin.cpp \
nsGfxFactoryWin.cpp \
nsUnicodeRange.cpp \
$(NULL)
EXPORTS = nsIRenderingContextWin.h nsIDrawingSurfaceWin.h
EXTRA_DSO_LIBS = gkgfx mozutil_s gfxshared_s
LOCAL_INCLUDES = \
-I$(srcdir)/. \
-I$(srcdir)/.. \
-I$(srcdir)/../shared \
$(NULL)
ifndef WINCE
_OS_LIBS = comdlg32
endif
OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_JS_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
libs:: fontEncoding.properties fontNameMap.properties
$(INSTALL) $^ $(DIST)/bin/res/fonts
install:: fontEncoding.properties fontNameMap.properties
$(INSTALL) $^ $(DESTDIR)$(mozappdir)/res/fonts
DEFINES += -DSTRICT
ifdef NGLAYOUT_DDRAW
DEFINES += DNGLAYOUT_DDRAW
ifeq ($(MOZ_VCVER),50)
LOCAL_INCLUDES += -I$(NGLAYOUT_DDRAW)/include
else
LOCAL_INCLUDES += -I$(NGLAYOUT_DDRAW)/inc
endif
EXTRA_DSO_LDOPTS += $(NGLAYOUT_DDRAW)/lib/ddraw.lib
OS_LIBS += ole32.lib
endif

Просмотреть файл

@ -1,221 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Jungshik Shin <jshin@mailaps.org>
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*========================================================
This file contains a precompiled CCMap for a class of Unicode
characters (blank_glyph) to be identified quickly by Mozilla.
It was generated by ccmapbin.pl which you can find under
mozilla/intl/unicharutil/tools.
Enumerated below are characters included in the precompiled CCMap
which is human-readable but not so human-friendly. If you
needs to modify the list of characters belonging to "blank_glyph",
you have to make a new file (with the name of your choice)
listing characters (one character per line) you want to put
into "blank_glyph" in the format
0xuuuu // comment
In addition, the input file can have the following optional lines that
read
VARIABLE::gCharsWithBlankGlyphCCMap
CLASS::blank_glyph
DESCRIPTION:: description of a character class
FILE:: mozilla source file to include the output file
Then, run the following in the current directory.
perl ccmapbin.pl input_file [gCharsWithBlankGlyphCCMap [blank_glyph]]
which will generate blank_glyph.ccmap (or blank_glyph.x-ccmap if the ccmap
includes non-BMP characters.). gCharsWithBlankGlyphCCMap is used as the prefix
in macros for the array initializer and the array size.
(see bug 180266, bug 167136, and bug 224337)
*/
/*
VARIABLE:: gCharsWithBlankGlyphCCMap
CLASS:: blank_glyph
DESCRIPTION:: Unicode characters for which blank glyphs are acceptable.
FILE:: nsFontMetricsWin.cpp
0X000020 : SPACE
0X0000A0 : NO-BREAK SPACE
0X00115F : HANGUL LEADING CONSONANT FILLER
0X001160 : HANGUL VOWEL FILLER
0X002000 : EN QUAD
0X002001 : EM QUAD
0X002002 : EN SPACE
0X002003 : EM SPACE
0X002004 : THREE-PER-EM SPACE
0X002005 : FOUR-PER-EM SPACE
0X002006 : SIX-PER-EM SPACE
0X002007 : FIGURE SPACE
0X002008 : PUNCTUATION SPACE
0X002009 : THIN SPACE
0X00200A : HAIR SPACE
0X00200B : ZERO WIDTH SPACE
0X00200C : ZERO WIDTH NON-JOINER
0X00200D : ZERO WIDTH JOINER
0X00200E : LEFT-TO-RIGHT MARK
0X00200F : RIGHT-TO-LEFT MARK
0X00202A : LEFT-TO-RIGHT EMBEDDING
0X00202B : RIGHT-TO-LEFT EMBEDDING
0X00202C : POP DIRECTIONAL FORMATTING
0X00202D : LEFT-TO-RIGHT OVERRIDE
0X00202E : RIGHT-TO-LEFT OVERRIDE
0X00202F : NARROW NO-BREAK SPACE
0X003000 : IDEOGRAPHIC SPACE
0X003164 : HANGUL COMPATIBILITY JAMO FILLER
0X00FEFF : BYTE ORDER MARK^L
0X00FFA0 : HALFWIDTH HANGUL FILLER
0X00FFF9 : INTERLINEAR ANNOTATION ANCHOR
0X00FFFA : INTERLINEAR ANNOTATION SEPARATOR
0X00FFFB : INTERLINEAR ANNOTATION TERMINATOR
*/
#if (defined(IS_LITTLE_ENDIAN) || ALU_SIZE == 16)
// Precompiled CCMap for Little Endian(16/32/64bit)
// and Big Endian(16bit)
#define gCharsWithBlankGlyphCCMap_SIZE 240
#define gCharsWithBlankGlyphCCMap_INITIALIZER \
/* 000000 */ 0x0030,0x0050,0x0070,0x0090,0x0010,0x0010,0x0010,0x0010, \
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00C0, \
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000020 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000030 */ 0x0040,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000040 */ 0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000050 */ 0x0020,0x0060,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000060 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,0x0001,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000070 */ 0x0080,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000080 */ 0xFFFF,0x0000,0xFC00,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000090 */ 0x00A0,0x00B0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 0000a0 */ 0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000b0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000c0 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x00D0,0x00E0, \
/* 0000d0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000, \
/* 0000e0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0E00,
#elif (ALU_SIZE == 32)
// Precompiled CCMap for Big Endian(32bit)
#define gCharsWithBlankGlyphCCMap_SIZE 240
#define gCharsWithBlankGlyphCCMap_INITIALIZER \
/* 000000 */ 0x0030,0x0050,0x0070,0x0090,0x0010,0x0010,0x0010,0x0010, \
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00C0, \
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000020 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000030 */ 0x0040,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000040 */ 0x0000,0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000, \
/* 000050 */ 0x0020,0x0060,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000060 */ 0x0000,0x0000,0x0000,0x0000,0x8000,0x0000,0x0000,0x0001, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000070 */ 0x0080,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000080 */ 0x0000,0xFFFF,0x0000,0xFC00,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000090 */ 0x00A0,0x00B0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 0000a0 */ 0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000b0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0010, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000c0 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x00D0,0x00E0, \
/* 0000d0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8000,0x0000, \
/* 0000e0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0001,0x0000,0x0000,0x0E00,0x0000,
#elif (ALU_SIZE == 64)
// Precompiled CCMap for Big Endian(64bit)
#define gCharsWithBlankGlyphCCMap_SIZE 240
#define gCharsWithBlankGlyphCCMap_INITIALIZER \
/* 000000 */ 0x0030,0x0050,0x0070,0x0090,0x0010,0x0010,0x0010,0x0010, \
0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x00C0, \
/* 000010 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000020 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000030 */ 0x0040,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000040 */ 0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000050 */ 0x0020,0x0060,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000060 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0001,0x8000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000070 */ 0x0080,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 000080 */ 0x0000,0xFC00,0x0000,0xFFFF,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 000090 */ 0x00A0,0x00B0,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
/* 0000a0 */ 0x0000,0x0000,0x0000,0x0001,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000b0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0010,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
/* 0000c0 */ 0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x0020, \
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020,0x00D0,0x00E0, \
/* 0000d0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0000,0x0000,0x0000,0x8000,0x0000,0x0000,0x0000, \
/* 0000e0 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, \
0x0000,0x0001,0x0000,0x0000,0x0E00,0x0000,0x0000,0x0000,
#else
#error "We don't support this architecture."
#endif

Просмотреть файл

@ -1,127 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla MathML Project.
#
# The Initial Developer of the Original Code is
# The University Of Queensland.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Roger B. Sidje <rbs@maths.uq.edu.au>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# LOCALIZATION NOTE: FILE
# Do not translate anything in this file
# This is a list of encodings used for special *symbolic fonts* (not documents) for
# which we have converters (i.e., the intl/uconv library contains encoding tables
# that provide a mapping of characters to the indices of the desired glyphshapes
# within these symbolic fonts).
#
# For each 'key = value' pair in this list:
#
# - the 'key' is a lower case ASCII with the *name of the font*, and the
# encoding type (e.g., .ttf for TrueType, and .t1 for Type 1). Note that
# the *name of a font* is not necessarily the *name of the file* that contains
# the font... All whitespace should be stripped from the name.
#
# - the 'value' is the case-sensitive charset string used when setting up the
# corresponding Unicode Converter in the intl/uconv library.
# Symbol font
encoding.symbol.ttf = Adobe-Symbol-Encoding
# TeX's Computer Modern fonts (Roman, Math Italic, Symbol and Extension)
encoding.cmr10.ttf = x-ttf-cmr
encoding.cmmi10.ttf = x-ttf-cmmi
encoding.cmsy10.ttf = x-ttf-cmsy
encoding.cmex10.ttf = x-ttf-cmex
# Mathematica fonts
encoding.math1.ttf = x-mathematica1
encoding.math1-bold.ttf = x-mathematica1
encoding.math1mono.ttf = x-mathematica1
encoding.math1mono-bold.ttf = x-mathematica1
encoding.math2.ttf = x-mathematica2
encoding.math2-bold.ttf = x-mathematica2
encoding.math2mono.ttf = x-mathematica2
encoding.math2mono-bold.ttf = x-mathematica2
encoding.math3.ttf = x-mathematica3
encoding.math3-bold.ttf = x-mathematica3
encoding.math3mono.ttf = x-mathematica3
encoding.math3mono-bold.ttf = x-mathematica3
encoding.math4.ttf = x-mathematica4
encoding.math4-bold.ttf = x-mathematica4
encoding.math4mono.ttf = x-mathematica4
encoding.math4mono-bold.ttf = x-mathematica4
encoding.math5.ttf = x-mathematica5
encoding.math5-bold.ttf = x-mathematica5
encoding.math5bold.ttf = x-mathematica5
encoding.math5mono.ttf = x-mathematica5
encoding.math5mono-bold.ttf = x-mathematica5
encoding.math5monobold.ttf = x-mathematica5
# MathType Extra
encoding.mtextra.ttf = x-mtextra
# The suffix '.wide' has to be added to encoding names to identify
# these fonts as 'wide' non-Unicode fonts.
# Korean Jamo TTFs
encoding.unbatang.ttf = x-koreanjamo-0.wide
# For the Korean locale, Korean family names have to be
# listed in UTF-8.
encoding.은바탕.ttf = x-koreanjamo-0.wide
# Tamil fonts (TSCII encoding : see http://www.tamil.net/tscii)
# See also http://bugzilla.mozilla.org/show_bug.cgi?id=204039.
# These fonts have pseudo-Unicode cmap with TSCII interpreted as Windows-1252.
# On Win2k/XP, you may wish to comment all these out because the native
# OS support of Tamil script is superior to Mozilla's internal support.
# On Win9x/ME, there's no native OS support of Tamil script so that
# you need these lines definitely.
encoding.tsc_paranarpdf.ttf = x-tamilttf-0.wide
encoding.tsc_paranbold.ttf = x-tamilttf-0.wide
encoding.tsc_paranarho.ttf = x-tamilttf-0.wide
encoding.tsc_kannadaasan.ttf = x-tamilttf-0.wide
encoding.tscu_comic.ttf = x-tamilttf-0.wide
encoding.tscu_times.ttf = x-tamilttf-0.wide
encoding.tscu_paranar.ttf = x-tamilttf-0.wide
encoding.tscu_paranarbold.ttf = x-tamilttf-0.wide
# These two fonts don't have Unicode cmap but have pseudo-Apple Roman cmap
# with TSCII assignment.
encoding.tsc_aandaal.ttf = x-tscii
encoding.tsc_aparanarpdf.ttf = x-tscii

Просмотреть файл

@ -1,123 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla MathML Project.
#
# The Initial Developer of the Original Code is
# The University Of Queensland.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jungshik Shin <jshin@i18nl10n.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# LOCALIZATION NOTE: FILE
# Do not translate anything in this file
# This is a font name mapping table for CJK fonts with CJK native names.
#
# For each font in the list, two key=value pairs have to be listed :
#
# - <asciiname>.<codepage>=<CJK native name>
# - <cjknativename>=<ASCII name>.<codepage>
#
# where
# - <CJK native name> and <ASCII name> are the ASCII name and
# the CJK native name of a font
# - <asciiname> and <cjknativename> are the ASCII name and
# the CJK native name of the font in lowercase with whitespace
# stripped.
# - <codepage> is the codepage in which the native name
# of the font is 'understood' (returned by Windows 'A' APIs )
# (Japanese : cp932, Simplified Chinese : cp936,
# Korean : cp949, Traditional Chinese : cp950)
#
# This list only includes the CJK *core* fonts shipped with MS Windows.
# If you have more CJK fonts with native names, you can add them.
# For additional font name mapping, see
# <http://www.trigeminal.com/samples/font_choices.html>
#
# Japanese fonts (cp932)
mspゴシック=MS PGothic.cp932
mspgothic.cp932= Pゴシック
msp明朝=MS PMincho.cp932
mspmincho.cp932= P明朝
msゴシック=MS Gothic.cp932
msgothic.cp932= ゴシック
ms明朝=MS Mincho.cp932
msmincho.cp932= 明朝
# Korean fonts (cp949)
바탕=Batang.cp949
batang.cp949=바탕
바탕체=Batangche.cp949
batangche.cp949=바탕체
굴림=Gulim.cp949
gulim.cp949=굴림
굴림체=Gulimche.cp949
gulimche.cp949=굴림체
돋움=Dotum.cp949
dotum.cp949=돋움
돋움체=Dotumche.cp949
dotumche.cp949=돋움체
궁서=Gungsuh.cp949
gungsuh.cp949=궁서
궁서체=Gungsuhche.cp949
gungsuhche.cp949=궁서체
# Simplified Chinese fonts (cp936)
宋体=SimSun.cp936
simsun.cp936=宋体
黑体=SimHei.cp936
simhei.cp936=黑体
新宋体=NSimSun.cp936
nsimsun.cp936=新宋体
# Traditional Chinese fonts (cp950)
新細明體=PMingLiu.cp950
pmingliu.cp950=新細明體
細明體=MingLiu.cp950
mingliu.cp950=細明體

Просмотреть файл

@ -1,7 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif
dist/bin/res/fonts/fontEncoding.properties

Просмотреть файл

@ -1,886 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextWin.h"
#include "nsRenderingContextWin.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsGfxCIID.h"
#include "nsReadableUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsString.h"
#if defined(DEBUG_rods) && defined(MOZ_LAYOUTDEBUG)
#include "nsIDebugObject.h"
#endif
#define DOC_TITLE_LENGTH 64
#include "prlog.h"
#ifdef PR_LOGGING
PRLogModuleInfo * kGfxPrintingLogMod = PR_NewLogModule("printing-gfx");
#define PR_PL(_p1) PR_LOG(kGfxPrintingLogMod, PR_LOG_DEBUG, _p1)
#else
#define PR_PL(_p1)
#endif
nsDeviceContextWin :: nsDeviceContextWin()
: DeviceContextImpl()
{
mSurface = NULL;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mDC = NULL;
mPixelScale = 1.0f;
mWidth = -1;
mHeight = -1;
mSpec = nsnull;
mCachedClientRect = PR_FALSE;
mCachedFullRect = PR_FALSE;
}
nsDeviceContextWin :: ~nsDeviceContextWin()
{
nsDrawingSurfaceWin *surf = (nsDrawingSurfaceWin *)mSurface;
NS_IF_RELEASE(surf); //this clears the surf pointer...
mSurface = nsnull;
if (NULL != mPaletteInfo.palette)
::DeleteObject((HPALETTE)mPaletteInfo.palette);
if (NULL != mDC)
{
::DeleteDC(mDC);
mDC = NULL;
}
NS_IF_RELEASE(mSpec);
}
NS_IMETHODIMP nsDeviceContextWin :: Init(nsNativeWidget aWidget)
{
mWidget = aWidget;
HWND hwnd = (HWND)aWidget;
HDC hdc = ::GetDC(hwnd);
CommonInit(hdc);
::ReleaseDC(hwnd, hdc);
return NS_OK;
}
//local method...
nsresult nsDeviceContextWin :: Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext)
{
float origscale, newscale;
float t2d, a2d;
mDC = (HDC)aContext;
CommonInit(mDC);
newscale = TwipsToDevUnits();
origscale = aOrigContext->TwipsToDevUnits();
mPixelScale = newscale / origscale;
t2d = aOrigContext->TwipsToDevUnits();
a2d = aOrigContext->AppUnitsToDevUnits();
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
return NS_OK;
}
void nsDeviceContextWin :: CommonInit(HDC aDC)
{
int rasterCaps = ::GetDeviceCaps(aDC, RASTERCAPS);
mDepth = (PRUint32)::GetDeviceCaps(aDC, BITSPIXEL);
mPaletteInfo.isPaletteDevice = RC_PALETTE == (rasterCaps & RC_PALETTE);
mPaletteInfo.sizePalette = (PRUint16)::GetDeviceCaps(aDC, SIZEPALETTE);
mPaletteInfo.numReserved = (PRUint16)::GetDeviceCaps(aDC, NUMRESERVED);
mWidth = ::GetDeviceCaps(aDC, HORZRES);
mHeight = ::GetDeviceCaps(aDC, VERTRES);
mPixelsToTwips = (float)NSIntPointsToTwips(72) / ((float)::GetDeviceCaps(aDC, LOGPIXELSY));
if (::GetDeviceCaps(aDC, TECHNOLOGY) == DT_RASDISPLAY)
{
// Ensure that, for screens, pixels-to-twips is an integer
mPixelsToTwips = NSToIntRound(mPixelsToTwips);
// init the screen manager and compute our client rect based on the
// screen objects. We'll save the result
nsresult ignore;
mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore);
} // if this dc is not a print device
mTwipsToPixels = 1.0 / mPixelsToTwips;
DeviceContextImpl::CommonInit();
}
void
nsDeviceContextWin :: ComputeClientRectUsingScreen ( nsRect* outRect )
{
// we always need to recompute the clientRect
// because the window may have moved onto a different screen. In the single
// monitor case, we only need to do the computation if we haven't done it
// once already, and remember that we have because we're assured it won't change.
nsCOMPtr<nsIScreen> screen;
FindScreen ( getter_AddRefs(screen) );
if ( screen ) {
PRInt32 x, y, width, height;
screen->GetAvailRect ( &x, &y, &width, &height );
// convert to device units
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
mCachedClientRect = PR_TRUE;
mClientRect = *outRect;
}
} // ComputeClientRectUsingScreen
void
nsDeviceContextWin :: ComputeFullAreaUsingScreen ( nsRect* outRect )
{
// if we have more than one screen, we always need to recompute the clientRect
// because the window may have moved onto a different screen. In the single
// monitor case, we only need to do the computation if we haven't done it
// once already, and remember that we have because we're assured it won't change.
nsCOMPtr<nsIScreen> screen;
FindScreen ( getter_AddRefs(screen) );
if ( screen ) {
PRInt32 x, y, width, height;
screen->GetRect ( &x, &y, &width, &height );
// convert to device units
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
mWidth = width;
mHeight = height;
mCachedFullRect = PR_TRUE;
}
} // ComputeFullRectUsingScreen
//
// FindScreen
//
// Determines which screen intersects the largest area of the given surface.
//
void
nsDeviceContextWin :: FindScreen ( nsIScreen** outScreen )
{
// now then, if we have more than one screen, we need to find which screen this
// window is on.
HWND window = reinterpret_cast<HWND>(mWidget);
if ( window ) {
RECT globalPosition;
::GetWindowRect ( window, &globalPosition );
if ( mScreenManager )
mScreenManager->ScreenForRect ( globalPosition.left, globalPosition.top,
globalPosition.right - globalPosition.left,
globalPosition.bottom - globalPosition.top, outScreen );
}
} // FindScreen
static NS_DEFINE_CID(kRCCID,NS_RENDERING_CONTEXT_CID);
NS_IMETHODIMP nsDeviceContextWin :: CreateRenderingContext(nsIRenderingContext *&aContext)
{
#ifdef NS_PRINT_PREVIEW
// Defer to Alt when there is one
if (mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) {
return mAltDC->CreateRenderingContext(aContext);
}
#endif
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceWin *surf;
rv = CallCreateInstance(kRCCID, &pContext);
if ( (NS_SUCCEEDED(rv)) && (nsnull != pContext))
{
surf = new nsDrawingSurfaceWin();
if (nsnull != surf)
{
rv = surf->Init(mDC);
if (NS_OK == rv)
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextWin :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
if (nsnull == mDC)
aSupportsWidgets = PR_TRUE;
else
aSupportsWidgets = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: GetCanonicalPixelScale(float &aScale) const
{
aScale = mPixelScale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: SetCanonicalPixelScale(float aScale)
{
DeviceContextImpl::SetCanonicalPixelScale(aScale);
mPixelScale = aScale;
return NS_OK;
}
nsresult nsDeviceContextWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
nsFont* aFont, PRBool aIsWide) const
{
PRUnichar name[LF_FACESIZE];
name[0] = 0;
if (aIsWide)
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2);
else {
MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName,
strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));
}
aFont->name = name;
// Do Style
aFont->style = NS_FONT_STYLE_NORMAL;
if (ptrLogFont->lfItalic)
{
aFont->style = NS_FONT_STYLE_ITALIC;
}
// XXX What about oblique?
aFont->variant = NS_FONT_VARIANT_NORMAL;
// Do Weight
aFont->weight = (ptrLogFont->lfWeight == FW_BOLD ?
NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);
// Do decorations
aFont->decorations = NS_FONT_DECORATION_NONE;
if (ptrLogFont->lfUnderline)
{
aFont->decorations |= NS_FONT_DECORATION_UNDERLINE;
}
if (ptrLogFont->lfStrikeOut)
{
aFont->decorations |= NS_FONT_DECORATION_LINE_THROUGH;
}
// Do Point Size
//
// The lfHeight is in pixel and it needs to be adjusted for the
// device it will be "displayed" on
// Screens and Printers will differe in DPI
//
// So this accounts for the difference in the DeviceContexts
// The mPixelScale will be a "1" for the screen and could be
// any value when going to a printer, for example mPixleScale is
// 6.25 when going to a 600dpi printer.
// round, but take into account whether it is negative
float pixelHeight = -ptrLogFont->lfHeight;
if (pixelHeight < 0) {
HFONT hFont = ::CreateFontIndirect(ptrLogFont);
if (!hFont)
return NS_ERROR_OUT_OF_MEMORY;
HGDIOBJ hObject = ::SelectObject(*aHDC, hFont);
TEXTMETRIC tm;
::GetTextMetrics(*aHDC, &tm);
::SelectObject(*aHDC, hObject);
::DeleteObject(hFont);
pixelHeight = tm.tmAscent;
}
float pointSize = pixelHeight * mPixelScale * 72 / ::GetDeviceCaps(*aHDC, LOGPIXELSY);
// we have problem on Simplified Chinese system because the system report
// the default font size is 8. but if we use 8, the text display very
// Ugly. force it to be at 9 on that system (cp936), but leave other sizes alone.
if ((pointSize < 9) &&
(936 == ::GetACP()))
pointSize = 9;
aFont->size = NSFloatPointsToTwips(pointSize);
return NS_OK;
}
nsresult nsDeviceContextWin :: GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const
{
HGDIOBJ hGDI;
LOGFONT logFont;
LOGFONT* ptrLogFont = NULL;
#ifdef WINCE
hGDI = ::GetStockObject(SYSTEM_FONT);
if (hGDI == NULL)
return NS_ERROR_UNEXPECTED;
if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
ptrLogFont = &logFont;
#else
NONCLIENTMETRICS ncm;
BOOL status;
if (anID == eSystemFont_Icon)
{
status = ::SystemParametersInfo(SPI_GETICONTITLELOGFONT,
sizeof(logFont),
(PVOID)&logFont,
0);
}
else
{
ncm.cbSize = sizeof(NONCLIENTMETRICS);
status = ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm),
(PVOID)&ncm,
0);
}
if (!status)
{
return NS_ERROR_FAILURE;
}
switch (anID)
{
// Caption in CSS is NOT the same as Caption on Windows
//case eSystemFont_Caption:
// ptrLogFont = &ncm.lfCaptionFont;
// break;
case eSystemFont_Icon:
ptrLogFont = &logFont;
break;
case eSystemFont_Menu:
ptrLogFont = &ncm.lfMenuFont;
break;
case eSystemFont_MessageBox:
ptrLogFont = &ncm.lfMessageFont;
break;
case eSystemFont_SmallCaption:
ptrLogFont = &ncm.lfSmCaptionFont;
break;
case eSystemFont_StatusBar:
case eSystemFont_Tooltips:
ptrLogFont = &ncm.lfStatusFont;
break;
case eSystemFont_Widget:
case eSystemFont_Window: // css3
case eSystemFont_Document:
case eSystemFont_Workspace:
case eSystemFont_Desktop:
case eSystemFont_Info:
case eSystemFont_Dialog:
case eSystemFont_Button:
case eSystemFont_PullDownMenu:
case eSystemFont_List:
case eSystemFont_Field:
case eSystemFont_Caption:
hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
if (hGDI != NULL)
{
if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
{
ptrLogFont = &logFont;
}
}
break;
} // switch
#endif // WINCE
if (nsnull == ptrLogFont)
{
return NS_ERROR_FAILURE;
}
aFont->systemFont = PR_TRUE;
return CopyLogFontToNSFont(&aHDC, ptrLogFont, aFont);
}
NS_IMETHODIMP nsDeviceContextWin :: GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
{
nsresult status = NS_OK;
switch (anID) {
case eSystemFont_Caption:
case eSystemFont_Icon:
case eSystemFont_Menu:
case eSystemFont_MessageBox:
case eSystemFont_SmallCaption:
case eSystemFont_StatusBar:
case eSystemFont_Tooltips:
case eSystemFont_Widget:
case eSystemFont_Window: // css3
case eSystemFont_Document:
case eSystemFont_Workspace:
case eSystemFont_Desktop:
case eSystemFont_Info:
case eSystemFont_Dialog:
case eSystemFont_Button:
case eSystemFont_PullDownMenu:
case eSystemFont_List:
case eSystemFont_Field:
{
HWND hwnd;
HDC tdc;
if (nsnull == mDC)
{
hwnd = (HWND)mWidget;
tdc = ::GetDC(hwnd);
}
else
tdc = mDC;
status = GetSysFontInfo(tdc, anID, aFont);
if (nsnull == mDC)
::ReleaseDC(hwnd, tdc);
break;
}
}
return status;
}
NS_IMETHODIMP nsDeviceContextWin :: GetDrawingSurface(nsIRenderingContext &aContext, nsIDrawingSurface* &aSurface)
{
if (NULL == mSurface) {
nsRect empty(0,0,0,0); // CreateDrawingSurface(null,...) used width=0,height=0
aContext.CreateDrawingSurface(empty, 0, mSurface);
}
aSurface = mSurface;
return NS_OK;
}
int CALLBACK fontcallback(ENUMLOGFONT FAR *lpelf, NEWTEXTMETRIC FAR *lpntm,
int FontType, LPARAM lParam)
{
if (NULL != lpelf)
*((PRBool *)lParam) = PR_TRUE;
return 0;
}
NS_IMETHODIMP nsDeviceContextWin :: CheckFontExistence(const nsString& aFontName)
{
HWND hwnd = (HWND)mWidget;
HDC hdc = ::GetDC(hwnd);
PRBool isthere = PR_FALSE;
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfPitchAndFamily = 0;
int outlen = WideCharToMultiByte(CP_ACP, 0, aFontName.get(), aFontName.Length() + 1,
logFont.lfFaceName, sizeof(logFont.lfFaceName), nsnull, nsnull);
// somehow the WideCharToMultiByte failed, let's try the old code
if(0 == outlen) {
nsFixedCString logFontStr(logFont.lfFaceName, LF_FACESIZE);
LossyCopyUTF16toASCII(aFontName, logFontStr);
if (logFontStr.get() != logFont.lfFaceName) {
return NS_ERROR_FAILURE; // the font name is too large
}
}
::EnumFontFamiliesEx(hdc, &logFont, (FONTENUMPROC)fontcallback, (LPARAM)&isthere, 0);
::ReleaseDC(hwnd, hdc);
if (PR_TRUE == isthere)
return NS_OK;
else
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDeviceContextWin::GetDepth(PRUint32& aDepth)
{
aDepth = mDepth;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
{
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
if (NULL == mPaletteInfo.palette) {
#ifndef WINCE
HWND hwnd = (HWND)mWidget;
HDC hdc = ::GetDC(hwnd);
mPaletteInfo.palette = ::CreateHalftonePalette(hdc);
::ReleaseDC(hwnd, hdc);
#else
mPaletteInfo.palette = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
#endif
}
aPaletteInfo.palette = mPaletteInfo.palette;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
#ifdef NS_PRINT_PREVIEW
// Defer to Alt when there is one
if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM)) {
return mAltDC->GetDeviceSurfaceDimensions(aWidth, aHeight);
}
#endif
if ( mSpec )
{
// we have a printer device
aWidth = NSToIntRound(mWidth * mDevUnitsToAppUnits);
aHeight = NSToIntRound(mHeight * mDevUnitsToAppUnits);
}
else
{
nsRect area;
ComputeFullAreaUsingScreen ( &area );
aWidth = area.width;
aHeight = area.height;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: GetRect(nsRect &aRect)
{
if ( mSpec )
{
// we have a printer device
aRect.x = 0;
aRect.y = 0;
aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
}
else
ComputeFullAreaUsingScreen ( &aRect );
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: GetClientRect(nsRect &aRect)
{
if ( mSpec )
{
// we have a printer device
aRect.x = 0;
aRect.y = 0;
aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
}
else
ComputeClientRectUsingScreen ( &aRect );
return NS_OK;
}
BOOL CALLBACK abortproc( HDC hdc, int iError )
{
return TRUE;
}
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
nsDeviceContextWin* devConWin = new nsDeviceContextWin(); //ref count 0
if (devConWin != nsnull) {
// this will ref count it
nsresult rv = devConWin->QueryInterface(NS_GET_IID(nsIDeviceContext), (void**)&aContext);
NS_ASSERTION(NS_SUCCEEDED(rv), "This has to support nsIDeviceContext");
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
devConWin->mSpec = aDevice;
NS_ADDREF(aDevice);
HDC dc = NULL;
nsCOMPtr<nsISupportsVoid> supVoid = do_QueryInterface(aDevice);
supVoid->GetData((void**)&dc);
return devConWin->Init(dc, this); // take ownership of the DC
}
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
static void DisplayLastError()
{
LPVOID lpMsgBuf;
DWORD errCode = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
}
#define DISPLAY_LAST_ERROR DisplayLastError();
#else
#define DISPLAY_LAST_ERROR
#endif
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
{
nsresult rv = NS_ERROR_GFX_PRINTER_STARTDOC;
if (NULL != mDC) {
DOCINFO docinfo;
nsString titleStr;
titleStr = aTitle;
if (titleStr.Length() > DOC_TITLE_LENGTH) {
titleStr.SetLength(DOC_TITLE_LENGTH-3);
titleStr.AppendLiteral("...");
}
char *title = GetACPString(titleStr);
char* docName = nsnull;
nsAutoString str(aPrintToFileName);
if (!str.IsEmpty()) {
docName = ToNewCString(str);
}
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = title != nsnull?title:"Mozilla Document";
#ifdef DEBUG_rods
docinfo.lpszOutput = "\\p.ps";
#ifdef MOZ_LAYOUTDEBUG
// This is for overriding the above when doing the runtime checking
char * tempFileName = nsnull;
nsCOMPtr<nsIDebugObject>debugObj = do_GetService("@mozilla.org/debug/debugobject;1");
if (debugObj) {
PRBool isDoingTests;
if (NS_SUCCEEDED(debugObj->GetDoRuntimeTests(&isDoingTests)) && isDoingTests) {
PRUnichar * name;
debugObj->GetPrintFileName(&name);
if (name) {
if (*name) {
nsCString cStrName;
cStrName.AssignWithConversion(name);
tempFileName = ToNewCString(cStrName);
}
nsMemory::Free(name);
}
docinfo.lpszOutput = tempFileName;
}
}
#endif
#else
docinfo.lpszOutput = docName;
#endif
docinfo.lpszDatatype = NULL;
docinfo.fwType = 0;
if (::StartDoc(mDC, &docinfo) > 0) {
rv = NS_OK;
} else {
DISPLAY_LAST_ERROR
rv = NS_ERROR_GFX_PRINTER_STARTDOC;
PR_PL(("nsDeviceContextWin::BeginDocument - StartDoc Error!\n"));
}
if (title != nsnull) delete [] title;
if (docName != nsnull) nsMemory::Free(docName);
#if defined(DEBUG_rods) && defined(MOZ_LAYOUTDEBUG)
if (tempFileName) {
nsMemory::Free(tempFileName);
}
#endif
}
return rv;
}
NS_IMETHODIMP nsDeviceContextWin :: EndDocument(void)
{
if (NULL != mDC)
{
if (::EndDoc(mDC) > 0) {
return NS_OK;
} else {
DISPLAY_LAST_ERROR
PR_PL(("nsDeviceContextWin::EndDocument - EndDoc Error!\n"));
return NS_ERROR_GFX_PRINTER_ENDDOC;
}
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: AbortDocument(void)
{
if (NULL != mDC)
{
if (::AbortDoc(mDC) > 0) {
return NS_OK;
} else {
DISPLAY_LAST_ERROR
PR_PL(("nsDeviceContextWin::AbortDocument - AbortDoc Error!\n"));
return NS_ERROR_ABORT;
}
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: BeginPage(void)
{
if (NULL != mDC)
{
if (::StartPage(mDC) > 0)
return NS_OK;
else {
DISPLAY_LAST_ERROR
PR_PL(("nsDeviceContextWin::BeginPage - StartPage Error!\n"));
return NS_ERROR_GFX_PRINTER_STARTPAGE;
}
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: EndPage(void)
{
if (NULL != mDC)
{
if (::EndPage(mDC) > 0) {
return NS_OK;
} else {
DISPLAY_LAST_ERROR
PR_PL(("nsDeviceContextWin::EndPage - EndPage Error!\n"));
return NS_ERROR_GFX_PRINTER_ENDPAGE;
}
}
return NS_OK;
}
char*
nsDeviceContextWin :: GetACPString(const nsAString& aStr)
{
int acplen = aStr.Length() * 2 + 1;
char * acp = new char[acplen];
if(acp)
{
int outlen = ::WideCharToMultiByte( CP_ACP, 0,
PromiseFlatString(aStr).get(), aStr.Length(),
acp, acplen, NULL, NULL);
if ( outlen > 0)
acp[outlen] = '\0'; // null terminate
}
return acp;
}

Просмотреть файл

@ -1,125 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextWin_h___
#define nsDeviceContextWin_h___
#include "nsDeviceContext.h"
#include "nsIScreenManager.h"
#include <windows.h>
class nsIScreen;
class nsDeviceContextWin : public DeviceContextImpl
{
public:
nsDeviceContextWin();
NS_IMETHOD Init(nsNativeWidget aWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const;
NS_IMETHOD SetCanonicalPixelScale(float aScale);
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsIDrawingSurface* &aSurface);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDepth(PRUint32& aDepth);
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
// Static Helper Methods
static char* GetACPString(const nsAString& aStr);
friend class nsNativeThemeWin;
protected:
virtual ~nsDeviceContextWin();
void CommonInit(HDC aDC);
nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
void FindScreen ( nsIScreen** outScreen ) ;
void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const;
nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont,
PRBool aIsWide = PR_FALSE) const;
PRBool mCachedClientRect;
PRBool mCachedFullRect;
nsIDrawingSurface* mSurface;
PRUint32 mDepth; // bit depth of device
nsPaletteInfo mPaletteInfo;
float mPixelScale;
PRInt32 mWidth;
PRInt32 mHeight;
nsRect mClientRect;
nsIDeviceContextSpec *mSpec;
nsCOMPtr<nsIScreenManager> mScreenManager; // cache the screen service
public:
HDC mDC;
};
#endif /* nsDeviceContextWin_h___ */

Просмотреть файл

@ -1,919 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifdef NGLAYOUT_DDRAW
#define INITGUID
#endif
#include "nsDrawingSurfaceWin.h"
#include "prmem.h"
#include "nsCRT.h"
//#define GFX_DEBUG
#ifdef GFX_DEBUG
#define BREAK_TO_DEBUGGER DebugBreak()
#else
#define BREAK_TO_DEBUGGER
#endif
#ifdef GFX_DEBUG
#define VERIFY(exp) ((exp) ? 0: (GetLastError(), BREAK_TO_DEBUGGER))
#else // !_DEBUG
#define VERIFY(exp) (exp)
#endif // !_DEBUG
static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID);
static NS_DEFINE_IID(kIDrawingSurfaceWinIID, NS_IDRAWING_SURFACE_WIN_IID);
#ifdef NGLAYOUT_DDRAW
IDirectDraw *nsDrawingSurfaceWin::mDDraw = NULL;
IDirectDraw2 *nsDrawingSurfaceWin::mDDraw2 = NULL;
nsresult nsDrawingSurfaceWin::mDDrawResult = NS_OK;
#endif
nsDrawingSurfaceWin :: nsDrawingSurfaceWin()
{
mDC = NULL;
mOrigBitmap = nsnull;
mSelectedBitmap = nsnull;
mKillDC = PR_FALSE;
mBitmapInfo = nsnull;
mDIBits = nsnull;
mLockedBitmap = nsnull;
mWidth = mHeight = 0;
mLockOffset = mLockHeight = 0;
mLockFlags = 0;
#ifdef NGLAYOUT_DDRAW
CreateDDraw();
mSurface = NULL;
mSurfLockCnt = 0;
#endif
}
nsDrawingSurfaceWin :: ~nsDrawingSurfaceWin()
{
if ((nsnull != mDC) && (nsnull != mOrigBitmap))
{
HBITMAP tbits = (HBITMAP)::SelectObject(mDC, mOrigBitmap);
if (nsnull != tbits)
VERIFY(::DeleteObject(tbits));
mOrigBitmap = nsnull;
}
if (nsnull != mBitmapInfo)
{
PR_Free(mBitmapInfo);
mBitmapInfo = nsnull;
}
if ((nsnull != mDIBits) && (nsnull == mSelectedBitmap))
PR_Free(mDIBits);
mDIBits = nsnull;
mSelectedBitmap = nsnull;
#ifdef NGLAYOUT_DDRAW
if (NULL != mSurface)
{
if (NULL != mDC)
{
mSurface->ReleaseDC(mDC);
mDC = NULL;
}
NS_RELEASE(mSurface);
mSurface = NULL;
}
else
#endif
{
if (NULL != mDC)
{
if (PR_TRUE == mKillDC)
::DeleteDC(mDC);
mDC = NULL;
}
}
}
NS_IMETHODIMP nsDrawingSurfaceWin :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDrawingSurfaceIID))
{
nsIDrawingSurface* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDrawingSurfaceWinIID))
{
nsIDrawingSurfaceWin* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDrawingSurface* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDrawingSurfaceWin)
NS_IMPL_RELEASE(nsDrawingSurfaceWin)
NS_IMETHODIMP nsDrawingSurfaceWin :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#ifdef NGLAYOUT_DDRAW
if (mSurfLockCnt == 0)
{
RECT srect;
DWORD lockflags = 0;
srect.left = aX;
srect.top = aY;
srect.right = aX + aWidth;
srect.bottom = aY + aHeight;
if (aFlags & NS_LOCK_SURFACE_READ_ONLY)
lockflags |= DDLOCK_READONLY;
if (aFlags & NS_LOCK_SURFACE_WRITE_ONLY)
lockflags |= DDLOCK_WRITEONLY;
if (PR_TRUE == LockSurface(mSurface, &mSurfDesc, &mBitmap, &srect, lockflags, &mPixFormat))
mSurfLockCnt++;
}
else
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
if (mSurfLockCnt == 0)
#endif
{
if (nsnull == mLockedBitmap)
{
if (nsnull == mSelectedBitmap)
{
HBITMAP tbits = ::CreateCompatibleBitmap(mDC, 2, 2);
if ( tbits != nsnull )
{
mLockedBitmap = (HBITMAP)::SelectObject(mDC, tbits);
// if the SelectObject fails, or there was no bitmap returned from this DC
if ( mLockedBitmap != nsnull )
{
::GetObject(mLockedBitmap, sizeof(BITMAP), &mBitmap);
// Always use at least 24-bit bitmaps regardless of the device context.
// See bug 228399 for more information.
if (mBitmap.bmBitsPixel < 24)
mBitmap.bmBitsPixel = 24;
// Note the width of the DIB-bits rows. DIB rows are DWORD-aligned,
// the original bitmap's rows may not have been DWORD-aligned.
mBitmap.bmWidthBytes = RASWIDTH(mBitmap.bmWidth, mBitmap.bmBitsPixel);
if (aY < 0 || aY + aHeight > mBitmap.bmHeight) {
::DeleteObject(tbits);
return NS_ERROR_FAILURE;
}
// GetDIBits always seems to interpret the scanlines as bottom-to-top.
mLockHeight = (PRInt32)aHeight;
mLockOffset = mBitmap.bmHeight - (aY + aHeight);
mBitmapInfo = CreateBitmapInfo(mBitmap.bmWidth, mBitmap.bmHeight, mBitmap.bmBitsPixel, (void **)&mDIBits);
if ( mBitmapInfo != nsnull ) {
if (!(aFlags & NS_LOCK_SURFACE_WRITE_ONLY))
::GetDIBits(mDC, mLockedBitmap, mLockOffset, mLockHeight, mDIBits, mBitmapInfo, DIB_RGB_COLORS);
mBitmap.bmBits = mDIBits;
} else {
::DeleteObject(tbits);
return NS_ERROR_FAILURE;
}
}
else
{
::DeleteObject(tbits);
return NS_ERROR_FAILURE;
}
}
else
{
return NS_ERROR_FAILURE;
}
}
else
{
if (!(aFlags & NS_LOCK_SURFACE_WRITE_ONLY))
::GdiFlush();
mLockedBitmap = mSelectedBitmap;
mBitmap.bmBits = mDIBits + mBitmap.bmWidthBytes * aY;
}
}
else
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
}
*aBits = (PRUint8 *)mBitmap.bmBits + (aX * (mBitmap.bmBitsPixel >> 3));
*aStride = mBitmap.bmWidthBytes;
*aWidthBytes = aWidth * (mBitmap.bmBitsPixel >> 3);
mLockFlags = aFlags;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: Unlock(void)
{
#ifdef NGLAYOUT_DDRAW
NS_ASSERTION(!(mDC != nsnull), "attempt to unlock with dc");
if (nsnull == mDC)
{
mSurfLockCnt--;
NS_ASSERTION(!(mSurfLockCnt != 0), "nested surface locks");
if (mSurfLockCnt == 0)
mSurface->Unlock(mSurfDesc.lpSurface);
}
else
#endif
{
if (nsnull != mLockedBitmap)
{
if (nsnull == mSelectedBitmap)
{
HBITMAP tbits;
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
::SetDIBits(mDC, mLockedBitmap, mLockOffset, mLockHeight, mDIBits, mBitmapInfo, DIB_RGB_COLORS);
tbits = (HBITMAP)::SelectObject(mDC, mLockedBitmap);
::DeleteObject(tbits);
if (nsnull != mBitmapInfo)
{
PR_Free(mBitmapInfo);
mBitmapInfo = nsnull;
}
if (nsnull != mDIBits)
{
PR_Free(mDIBits);
mDIBits = nsnull;
}
}
mLockedBitmap = nsnull;
}
}
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mKillDC;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: IsPixelAddressable(PRBool *aAddressable)
{
#ifdef NGLAYOUT_DDRAW
if (nsnull != mSurface)
*aAddressable = PR_TRUE;
else
#endif
if (nsnull != mSelectedBitmap)
*aAddressable = PR_TRUE;
else
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: Init(HDC aDC)
{
mDC = aDC;
mTechnology = ::GetDeviceCaps(mDC, TECHNOLOGY);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: Init(HDC aDC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
NS_ASSERTION(!(aDC == nsnull), "null DC");
#if defined(MOZ_SVG) && defined(SVG_FORCE_PIXEL_ACCESS_SURFACES)
// force pixel access on all surfaces. Improves gdi+ performance
aFlags |= NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS;
#endif
#ifdef NGLAYOUT_DDRAW
if (aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS)
{
LPDIRECTDRAWSURFACE ddsurf = nsnull;
if ((NULL != mDDraw2) && (aWidth > 0) && (aHeight > 0))
{
DDSURFACEDESC ddsd;
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |
((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) ?
DDSCAPS_SYSTEMMEMORY : 0);
ddsd.dwWidth = aWidth;
ddsd.dwHeight = aHeight;
mDDraw2->CreateSurface(&ddsd, &ddsurf, NULL);
}
if (NULL != ddsurf)
mSurface = ddsurf;
else
{
mDC = ::CreateCompatibleDC(aDC);
mKillDC = PR_TRUE;
}
}
else
#endif
{
mDC = ::CreateCompatibleDC(aDC);
mTechnology = ::GetDeviceCaps(mDC, TECHNOLOGY);
mKillDC = PR_TRUE;
}
#ifdef NGLAYOUT_DDRAW
if (nsnull == mSurface)
#endif
{
HBITMAP tbits = nsnull;
if (aWidth > 0 && aHeight > 0)
{
if ((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) == 0)
tbits = ::CreateCompatibleBitmap(aDC, aWidth, aHeight);
// Create a DIB if we need Pixel Access, or if DDB creation failed
if (nsnull == tbits)
{
void *bits;
BITMAPINFO *binfo;
int depth;
depth = ::GetDeviceCaps(aDC, BITSPIXEL);
// Always use at least 24-bit bitmaps regardless of the device context.
// See bug 228399 for more information.
if (depth < 24)
depth = 24;
binfo = CreateBitmapInfo(aWidth, aHeight, depth);
if (nsnull == binfo)
return NS_ERROR_FAILURE;
mSelectedBitmap = tbits = ::CreateDIBSection(aDC, binfo, DIB_RGB_COLORS, &bits, NULL, 0);
if (NULL == mSelectedBitmap)
return NS_ERROR_FAILURE;
mBitmapInfo = binfo;
mDIBits = (PRUint8 *)bits;
mBitmap.bmWidthBytes = RASWIDTH(aWidth, depth);
mBitmap.bmBitsPixel = depth;
}
}
else
{
//we do this to make sure that the memory DC knows what the
//bitmap format of the original DC was. this way, later
//operations to create bitmaps from the memory DC will create
//bitmaps with the correct properties.
tbits = ::CreateCompatibleBitmap(aDC, 2, 2);
}
mOrigBitmap = (HBITMAP)::SelectObject(mDC, tbits);
}
mWidth = aWidth;
mHeight = aHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: GetDC(HDC *aDC)
{
#ifdef NGLAYOUT_DDRAW
if (nsnull != mSurface)
{
if (0 == mSurfLockCnt)
mSurface->GetDC(&mDC);
mSurfLockCnt++;
}
#endif
*aDC = mDC;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceWin::GetTECHNOLOGY(PRInt32 *aTechnology)
{
*aTechnology = mTechnology;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: ReleaseDC(void)
{
#ifdef NGLAYOUT_DDRAW
if (nsnull != mSurface)
{
--mSurfLockCnt;
if ((nsnull != mDC) && (mSurfLockCnt == 0))
{
mSurface->ReleaseDC(mDC);
mDC = nsnull;
}
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceWin :: IsReleaseDCDestructive(PRBool *aDestructive)
{
#ifdef NGLAYOUT_DDRAW
if (nsnull != mSurface)
*aDestructive = PR_TRUE;
else
#endif
*aDestructive = PR_FALSE;
return NS_OK;
}
BITMAPINFO * nsDrawingSurfaceWin :: CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
void **aBits)
{
NS_ASSERTION(aDepth == 24 || aDepth == 32, "Unsupported bitmap depth");
PRInt32 palsize, imagesize, spanbytes, allocsize;
PRUint8 *colortable;
DWORD bicomp, masks[3];
BITMAPINFO *rv = nsnull;
switch (aDepth)
{
case 24:
palsize = 0;
allocsize = 0;
bicomp = BI_RGB;
mPixFormat.mRedZeroMask = 0xff;
mPixFormat.mGreenZeroMask = 0xff;
mPixFormat.mBlueZeroMask = 0xff;
mPixFormat.mAlphaZeroMask = 0;
mPixFormat.mRedMask = 0xff0000;
mPixFormat.mGreenMask = 0xff00;
mPixFormat.mBlueMask = 0xff;
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedCount = 8;
mPixFormat.mGreenCount = 8;
mPixFormat.mBlueCount = 8;
mPixFormat.mAlphaCount = 0;
mPixFormat.mRedShift = 16;
mPixFormat.mGreenShift = 8;
mPixFormat.mBlueShift = 0;
mPixFormat.mAlphaShift = 0;
break;
case 32:
palsize = 0;
allocsize = 3;
bicomp = BI_BITFIELDS;
masks[0] = 0xff0000;
masks[1] = 0x00ff00;
masks[2] = 0x0000ff;
mPixFormat.mRedZeroMask = 0xff;
mPixFormat.mGreenZeroMask = 0xff;
mPixFormat.mBlueZeroMask = 0xff;
mPixFormat.mAlphaZeroMask = 0xff;
mPixFormat.mRedMask = masks[0];
mPixFormat.mGreenMask = masks[1];
mPixFormat.mBlueMask = masks[2];
mPixFormat.mAlphaMask = 0xff000000;
mPixFormat.mRedCount = 8;
mPixFormat.mGreenCount = 8;
mPixFormat.mBlueCount = 8;
mPixFormat.mAlphaCount = 8;
mPixFormat.mRedShift = 16;
mPixFormat.mGreenShift = 8;
mPixFormat.mBlueShift = 0;
mPixFormat.mAlphaShift = 24;
break;
default:
palsize = -1;
break;
}
if (palsize >= 0)
{
spanbytes = RASWIDTH(aWidth, aDepth);
imagesize = spanbytes * aHeight;
rv = (BITMAPINFO *)PR_Malloc(sizeof(BITMAPINFOHEADER) + (sizeof(RGBQUAD) * allocsize));
if (nsnull != rv)
{
rv->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
rv->bmiHeader.biWidth = aWidth;
rv->bmiHeader.biHeight = -aHeight;
rv->bmiHeader.biPlanes = 1;
rv->bmiHeader.biBitCount = (unsigned short)aDepth;
rv->bmiHeader.biCompression = bicomp;
rv->bmiHeader.biSizeImage = imagesize;
rv->bmiHeader.biXPelsPerMeter = 0;
rv->bmiHeader.biYPelsPerMeter = 0;
rv->bmiHeader.biClrUsed = palsize;
rv->bmiHeader.biClrImportant = palsize;
// set the color table in the info header
colortable = (PRUint8 *)rv + sizeof(BITMAPINFOHEADER);
if ((aDepth == 16) || (aDepth == 32))
memcpy(colortable, masks, sizeof(DWORD) * allocsize);
else
memset(colortable, 0, sizeof(RGBQUAD) * palsize);
if (nsnull != aBits) {
*aBits = PR_Malloc(imagesize);
if ( nsnull == *aBits ) {
PR_Free(rv);
rv = nsnull;
}
}
}
}
return rv;
}
#ifdef NGLAYOUT_DDRAW
PRBool nsDrawingSurfaceWin :: LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc,
BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags, nsPixelFormat *aPixFormat)
{
if (nsnull != aSurface)
{
aDesc->dwSize = sizeof(DDSURFACEDESC);
if (DD_OK == aSurface->Lock(aRect, aDesc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | aLockFlags, NULL))
{
if ((aDesc->ddpfPixelFormat.dwFlags &
(DDPF_ALPHA | DDPF_PALETTEINDEXED1 |
DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4 |
DDPF_PALETTEINDEXEDTO8 | DDPF_YUV | DDPF_ZBUFFER)) ||
(aDesc->ddpfPixelFormat.dwRGBBitCount < 8))
{
//this is a surface that we can't, or don't want to handle.
aSurface->Unlock(aDesc->lpSurface);
return PR_FALSE;
}
aBitmap->bmType = 0;
aBitmap->bmWidth = aDesc->dwWidth;
aBitmap->bmHeight = aDesc->dwHeight;
aBitmap->bmWidthBytes = aDesc->lPitch;
aBitmap->bmPlanes = 1;
aBitmap->bmBitsPixel = (PRUint16)aDesc->ddpfPixelFormat.dwRGBBitCount;
aBitmap->bmBits = aDesc->lpSurface;
if ((nsnull != aPixFormat) && (aBitmap->bmBitsPixel > 8))
{
DWORD btemp, shiftcnt;
btemp = aDesc->ddpfPixelFormat.dwRBitMask;
aPixFormat->mRedMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff))
{
aPixFormat->mRedShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff))
{
aPixFormat->mRedShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else
{
aPixFormat->mRedShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mRedShift++;
}
aPixFormat->mRedZeroMask = btemp;
aPixFormat->mRedCount = 0;
while ((btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mRedCount++;
}
btemp = aDesc->ddpfPixelFormat.dwGBitMask;
aPixFormat->mGreenMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff))
{
aPixFormat->mGreenShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff))
{
aPixFormat->mGreenShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else
{
aPixFormat->mGreenShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mGreenShift++;
}
aPixFormat->mGreenZeroMask = btemp;
aPixFormat->mGreenCount = 0;
while ((btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mGreenCount++;
}
btemp = aDesc->ddpfPixelFormat.dwBBitMask;
aPixFormat->mBlueMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff))
{
aPixFormat->mBlueShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff))
{
aPixFormat->mBlueShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else
{
aPixFormat->mBlueShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mBlueShift++;
}
aPixFormat->mBlueZeroMask = btemp;
aPixFormat->mBlueCount = 0;
while ((btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mBlueCount++;
}
aPixFormat->mAlphaCount = (PRUint8)aDesc->ddpfPixelFormat.dwAlphaBitDepth;
if (aPixFormat->mAlphaCount > 0)
{
btemp = aDesc->ddpfPixelFormat.dwRGBAlphaBitMask;
aPixFormat->mAlphaMask = btemp;
shiftcnt = 32;
if (!(btemp & 0xffff))
{
aPixFormat->mAlphaShift = 16;
btemp >>= 16;
shiftcnt = 16;
}
else if (!(btemp & 0xff))
{
aPixFormat->mAlphaShift = 8;
btemp >>= 8;
shiftcnt = 24;
}
else
{
aPixFormat->mAlphaShift = 0;
shiftcnt = 32;
}
while (!(btemp & 1) && shiftcnt--)
{
btemp >>= 1;
aPixFormat->mAlphaShift++;
}
aPixFormat->mAlphaZeroMask = btemp;
}
else
{
aPixFormat->mAlphaMask = 0;
aPixFormat->mAlphaShift = 0;
aPixFormat->mAlphaZeroMask = 0;
}
}
return PR_TRUE;
}
else
return PR_FALSE;
}
else
return PR_FALSE;
}
nsresult nsDrawingSurfaceWin :: CreateDDraw()
{
if ((mDDraw2 == NULL) && (mDDrawResult == NS_OK))
{
CoInitialize(NULL);
mDDrawResult = DirectDrawCreate(NULL, &mDDraw, NULL);
if (mDDrawResult == NS_OK)
mDDrawResult = mDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)&mDDraw2);
if (mDDrawResult == NS_OK)
{
mDDraw2->SetCooperativeLevel(NULL, DDSCL_NORMAL);
#ifdef NS_DEBUG
printf("using DirectDraw (%08X)\n", mDDraw2);
DDSCAPS ddscaps;
DWORD totalmem, freemem;
ddscaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
nsresult res = mDDraw2->GetAvailableVidMem(&ddscaps, &totalmem, &freemem);
if (NS_SUCCEEDED(res))
{
printf("total video memory: %d\n", totalmem);
printf("free video memory: %d\n", freemem);
}
else
{
printf("GetAvailableVidMem() returned %08x: %s\n", res,
(res == DDERR_NODIRECTDRAWHW) ?
"no hardware ddraw driver available" : "unknown error code");
}
#endif
}
}
return mDDrawResult;
}
nsresult nsDrawingSurfaceWin :: GetDDraw(IDirectDraw2 **aDDraw)
{
CreateDDraw();
if (NULL != mDDraw2)
{
NS_ADDREF(mDDraw2);
*aDDraw = mDDraw2;
}
else
*aDDraw = NULL;
return NS_OK;
}
#endif

Просмотреть файл

@ -1,122 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDrawingSurfaceWin_h___
#define nsDrawingSurfaceWin_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceWin.h"
#ifdef NGLAYOUT_DDRAW
#include "ddraw.h"
#endif
class nsDrawingSurfaceWin : public nsIDrawingSurface,
nsIDrawingSurfaceWin
{
public:
nsDrawingSurfaceWin();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
//nsIDrawingSurfaceWin interface
NS_IMETHOD Init(HDC aDC);
NS_IMETHOD Init(HDC aDC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags);
NS_IMETHOD GetDC(HDC *aDC);
NS_IMETHOD GetTECHNOLOGY(PRInt32 *aTechnology);
NS_IMETHOD ReleaseDC(void);
NS_IMETHOD IsReleaseDCDestructive(PRBool *aDestructive);
// locals
#ifdef NGLAYOUT_DDRAW
nsresult GetDDraw(IDirectDraw2 **aDDraw);
#endif
private:
~nsDrawingSurfaceWin();
BITMAPINFO *CreateBitmapInfo(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
void **aBits = nsnull);
#ifdef NGLAYOUT_DDRAW
nsresult CreateDDraw(void);
PRBool LockSurface(IDirectDrawSurface *aSurface, DDSURFACEDESC *aDesc,
BITMAP *aBitmap, RECT *aRect, DWORD aLockFlags, nsPixelFormat *aPixFormat);
#endif
HDC mDC;
HBITMAP mOrigBitmap;
HBITMAP mSelectedBitmap;
PRBool mKillDC;
BITMAPINFO *mBitmapInfo;
PRUint8 *mDIBits;
BITMAP mBitmap;
nsPixelFormat mPixFormat;
HBITMAP mLockedBitmap;
PRUint32 mWidth;
PRUint32 mHeight;
PRInt32 mLockOffset;
PRInt32 mLockHeight;
PRUint32 mLockFlags;
PRInt32 mTechnology;
#ifdef NGLAYOUT_DDRAW
IDirectDrawSurface *mSurface;
PRInt32 mSurfLockCnt;
DDSURFACEDESC mSurfDesc;
static IDirectDraw *mDDraw;
static IDirectDraw2 *mDDraw2;
static nsresult mDDrawResult;
#endif
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,464 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFontMetricsWin_h__
#define nsFontMetricsWin_h__
#include <windows.h>
#include "plhash.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsDeviceContextWin.h"
#include "nsCOMPtr.h"
#include "nsVoidArray.h"
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include "nsUnicharUtils.h"
#ifdef ADD_GLYPH
#undef ADD_GLYPH
#endif
#define ADD_GLYPH(map, g) SET_REPRESENTABLE(map, g)
enum eFontType {
eFontType_UNKNOWN = -1,
eFontType_Unicode,
eFontType_NonUnicode
};
struct nsCharacterMap {
PRUint8* mData;
PRInt32 mLength;
};
struct nsGlobalFont
{
nsString name;
LOGFONT logFont;
PRUint16* ccmap;
FONTSIGNATURE signature;
eFontType fonttype;
PRUint32 flags;
};
// Bits used for nsGlobalFont.flags
// If this bit is set, then the font is to be ignored
#define NS_GLOBALFONT_SKIP 0x80000000L
// If this bit is set, then the font is a TrueType font
#define NS_GLOBALFONT_TRUETYPE 0x40000000L
// If this bit is set, then the font is a Symbol font (SYMBOL_CHARSET)
#define NS_GLOBALFONT_SYMBOL 0x20000000L
class nsFontWin
{
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsFontWin(LOGFONT* aLogFont, HFONT aFont, PRUint16* aCCMap);
virtual ~nsFontWin();
virtual PRInt32 GetWidth(HDC aDC, const char* aString,
PRUint32 aLength);
virtual PRInt32 GetWidth(HDC aDC, const PRUnichar* aString,
PRUint32 aLength) = 0;
virtual void DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const char* aString, PRUint32 aLength, INT* aDx0);
virtual void DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength) = 0;
virtual PRBool HasGlyph(PRUint32 ch) {return CCMAP_HAS_CHAR_EXT(mCCMap, ch);};
#ifdef MOZ_MATHML
virtual nsresult
GetBoundingMetrics(HDC aDC,
const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
virtual nsresult
GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#ifdef NS_DEBUG
virtual void DumpFontInfo() = 0;
#endif // NS_DEBUG
#endif
char mName[LF_FACESIZE];
HFONT mFont;
PRUint16* mCCMap;
#ifdef MOZ_MATHML
nsCharacterMap* mCMAP;
#endif
nscoord mMaxAscent;
nscoord mMaxDescent;
// Note: these are in device units (pixels) -- not twips like the others
LONG mOverhangCorrection;
LONG mMaxCharWidthMetric;
LONG mMaxHeightMetric;
BYTE mPitchAndFamily;
PRBool FillClipRect(PRInt32 aX, PRInt32 aY, UINT aLength, UINT uOptions, RECT& clipRect);
};
// A "substitute font" to deal with missing glyphs -- see bug 6585
// We now use transliteration+fallback to the REPLACEMENT CHAR +
// HEX representation to handle this issue.
class nsFontWinSubstitute : public nsFontWin
{
public:
nsFontWinSubstitute(LOGFONT* aLogFont, HFONT aFont, PRUint16* aCCMap, PRBool aDisplayUnicode);
nsFontWinSubstitute(PRUint16* aCCMap);
virtual ~nsFontWinSubstitute();
virtual PRBool HasGlyph(PRUint32 ch) {
return mIsForIgnorable ? CCMAP_HAS_CHAR_EXT(mCCMap, ch) :
IS_IN_BMP(ch) && IS_REPRESENTABLE(mRepresentableCharMap, ch);};
virtual void SetRepresentable(PRUint32 ch) { if (IS_IN_BMP(ch)) SET_REPRESENTABLE(mRepresentableCharMap, ch); };
virtual PRInt32 GetWidth(HDC aDC, const PRUnichar* aString, PRUint32 aLength);
virtual void DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength);
#ifdef MOZ_MATHML
virtual nsresult
GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
#ifdef NS_DEBUG
virtual void DumpFontInfo();
#endif // NS_DEBUG
#endif
private:
PRBool mDisplayUnicode;
PRBool mIsForIgnorable;
//We need to have a easily operatable charmap for substitute font
PRUint32 mRepresentableCharMap[UCS2_MAP_LEN];
};
/**
* nsFontSwitchCallback
*
* Font-switching callback function. Used by ResolveForwards() and
* ResolveBackwards(). aFontSwitch points to a structure that gives
* details about the current font needed to represent the current
* substring. In particular, this struct contains a handler to the font
* and some metrics of the font. These metrics may be different from
* the metrics obtained via nsIFontMetrics.
* Return PR_FALSE to stop the resolution of the remaining substrings.
*/
struct nsFontSwitch {
// Simple wrapper on top of nsFontWin for the moment
// Could hold other attributes of the font
nsFontWin* mFontWin;
};
typedef PRBool (*PR_CALLBACK nsFontSwitchCallback)
(const nsFontSwitch* aFontSwitch,
const PRUnichar* aSubstring,
PRUint32 aSubstringLength,
void* aData);
class nsFontMetricsWin : public nsIFontMetrics
{
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
nsFontMetricsWin();
virtual ~nsFontMetricsWin();
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
#ifdef FONT_LEADING_APIS_V2
NS_IMETHOD GetInternalLeading(nscoord &aLeading);
NS_IMETHOD GetExternalLeading(nscoord &aLeading);
#else
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
#endif //FONT_LEADING_APIS_V2
NS_IMETHOD GetEmHeight(nscoord &aHeight);
NS_IMETHOD GetEmAscent(nscoord &aAscent);
NS_IMETHOD GetEmDescent(nscoord &aDescent);
NS_IMETHOD GetMaxHeight(nscoord &aHeight);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
virtual PRInt32 GetMaxStringLength();
virtual nsresult
ResolveForwards(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsFontSwitchCallback aFunc,
void* aData);
virtual nsresult
ResolveBackwards(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsFontSwitchCallback aFunc,
void* aData);
nsFontWin* FindFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindUserDefinedFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindLocalFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindGenericFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindPrefFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindSubstituteFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName, PRBool aNameQuirks=PR_FALSE);
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const nsString& aName);
virtual nsFontWin* GetFontFor(HFONT aHFONT);
nsCOMPtr<nsIAtom> mLangGroup;
nsStringArray mFonts;
PRInt32 mFontsIndex;
nsVoidArray mLoadedFonts;
nsFontWin *mSubstituteFont;
PRInt32 mGenericIndex;
nsString mGeneric;
nsString mUserDefined;
PRBool mTriedAllGenerics;
PRBool mTriedAllPref;
PRBool mIsUserDefined;
static PRUint16* gEmptyCCMap;
static PLHashTable* gFontMaps;
static PLHashTable* gFamilyNames;
static PLHashTable* gFontWeights;
static nsVoidArray* gGlobalFonts;
static nsVoidArray* InitializeGlobalFonts(HDC aDC);
static void SetFontWeight(PRInt32 aWeight, PRUint16* aWeightTable);
static PRBool IsFontWeightAvailable(PRInt32 aWeight, PRUint16 aWeightTable);
static PRUint16* GetFontCCMAP(HDC aDC, const char* aShortName,
PRBool aNameQuirks, eFontType& aFontType, PRUint8& aCharset);
static PRUint16* GetCCMAP(HDC aDC, const char* aShortName,
PRBool* aNameQuirks, eFontType* aFontType, PRUint8* aCharset);
static int SameAsPreviousMap(int aIndex);
// These functions create possibly adjusted fonts
HFONT CreateFontHandle(HDC aDC, const nsString& aName, LOGFONT* aLogFont);
HFONT CreateFontHandle(HDC aDC, nsGlobalFont* aGlobalFont, LOGFONT* aLogFont);
HFONT CreateFontAdjustHandle(HDC aDC, LOGFONT* aLogFont);
void InitMetricsFor(HDC aDC, nsFontWin* aFontWin);
protected:
// @description Font Weights
// Each available font weight is stored as as single bit inside a PRUint16.
// e.g. The binary value 0000000000001000 indcates font weight 400 is available.
// while the binary value 0000000000001001 indicates both font weight 100 and 400 are available
// The font weights which will be represented include {100, 200, 300, 400, 500, 600, 700, 800, 900}
// The font weight specified in the mFont->weight may include values which are not an even multiple of 100.
// If so, the font weight mod 100 indicates the number steps to lighten are make bolder.
// This corresponds to the CSS lighter and bolder property values. If bolder is applied twice to the font which has
// a font weight of 400 then the mFont->weight will contain the value 402.
// If lighter is applied twice to a font of weight 400 then the mFont->weight will contain the value 398.
// Only nine steps of bolder or lighter are allowed by the CSS XPCODE.
// The font weight table is used in conjuction with the mFont->weight to determine
// what font weight to pass in the LOGFONT structure.
// Utility methods for managing font weights.
PRUint16 LookForFontWeightTable(HDC aDc, const nsString& aName);
PRInt32 GetBolderWeight(PRInt32 aWeight, PRInt32 aDistance, PRUint16 aWeightTable);
PRInt32 GetLighterWeight(PRInt32 aWeight, PRInt32 aDistance, PRUint16 aWeightTable);
PRInt32 GetFontWeight(PRInt32 aWeight, PRUint16 aWeightTable);
PRInt32 GetClosestWeight(PRInt32 aWeight, PRUint16 aWeightTable);
PRUint16 GetFontWeightTable(HDC aDC, const nsString& aFontName);
nsFontWin* LocateFont(HDC aDC, PRUint32 aChar, PRInt32 & aCount);
nsresult RealizeFont();
void FillLogFont(LOGFONT* aLogFont, PRInt32 aWeight,
PRBool aSizeOnly=PR_FALSE);
nsDeviceContextWin *mDeviceContext;
HFONT mFontHandle;
nscoord mExternalLeading;
nscoord mInternalLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mAveCharWidth;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
PRInt32 mMaxStringLength;
};
class nsFontEnumeratorWin : public nsIFontEnumerator
{
public:
nsFontEnumeratorWin();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
// The following is a workaround for a Japanse Windows 95 problem.
class nsFontSubset;
class nsFontMetricsWinA;
class nsFontWinA : public nsFontWin
{
public:
nsFontWinA(LOGFONT* aLogFont, HFONT aFont, PRUint16* aCCMap);
virtual ~nsFontWinA();
virtual PRInt32 GetWidth(HDC aDC, const PRUnichar* aString,
PRUint32 aLength);
virtual void DrawString(HDC aDC, PRInt32 aX, PRInt32 aY,
const PRUnichar* aString, PRUint32 aLength);
virtual nsFontSubset* FindSubset(HDC aDC, PRUnichar aChar, nsFontMetricsWinA* aFontMetrics);
#ifdef MOZ_MATHML
virtual nsresult
GetBoundingMetrics(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
#ifdef NS_DEBUG
virtual void DumpFontInfo();
#endif // NS_DEBUG
#endif
int GetSubsets(HDC aDC);
LOGFONT mLogFont;
nsFontSubset** mSubsets;
PRUint16 mSubsetsCount;
};
class nsFontWinSubstituteA : public nsFontWinA
{
public:
nsFontWinSubstituteA(LOGFONT* aLogFont, HFONT aFont, PRUint16* aCCMap);
nsFontWinSubstituteA(PRUint16* aCCMap);
virtual ~nsFontWinSubstituteA();
virtual PRBool HasGlyph(PRUint32 ch) {
return mIsForIgnorable ? CCMAP_HAS_CHAR_EXT(mCCMap, ch) :
IS_IN_BMP(ch) && IS_REPRESENTABLE(mRepresentableCharMap, ch);};
virtual void SetRepresentable(PRUint32 ch) { if (IS_IN_BMP(ch)) SET_REPRESENTABLE(mRepresentableCharMap, ch); };
virtual nsFontSubset* FindSubset(HDC aDC, PRUnichar aChar, nsFontMetricsWinA* aFontMetrics) {return mSubsets[0];};
private:
PRBool mIsForIgnorable;
//We need to have a easily operatable charmap for substitute fonts
PRUint32 mRepresentableCharMap[UCS2_MAP_LEN];
};
class nsFontMetricsWinA : public nsFontMetricsWin
{
public:
virtual nsFontWin* FindLocalFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* LoadGenericFont(HDC aDC, PRUint32 aChar, const nsString& aName);
virtual nsFontWin* FindGlobalFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* FindSubstituteFont(HDC aDC, PRUint32 aChar);
virtual nsFontWin* LoadFont(HDC aDC, const nsString& aName, PRBool aNameQuirks=PR_FALSE);
virtual nsFontWin* LoadGlobalFont(HDC aDC, nsGlobalFont* aGlobalFontItem);
virtual nsFontWin* LoadSubstituteFont(HDC aDC, const nsString& aName);
virtual nsFontWin* GetFontFor(HFONT aHFONT);
virtual nsresult
ResolveForwards(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsFontSwitchCallback aFunc,
void* aData);
virtual nsresult
ResolveBackwards(HDC aDC,
const PRUnichar* aString,
PRUint32 aLength,
nsFontSwitchCallback aFunc,
void* aData);
protected:
nsFontSubset* LocateFontSubset(HDC aDC, PRUnichar aChar, PRInt32 & aCount, nsFontWinA*& aFont);
};
#endif /* nsFontMetricsWin_h__ */

Просмотреть файл

@ -1,192 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsWin.h"
#include "nsRenderingContextWin.h"
#include "nsImageWin.h"
#include "nsDeviceContextWin.h"
#include "nsRegionWin.h"
#include "nsBlender.h"
#include "nsScriptableRegion.h"
#include "nsIGenericFactory.h"
#include "gfxImageFrame.h"
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceWin)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableRegion)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
PRBool
UseAFunctions()
{
#ifndef WINCE
static PRBool useAFunctions = PR_FALSE;
static PRBool init = PR_FALSE;
if (!init) {
init = 1;
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(os);
::GetVersionEx(&os);
if ((os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
(os.dwMajorVersion == 4) &&
(os.dwMinorVersion == 0) && // Windows 95 (not 98)
(::GetACP() == 932)) { // Shift-JIS (Japanese)
useAFunctions = 1;
}
}
return useAFunctions;
#else
return PR_FALSE;
#endif
}
static NS_IMETHODIMP
nsFontMetricsWinConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
*aResult = nsnull;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsFontMetricsWin* result;
if (UseAFunctions())
result = new nsFontMetricsWinA();
else
result = new nsFontMetricsWin();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
return rv;
}
static NS_IMETHODIMP
nsScriptableRegionConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
*aResult = nsnull;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsRegionWin* region = new nsRegionWin();
if (! region)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(region);
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
nsScriptableRegion* result = new nsScriptableRegion(region);
if (result) {
NS_ADDREF(result);
rv = result->QueryInterface(aIID, aResult);
NS_RELEASE(result);
}
NS_RELEASE(region);
return rv;
}
static const nsModuleComponentInfo components[] =
{
{ "nsFontMetricsWin",
NS_FONT_METRICS_CID,
"@mozilla.org/gfx/fontmetrics;1",
nsFontMetricsWinConstructor },
{ "nsDeviceContextWin",
NS_DEVICE_CONTEXT_CID,
"@mozilla.org/gfx/devicecontext;1",
nsDeviceContextWinConstructor },
{ "nsRenderingContextWin",
NS_RENDERING_CONTEXT_CID,
"@mozilla.org/gfx/renderingcontext;1",
nsRenderingContextWinConstructor },
{ "nsImageWin",
NS_IMAGE_CID,
"@mozilla.org/gfx/image;1",
nsImageWinConstructor },
{ "nsRegionWin",
NS_REGION_CID,
"@mozilla.org/gfx/unscriptable-region;1",
nsRegionWinConstructor },
{ "nsBlender",
NS_BLENDER_CID,
"@mozilla.org/gfx/blender;1",
nsBlenderConstructor },
{ "nsDrawingSurfaceWin",
NS_DRAWING_SURFACE_CID,
"@mozilla.org/gfx/drawing-surface;1",
nsDrawingSurfaceWinConstructor },
{ "nsScriptableRegion",
NS_SCRIPTABLE_REGION_CID,
"@mozilla.org/gfx/region;1",
nsScriptableRegionConstructor },
{ "nsFontEnumeratorWin",
NS_FONT_ENUMERATOR_CID,
"@mozilla.org/gfx/fontenumerator;1",
nsFontEnumeratorWinConstructor },
{ "windows image frame",
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",
gfxImageFrameConstructor, },
};
NS_IMPL_NSGETMODULE(nsGfxModule, components)

Просмотреть файл

@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDrawingSurfaceWin_h___
#define nsIDrawingSurfaceWin_h___
#include "nsIDrawingSurface.h"
#include <windows.h>
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_WIN_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceWin : public nsISupports
{
public:
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(HDC aDC) = 0;
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(HDC aDC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags) = 0;
/**
* Get a windows DC that represents the drawing surface.
* GetDC() must be paired with ReleaseDC(). Getting a DC
* and Lock()ing are mutually exclusive operations.
* @param aDC out parameter for HDC
* @return error status
**/
NS_IMETHOD GetDC(HDC *aDC) = 0;
/**
* Release a windows DC obtained by GetDC().
* ReleaseDC() must be preceded by a call to ReleaseDC().
* @return error status
**/
NS_IMETHOD ReleaseDC(void) = 0;
/**
* If ReleaseDC() truly destroys the state in the DC
* this will return PR_TRUE.
* @param aDestructive out parameter for destructiveness
* @return error status
**/
NS_IMETHOD IsReleaseDCDestructive(PRBool *aDestructive) = 0;
};
#endif // nsIDrawingSurfaceWin_h___

Просмотреть файл

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIRenderingContextWin_h___
#define nsIRenderingContextWin_h___
#include "nsIRenderingContext.h"
#include <windows.h>
// IID for the nsIRenderingContext interface
#define NS_IRENDERING_CONTEXT_WIN_IID \
{ 0x0fcde820, 0x8ae2, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
// RenderingContextWin interface
class nsIRenderingContextWin : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRENDERING_CONTEXT_WIN_IID)
/**
* Create a new drawing surface to represent an HDC.
* @param aDC Windows HDC.
* @param aSurface out parameter for new drawing surface
* @result error status
*/
NS_IMETHOD CreateDrawingSurface(HDC aDC, nsIDrawingSurface* &aSurface) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRenderingContextWin,
NS_IRENDERING_CONTEXT_WIN_IID)
#endif /* nsIRenderingContextWin_h___ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,298 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsImageWin_h___
#define nsImageWin_h___
#include <windows.h>
#include "nsIImage.h"
#include "nsCOMPtr.h"
#include "nsITimer.h"
// Remove DDB after 60s of non-use
#define GFX_MS_REMOVE_DBB 60000
/* for compatibility with VC++ 5 */
#if !defined(AC_SRC_OVER)
#define AC_SRC_OVER 0x00
#define AC_SRC_ALPHA 0x01
#pragma pack(1)
typedef struct {
BYTE BlendOp;
BYTE BlendFlags;
BYTE SourceConstantAlpha;
BYTE AlphaFormat;
}BLENDFUNCTION;
#pragma pack()
#endif
typedef BOOL (WINAPI *ALPHABLENDPROC)(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
BLENDFUNCTION blendFunction);
/* For gOsMajorVersion */
#define VER_OSMAJOR_WINNT31 3
#define VER_OSMAJOR_WIN9598MENT 4
#define VER_OSMAJOR_WIN2KXP 5
class nsImageWin : public nsIImage{
public:
nsImageWin();
~nsImageWin();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight() { return mBHead->biHeight; }
virtual PRBool GetIsRowOrderTopToBottom() { return PR_FALSE; }
virtual PRInt32 GetWidth() { return mBHead->biWidth; }
virtual PRUint8* GetBits() ;
virtual PRInt32 GetLineStride() { return mRowBytes; }
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, PRInt32 aSX, PRInt32 aSY,
PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight);
virtual nsColorMap* GetColorMap() {return mColorMap;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual PRBool GetIsImageComplete();
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
virtual PRInt32 GetAlphaLineStride(){ return mARowBytes; }
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsIDrawingSurface* aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
PRInt32 aPadX, PRInt32 aPadY,
const nsRect &aTileRect);
/**
* Return the header size of the Device Independent Bitmap(DIB).
* @return size of header in bytes
*/
PRIntn GetSizeHeader(){return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * mNumPaletteColors;}
/**
* Return the image size of the Device Independent Bitmap(DIB).
* @update dc - 10/29/98
* @return size of image in bytes
*/
PRIntn GetSizeImage(){ return mSizeImage; }
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
/**
* Get the alpha depth for the image mask
* @update - lordpixel 2001/05/16
* @return the alpha mask depth for the image, ie, 0, 1 or 8
*/
virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);}
/**
* Get the DIB specific informations for this bitmap.
* @update dc - 10/29/98
* @return VOID
*/
void* GetBitInfo() {return mBHead;}
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
// VER_PLATFORM_WIN32_WINDOWS == Win 95/98/ME
// VER_PLATFORM_WIN32_NT == Win NT/2K/XP/.NET Server
static PRInt32 gPlatform;
static PRInt32 gOsMajorVersion;
/** Create a DDB out of the imagebits, and destroy the imagebits
*/
NS_IMETHOD CreateDDB();
/** Removes the DBB, restoring the imagebits if necessary
*/
NS_IMETHOD RemoveDDB();
private:
/**
* Clean the device Independent bits that could be allocated by this object.
* @update dc - 04/05/00
*/
void CleanUpDIB();
/**
* Clean the device dependent bits that could be allocated by this object.
* @update dc - 04/05/00
*/
void CleanUpDDB();
void CreateImageWithAlphaBits(HDC TheHDC);
void DrawComposited24(unsigned char *aBits,
PRUint8 *aImageRGB, PRUint32 aStrideRGB,
PRUint8 *aImageAlpha, PRUint32 aStrideAlpha,
int aWidth, int aHeight);
nsresult DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int aDHeight,
int aSX, int aSY, int aSWidth, int aSHeight,
int aOrigDWidth, int aOrigDHeight);
static PRBool CanAlphaBlend(void);
/**
* Recreate a device independent image from a device dependent image (DDB)
* Does not remove the DDB
*/
nsresult ConvertDDBtoDIB();
/**
* Print a DDB
* @update dc - 05/20/99
* @param aSurface - The drawingsurface to create the DIB from.
* @param aDX - x location to place image
* @param aDY - y location to place image
* @param aDWidth - width of DIB
* @param aDHeight - height of DIB
* @param aSX - x location of rect to use
* @param aSY - y location to rect to use (in bitmap, not image, so
"upside down" from Mozilla's coordinates)
* @param aSWidth - width of rect to use
* @param aSHeight - height of rect to use
*/
nsresult PrintDDB(nsIDrawingSurface* aSurface,
PRInt32 aDX, PRInt32 aDY,
PRInt32 aDWidth, PRInt32 aDHeight,
PRInt32 aSX, PRInt32 aSY,
PRInt32 aSWidth, PRInt32 aSHeight,
PRUint32 aROP);
/**
* Progressively double the bitmap size as we blit.. very fast way to tile
* @return if TRUE, no errors
*/
PRBool ProgressiveDoubleBlit(nsIDeviceContext *aContext,
nsIDrawingSurface* aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
nsRect aDestRect);
/**
* Draw Image and Mask (if one exists) to another set of DCs
* @param aDstDC Where aSrcDC will be drawn to
* @param aDstMaskDC Where aMaskDC will be drawn to. If same as aDstDC and
there's a aSrcMaskDC, blending occurs.
* @param aDstX x-pos of where to start drawing to
* @param aDstY y-pos of where to start drawing to
* @param aWidth Width to copy from src to dst
* @param aHeight Height to copy from src to dst
* @param aSrcDC Source Image
* @param aSrcMaskDC Source Mask. If nsnull, aDstMaskDC will be ignored
* @param aSrcX copy src starting at this x position
* @param aSrcY copy src starting at this y position
* @param aUseAlphaBlend When True, aDstSrc is a 32-bit DC storing alpha
information in the 4th byte, so use AlphaBlend API
instead of BitBlt.
When False, BitBlt is used.
*/
void BlitImage(HDC aDstDC, HDC aDstMaskDC, PRInt32 aDstX, PRInt32 aDstY,
PRInt32 aWidth, PRInt32 aHeight,
HDC aSrcDC, HDC aSrcMaskDC, PRInt32 aSrcX, PRInt32 aSrcY,
PRBool aUseAlphaBlend);
/**
* Get an index in the palette that matches as closly as possible the passed in RGB colors
* @update dc - 4/20/2000
* @param aR - Red component of the color to match
* @param aG - Green component of the color to match
* @param aB - Blue component of the color to match
* @return - The closest palette match
*/
PRUint8 PaletteMatch(PRUint8 r, PRUint8 g, PRUint8 b);
PRPackedBool mInitialized;
PRPackedBool mWantsOptimization;
PRPackedBool mIsOptimized; // Did we convert our DIB to a HBITMAP
PRPackedBool mIsLocked; // variable to keep track of the locking
PRPackedBool mDIBTemp; // boolean to let us know if DIB was created as temp
PRPackedBool mImagePreMultiplied;// Are the image bits pre-multiplied with alpha?
PRInt8 mNumBytesPixel; // number of bytes per pixel
PRInt16 mNumPaletteColors; // Number of colors in the pallete 256
PRInt32 mSizeImage; // number of bytes
PRInt32 mRowBytes; // number of bytes per row
PRUint8* mImageBits; // starting address of DIB bits
nsColorMap* mColorMap; // Redundant with mColorTable, but necessary
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
// alpha layer members
PRUint8 *mAlphaBits; // alpha layer if we made one
PRInt8 mAlphaDepth; // alpha layer depth
PRInt32 mARowBytes; // number of bytes per row in the image for tha alpha
PRInt8 mImageCache; // place to save off the old image for fast animation
HBITMAP mHBitmap; // the GDI bitmaps
LPBITMAPINFOHEADER mBHead; // BITMAPINFOHEADER
static ALPHABLENDPROC gAlphaBlend; // AlphaBlend function pointer
nsCOMPtr<nsITimer> mTimer; // Timer for releasing DDB
static void TimerCallBack(nsITimer *aTimer, void *aClosure);
};
#endif

Просмотреть файл

@ -1,323 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsRegionWin.h"
#include "prmem.h"
nsRegionWin :: nsRegionWin()
{
mRegion = NULL;
mRegionType = NULLREGION;
mData = NULL;
mDataSize = 0;
}
nsRegionWin :: ~nsRegionWin()
{
if (NULL != mRegion)
{
::DeleteObject(mRegion);
mRegion = NULL;
}
if (NULL != mData)
{
PR_Free(mData);
mData = NULL;
mDataSize = 0;
}
}
NS_IMPL_ISUPPORTS1(nsRegionWin, nsIRegion)
nsresult nsRegionWin :: Init(void)
{
if (NULL != mRegion) {
::SetRectRgn(mRegion, 0, 0, 0, 0);
FreeRects(nsnull);
}
else {
mRegion = ::CreateRectRgn(0, 0, 0, 0);
}
mRegionType = NULLREGION;
return NS_OK;
}
void nsRegionWin :: SetTo(const nsIRegion &aRegion)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
mRegionType = ::CombineRgn(mRegion, pRegion->mRegion, NULL, RGN_COPY);
}
void nsRegionWin :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
if (NULL != mRegion)
::SetRectRgn(mRegion, aX, aY, aX + aWidth, aY + aHeight);
else
mRegion = ::CreateRectRgn(aX, aY, aX + aWidth, aY + aHeight);
if ((aWidth == 0) || (aHeight == 0))
mRegionType = NULLREGION;
else
mRegionType = SIMPLEREGION;
}
void nsRegionWin :: Intersect(const nsIRegion &aRegion)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
mRegionType = ::CombineRgn(mRegion, mRegion, pRegion->mRegion, RGN_AND);
}
void nsRegionWin :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
HRGN tRegion;
tRegion = ::CreateRectRgn(aX, aY, aX + aWidth, aY + aHeight);
mRegionType = ::CombineRgn(mRegion, mRegion, tRegion, RGN_AND);
::DeleteObject(tRegion);
}
void nsRegionWin :: Union(const nsIRegion &aRegion)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
mRegionType = ::CombineRgn(mRegion, mRegion, pRegion->mRegion, RGN_OR);
}
void nsRegionWin :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
HRGN tRegion;
tRegion = ::CreateRectRgn(aX, aY, aX + aWidth, aY + aHeight);
mRegionType = ::CombineRgn(mRegion, mRegion, tRegion, RGN_OR);
::DeleteObject(tRegion);
}
void nsRegionWin :: Subtract(const nsIRegion &aRegion)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
mRegionType = ::CombineRgn(mRegion, mRegion, pRegion->mRegion, RGN_DIFF);
}
void nsRegionWin :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
HRGN tRegion;
tRegion = ::CreateRectRgn(aX, aY, aX + aWidth, aY + aHeight);
mRegionType = ::CombineRgn(mRegion, mRegion, tRegion, RGN_DIFF);
::DeleteObject(tRegion);
}
PRBool nsRegionWin :: IsEmpty(void)
{
return (mRegionType == NULLREGION) ? PR_TRUE : PR_FALSE;
}
PRBool nsRegionWin :: IsEqual(const nsIRegion &aRegion)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
return ::EqualRgn(mRegion, pRegion->mRegion) ? PR_TRUE : PR_FALSE;
}
void nsRegionWin :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
RECT bounds;
if (mRegionType != NULLREGION)
{
::GetRgnBox(mRegion, &bounds);
*aX = bounds.left;
*aY = bounds.top;
*aWidth = bounds.right - bounds.left;
*aHeight = bounds.bottom - bounds.top;
}
else
*aX = *aY = *aWidth = *aHeight = 0;
}
void nsRegionWin :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
::OffsetRgn(mRegion, aXOffset, aYOffset);
}
PRBool nsRegionWin :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
RECT trect;
trect.left = aX;
trect.top = aY;
trect.right = aX + aWidth;
trect.bottom = aY + aHeight;
return ::RectInRegion(mRegion, &trect) ? PR_TRUE : PR_FALSE;
}
NS_IMETHODIMP nsRegionWin :: GetRects(nsRegionRectSet **aRects)
{
nsRegionRectSet *rects;
nsRegionRect *rect;
LPRECT pRects;
DWORD dwCount, dwResult;
unsigned int num_rects;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
rects = *aRects;
if (nsnull != rects)
rects->mNumRects = 0;
// code lifted from old winfe. MMP
/* Get the size of the region data */
dwCount = GetRegionData(mRegion, 0, NULL);
NS_ASSERTION(!(dwCount == 0), "bad region");
if (dwCount == 0)
return NS_OK;
if (dwCount > mDataSize)
{
if (NULL != mData)
PR_Free(mData);
mData = (LPRGNDATA)PR_Malloc(dwCount);
}
NS_ASSERTION(!(nsnull == mData), "failed allocation");
if (mData == NULL)
return NS_OK;
dwResult = GetRegionData(mRegion, dwCount, mData);
NS_ASSERTION(!(dwResult == 0), "get data failed");
if (dwResult == 0)
return NS_OK;
if ((nsnull == rects) || (rects->mRectsLen < mData->rdh.nCount))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (mData->rdh.nCount - 1)));
if (nsnull == buf)
{
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = mData->rdh.nCount;
}
rects->mNumRects = mData->rdh.nCount;
rects->mArea = 0;
rect = &rects->mRects[0];
for (pRects = (LPRECT)mData->Buffer, num_rects = 0;
num_rects < mData->rdh.nCount;
num_rects++, pRects++, rect++)
{
rect->x = pRects->left;
rect->y = pRects->top;
rect->width = pRects->right - rect->x;
rect->height = pRects->bottom - rect->y;
rects->mArea += rect->width * rect->height;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionWin :: FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects)
PR_Free((void *)aRects);
if (NULL != mData)
{
PR_Free(mData);
mData = NULL;
mDataSize = 0;
}
return NS_OK;
}
NS_IMETHODIMP nsRegionWin :: GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionWin :: GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
switch (mRegionType)
{
case NULLREGION:
aComplexity = eRegionComplexity_empty;
break;
case SIMPLEREGION:
aComplexity = eRegionComplexity_rect;
break;
default:
case COMPLEXREGION:
aComplexity = eRegionComplexity_complex;
break;
}
return NS_OK;
}

Просмотреть файл

@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRegionWin_h___
#define nsRegionWin_h___
#include "nsIRegion.h"
#include "windows.h"
class nsRegionWin : public nsIRegion
{
public:
nsRegionWin();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
private:
~nsRegionWin();
LPRGNDATA mData;
PRUint32 mDataSize;
public:
//public so the rendering context can poke these... shoot me. MMP
HRGN mRegion;
int mRegionType;
};
#endif // nsRegionWin_h___

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,297 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRenderingContextWin_h___
#define nsRenderingContextWin_h___
#include "nsIRenderingContext.h"
#include "nsFont.h"
#include "nsFontMetricsWin.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsImageWin.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsIRenderingContextWin.h"
#include "nsDrawingSurfaceWin.h"
#include "nsRenderingContextImpl.h"
class GraphicsState;
class nsDrawingSurfaceWin;
class nsRenderingContextWin : public nsRenderingContextImpl,
nsIRenderingContextWin
{
public:
nsRenderingContextWin();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIDrawingSurface* aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsIDrawingSurface* aSurface);
NS_IMETHOD GetDrawingSurface(nsIDrawingSurface* *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(void);
void* GetNativeGraphicData(GraphicDataType aType);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aClipState);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipState);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsIDrawingSurface* &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsIDrawingSurface* aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD SetPenMode(nsPenMode aPenMode);
NS_IMETHOD GetPenMode(nsPenMode &aPenMode);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull)
{ return nsRenderingContextImpl::GetWidth(aString, aWidth, aFontID); }
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth)
{ return nsRenderingContextImpl::GetWidth(aString, aWidth); }
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth)
{ return nsRenderingContextImpl::GetWidth(aString, aLength, aWidth); }
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull)
{ return nsRenderingContextImpl::GetWidth(aString, aLength, aWidth, aFontID); }
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull)
{ return nsRenderingContextImpl::DrawString(aString, aX, aY, aFontID, aSpacing); }
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidthInternal(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidthInternal(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawStringInternal(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing);
NS_IMETHOD DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD GetTextDimensionsInternal(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions);
NS_IMETHOD GetTextDimensionsInternal(const PRUnichar *aString, PRUint32 aLength,
nsTextDimensions& aDimensions,PRInt32 *aFontID);
NS_IMETHOD GetTextDimensionsInternal(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
NS_IMETHOD GetTextDimensionsInternal(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
NS_IMETHOD GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/**
* Returns metrics (in app units) of a Unicode character string
*/
NS_IMETHOD GetBoundingMetricsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
virtual PRInt32 GetMaxStringLength();
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
// nsIRenderingContextWin
NS_IMETHOD CreateDrawingSurface(HDC aDC, nsIDrawingSurface* &aSurface);
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
protected:
void SetupFontAndColor(void);
~nsRenderingContextWin();
private:
// ConditionRect is used to fix a coordinate overflow problem under WIN95.
void ConditionRect(nsRect& aSrcRect, RECT& aDestRect);
nsresult CommonInit(void);
nsresult SetupDC(HDC aOldDC, HDC aNewDC);
HBRUSH SetupSolidBrush(void);
HPEN SetupPen(void);
HPEN SetupSolidPen(void);
HPEN SetupDashedPen(void);
HPEN SetupDottedPen(void);
void PushClipState(void);
void InitBidiInfo(void);
friend class nsNativeThemeWin;
protected:
nscolor mCurrentColor;
// current font-metrics set in this RC
nsIFontMetrics *mFontMetrics;
HDC mDC;
HDC mMainDC;
nsDrawingSurfaceWin *mSurface;
nsDrawingSurfaceWin *mMainSurface;
COLORREF mColor;
nsIWidget *mDCOwner;
// int mOldMapMode;
nsIDeviceContext *mContext;
float mP2T;
HRGN mClipRegion;
//default objects
HBRUSH mOrigSolidBrush;
HFONT mOrigFont;
HPEN mOrigSolidPen;
HPALETTE mOrigPalette;
//state management
GraphicsState *mStates;
nsVoidArray *mStateCache;
nscolor mCurrBrushColor;
HBRUSH mCurrBrush;
// mFontMetrics owns mCurrFontWin which is a thin wrapper
// around mCurrFont (the actual GDI font handle). These variables
// allow us to quickly tell the current selected font and to
// avoid the extra cost of a redundant setup of the same font.
nsFontWin *mCurrFontWin;
HFONT mCurrFont;
nscolor mCurrPenColor;
HPEN mCurrPen;
HPEN mNullPen;
PRUint8 *mGammaTable;
nscolor mCurrTextColor;
nsLineStyle mCurrLineStyle;
#ifdef NS_DEBUG
PRPackedBool mInitialized;
#endif
PRPackedBool mRightToLeftText;
};
#endif /* nsRenderingContextWin_h___ */

Просмотреть файл

@ -1,452 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsUnicodeRange.h"
// This table depends on unicode range definitions.
// Each item's index must correspond unicode range value
// eg. x-cyrillic = LangGroupTable[kRangeCyrillic]
const char *gUnicodeRangeToLangGroupTable[] =
{
"x-cyrillic",
"el",
"tr",
"he",
"ar",
"x-baltic",
"th",
"ko",
"ja",
"zh-CN",
"zh-TW",
"x-devanagari",
"x-tamil",
"x-armn",
"x-beng",
"x-cans",
"x-ethi",
"x-geor",
"x-gujr",
"x-guru",
"x-khmr",
"x-mlym"
};
/**********************************************************************
* Unicode subranges as defined in unicode 3.0
* x-western, x-central-euro, tr, x-baltic -> latin
* 0000 - 036f
* 1e00 - 1eff
* 2000 - 206f (general punctuation)
* 20a0 - 20cf (currency symbols)
* 2100 - 214f (letterlike symbols)
* 2150 - 218f (Number Forms)
* el -> greek
* 0370 - 03ff
* 1f00 - 1fff
* x-cyrillic -> cyrillic
* 0400 - 04ff
* he -> hebrew
* 0590 - 05ff
* ar -> arabic
* 0600 - 06ff
* fb50 - fdff (arabic presentation forms)
* fe70 - feff (arabic presentation forms b)
* th - thai
* 0e00 - 0e7f
* ko -> korean
* ac00 - d7af (hangul Syllables)
* 1100 - 11ff (jamo)
* 3130 - 318f (hangul compatibility jamo)
* ja
* 3040 - 309f (hiragana)
* 30a0 - 30ff (katakana)
* zh-CN
* zh-TW
*
* CJK
* 3100 - 312f (bopomofo)
* 31a0 - 31bf (bopomofo extended)
* 3000 - 303f (CJK Symbols and Punctuation)
* 2e80 - 2eff (CJK radicals supplement)
* 2f00 - 2fdf (Kangxi Radicals)
* 2ff0 - 2fff (Ideographic Description Characters)
* 3190 - 319f (kanbun)
* 3200 - 32ff (Enclosed CJK letters and Months)
* 3300 - 33ff (CJK compatibility)
* 3400 - 4dbf (CJK Unified Ideographs Extension A)
* 4e00 - 9faf (CJK Unified Ideographs)
* f900 - fa5f (CJK Compatibility Ideographs)
* fe30 - fe4f (CJK compatibility Forms)
* ff00 - ffef (halfwidth and fullwidth forms)
*
* Armenian
* 0530 - 058f
* Sriac
* 0700 - 074f
* Thaana
* 0780 - 07bf
* Devanagari
* 0900 - 097f
* Bengali
* 0980 - 09ff
* Gurmukhi
* 0a00 - 0a7f
* Gujarati
* 0a80 - 0aff
* Oriya
* 0b00 - 0b7f
* Tamil
* 0b80 - 0bff
* Telugu
* 0c00 - 0c7f
* Kannada
* 0c80 - 0cff
* Malayalam
* 0d00 - 0d7f
* Sinhala
* 0d80 - 0def
* Lao
* 0e80 - 0eff
* Tibetan
* 0f00 - 0fbf
* Myanmar
* 1000 - 109f
* Georgian
* 10a0 - 10ff
* Ethiopic
* 1200 - 137f
* Cherokee
* 13a0 - 13ff
* Canadian Aboriginal Syllabics
* 1400 - 167f
* Ogham
* 1680 - 169f
* Runic
* 16a0 - 16ff
* Khmer
* 1780 - 17ff
* Mongolian
* 1800 - 18af
* Misc - superscripts and subscripts
* 2070 - 209f
* Misc - Combining Diacritical Marks for Symbols
* 20d0 - 20ff
* Misc - Arrows
* 2190 - 21ff
* Misc - Mathematical Operators
* 2200 - 22ff
* Misc - Miscellaneous Technical
* 2300 - 23ff
* Misc - Control picture
* 2400 - 243f
* Misc - Optical character recognition
* 2440 - 2450
* Misc - Enclose Alphanumerics
* 2460 - 24ff
* Misc - Box Drawing
* 2500 - 257f
* Misc - Block Elements
* 2580 - 259f
* Misc - Geometric Shapes
* 25a0 - 25ff
* Misc - Miscellaneous Symbols
* 2600 - 267f
* Misc - Dingbats
* 2700 - 27bf
* Misc - Braille Patterns
* 2800 - 28ff
* Yi Syllables
* a000 - a48f
* Yi radicals
* a490 - a4cf
* Alphabetic Presentation Forms
* fb00 - fb4f
* Misc - Combining half Marks
* fe20 - fe2f
* Misc - small form variants
* fe50 - fe6f
* Misc - Specials
* fff0 - ffff
*********************************************************************/
#define NUM_OF_SUBTABLES 9
#define SUBTABLE_SIZE 16
static PRUint8 gUnicodeSubrangeTable[NUM_OF_SUBTABLES][SUBTABLE_SIZE] =
{
{ // table for X---
kRangeTableBase+1, //u0xxx
kRangeTableBase+2, //u1xxx
kRangeTableBase+3, //u2xxx
kRangeSetCJK, //u3xxx
kRangeSetCJK, //u4xxx
kRangeSetCJK, //u5xxx
kRangeSetCJK, //u6xxx
kRangeSetCJK, //u7xxx
kRangeSetCJK, //u8xxx
kRangeSetCJK, //u9xxx
kRangeTableBase+4, //uaxxx
kRangeKorean, //ubxxx
kRangeKorean, //ucxxx
kRangeTableBase+5, //udxxx
kRangePrivate, //uexxx
kRangeTableBase+6 //ufxxx
},
{ //table for 0X--
kRangeSetLatin, //u00xx
kRangeSetLatin, //u01xx
kRangeSetLatin, //u02xx
kRangeGreek, //u03xx XXX 0300-036f is in fact kRangeCombiningDiacriticalMarks
kRangeCyrillic, //u04xx
kRangeTableBase+7, //u05xx, includes Cyrillic supplement, Hebrew, and Armenian
kRangeArabic, //u06xx
kRangeTertiaryTable, //u07xx
kRangeUnassigned, //u08xx
kRangeTertiaryTable, //u09xx
kRangeTertiaryTable, //u0axx
kRangeTertiaryTable, //u0bxx
kRangeTertiaryTable, //u0cxx
kRangeTertiaryTable, //u0dxx
kRangeTertiaryTable, //u0exx
kRangeTibetan, //u0fxx
},
{ //table for 1x--
kRangeTertiaryTable, //u10xx
kRangeKorean, //u11xx
kRangeEthiopic, //u12xx
kRangeTertiaryTable, //u13xx
kRangeCanadian, //u14xx
kRangeCanadian, //u15xx
kRangeTertiaryTable, //u16xx
kRangeKhmer, //u17xx
kRangeMongolian, //u18xx
kRangeUnassigned, //u19xx
kRangeUnassigned, //u1axx
kRangeUnassigned, //u1bxx
kRangeUnassigned, //u1cxx
kRangeUnassigned, //u1dxx
kRangeSetLatin, //u1exx
kRangeGreek, //u1fxx
},
{ //table for 2x--
kRangeSetLatin, //u20xx
kRangeSetLatin, //u21xx
kRangeMathOperators, //u22xx
kRangeMiscTechnical, //u23xx
kRangeControlOpticalEnclose, //u24xx
kRangeBoxBlockGeometrics, //u25xx
kRangeMiscSymbols, //u26xx
kRangeDingbats, //u27xx
kRangeBraillePattern, //u28xx
kRangeUnassigned, //u29xx
kRangeUnassigned, //u2axx
kRangeUnassigned, //u2bxx
kRangeUnassigned, //u2cxx
kRangeUnassigned, //u2dxx
kRangeSetCJK, //u2exx
kRangeSetCJK, //u2fxx
},
{ //table for ax--
kRangeYi, //ua0xx
kRangeYi, //ua1xx
kRangeYi, //ua2xx
kRangeYi, //ua3xx
kRangeYi, //ua4xx
kRangeUnassigned, //ua5xx
kRangeUnassigned, //ua6xx
kRangeUnassigned, //ua7xx
kRangeUnassigned, //ua8xx
kRangeUnassigned, //ua9xx
kRangeUnassigned, //uaaxx
kRangeUnassigned, //uabxx
kRangeKorean, //uacxx
kRangeKorean, //uadxx
kRangeKorean, //uaexx
kRangeKorean, //uafxx
},
{ //table for dx--
kRangeKorean, //ud0xx
kRangeKorean, //ud1xx
kRangeKorean, //ud2xx
kRangeKorean, //ud3xx
kRangeKorean, //ud4xx
kRangeKorean, //ud5xx
kRangeKorean, //ud6xx
kRangeKorean, //ud7xx
kRangeSurrogate, //ud8xx
kRangeSurrogate, //ud9xx
kRangeSurrogate, //udaxx
kRangeSurrogate, //udbxx
kRangeSurrogate, //udcxx
kRangeSurrogate, //uddxx
kRangeSurrogate, //udexx
kRangeSurrogate, //udfxx
},
{ // table for fx--
kRangePrivate, //uf0xx
kRangePrivate, //uf1xx
kRangePrivate, //uf2xx
kRangePrivate, //uf3xx
kRangePrivate, //uf4xx
kRangePrivate, //uf5xx
kRangePrivate, //uf6xx
kRangePrivate, //uf7xx
kRangePrivate, //uf8xx
kRangeSetCJK, //uf9xx
kRangeSetCJK, //ufaxx
kRangeArabic, //ufbxx, includes alphabic presentation form
kRangeArabic, //ufcxx
kRangeArabic, //ufdxx
kRangeArabic, //ufexx, includes Combining half marks,
// CJK compatibility forms,
// CJK compatibility forms,
// small form variants
kRangeTableBase+8, //uffxx, halfwidth and fullwidth forms, includes Specials
},
{ //table for 0x0500 - 0x05ff
kRangeCyrillic, //u050x
kRangeCyrillic, //u051x
kRangeCyrillic, //u052x
kRangeArmenian, //u053x
kRangeArmenian, //u054x
kRangeArmenian, //u055x
kRangeArmenian, //u056x
kRangeArmenian, //u057x
kRangeArmenian, //u058x
kRangeHebrew, //u059x
kRangeHebrew, //u05ax
kRangeHebrew, //u05bx
kRangeHebrew, //u05cx
kRangeHebrew, //u05dx
kRangeHebrew, //u05ex
kRangeHebrew, //u05fx
},
{ //table for 0xff00 - 0xffff
kRangeSetCJK, //uff0x, fullwidth latin
kRangeSetCJK, //uff1x, fullwidth latin
kRangeSetCJK, //uff2x, fullwidth latin
kRangeSetCJK, //uff3x, fullwidth latin
kRangeSetCJK, //uff4x, fullwidth latin
kRangeSetCJK, //uff5x, fullwidth latin
kRangeSetCJK, //uff6x, halfwidth katakana
kRangeSetCJK, //uff7x, halfwidth katakana
kRangeSetCJK, //uff8x, halfwidth katakana
kRangeSetCJK, //uff9x, halfwidth katakana
kRangeSetCJK, //uffax, halfwidth hangul jamo
kRangeSetCJK, //uffbx, halfwidth hangul jamo
kRangeSetCJK, //uffcx, halfwidth hangul jamo
kRangeSetCJK, //uffdx, halfwidth hangul jamo
kRangeSetCJK, //uffex, fullwidth symbols
kRangeSpecials, //ufffx, Specials
},
};
// Most scripts between U+0700 and U+16FF are assigned a chunk of 128 (0x80)
// code points so that the number of entries in the tertiary range
// table for that range is obtained by dividing (0x1700 - 0x0700) by 128.
// Exceptions: Ethiopic, Tibetan, Hangul Jamo and Canadian aboriginal
// syllabaries take multiple chunks and Ogham and Runic share a single chunk.
#define TERTIARY_TABLE_SIZE ((0x1700 - 0x0700) / 0x80)
static PRUint8 gUnicodeTertiaryRangeTable[TERTIARY_TABLE_SIZE] =
{ //table for 0x0700 - 0x1600
kRangeSyriac, //u070x
kRangeThaana, //u078x
kRangeUnassigned, //u080x place holder(resolved in the 2ndary tab.)
kRangeUnassigned, //u088x place holder(resolved in the 2ndary tab.)
kRangeDevanagari, //u090x
kRangeBengali, //u098x
kRangeGurmukhi, //u0a0x
kRangeGujarati, //u0a8x
kRangeOriya, //u0b0x
kRangeTamil, //u0b8x
kRangeTelugu, //u0c0x
kRangeKannada, //u0c8x
kRangeMalayalam, //u0d0x
kRangeSinhala, //u0d8x
kRangeThai, //u0e0x
kRangeLao, //u0e8x
kRangeTibetan, //u0f0x place holder(resolved in the 2ndary tab.)
kRangeTibetan, //u0f8x place holder(resolved in the 2ndary tab.)
kRangeMyanmar, //u100x
kRangeGeorgian, //u108x
kRangeKorean, //u110x place holder(resolved in the 2ndary tab.)
kRangeKorean, //u118x place holder(resolved in the 2ndary tab.)
kRangeEthiopic, //u120x place holder(resolved in the 2ndary tab.)
kRangeEthiopic, //u128x place holder(resolved in the 2ndary tab.)
kRangeEthiopic, //u130x
kRangeCherokee, //u138x
kRangeCanadian, //u140x place holder(resolved in the 2ndary tab.)
kRangeCanadian, //u148x place holder(resolved in the 2ndary tab.)
kRangeCanadian, //u150x place holder(resolved in the 2ndary tab.)
kRangeCanadian, //u158x place holder(resolved in the 2ndary tab.)
kRangeCanadian, //u160x
kRangeOghamRunic, //u168x this contains two scripts, Ogham & Runic
};
// A two level index is almost enough for locating a range, with the
// exception of u03xx and u05xx. Since we don't really care about range for
// combining diacritical marks in our font application, they are
// not discriminated further. But future adoption of this module for other use
// should be aware of this limitation. The implementation can be extended if
// there is such a need.
// For Indic, Southeast Asian scripts and some other scripts between
// U+0700 and U+16FF, it's extended to the third level.
PRUint32 FindCharUnicodeRange(PRUnichar ch)
{
PRUint32 range;
//search the first table
range = gUnicodeSubrangeTable[0][ch >> 12];
if (range < kRangeTableBase)
// we try to get a specific range
return range;
// otherwise, we have one more table to look at
range = gUnicodeSubrangeTable[range - kRangeTableBase][(ch & 0x0f00) >> 8];
if (range < kRangeTableBase)
return range;
if (range < kRangeTertiaryTable)
return gUnicodeSubrangeTable[range - kRangeTableBase][(ch & 0x00f0) >> 4];
// Yet another table to look at : U+0700 - U+16FF : 128 code point blocks
return gUnicodeTertiaryRangeTable[(ch - 0x0700) >> 7];
}

Просмотреть файл

@ -1,122 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
// The following constants define unicode subranges
// values below kRangeNum must be continuous so that we can map to
// lang group directly.
// all ranges we care about should be defined under 32, that allows
// us to store range using bits of a PRUint32
// frequently used range definitions
const PRUint8 kRangeCyrillic = 0;
const PRUint8 kRangeGreek = 1;
const PRUint8 kRangeTurkish = 2;
const PRUint8 kRangeHebrew = 3;
const PRUint8 kRangeArabic = 4;
const PRUint8 kRangeBaltic = 5;
const PRUint8 kRangeThai = 6;
const PRUint8 kRangeKorean = 7;
const PRUint8 kRangeJapanese = 8;
const PRUint8 kRangeSChinese = 9;
const PRUint8 kRangeTChinese = 10;
const PRUint8 kRangeDevanagari = 11;
const PRUint8 kRangeTamil = 12;
const PRUint8 kRangeArmenian = 13;
const PRUint8 kRangeBengali = 14;
const PRUint8 kRangeCanadian = 15;
const PRUint8 kRangeEthiopic = 16;
const PRUint8 kRangeGeorgian = 17;
const PRUint8 kRangeGujarati = 18;
const PRUint8 kRangeGurmukhi = 19;
const PRUint8 kRangeKhmer = 20;
const PRUint8 kRangeMalayalam = 21;
const PRUint8 kRangeSpecificItemNum = 22;
//range/rangeSet grow to this place 22-29
const PRUint8 kRangeSetStart = 30; // range set definition starts from here
const PRUint8 kRangeSetLatin = 30;
const PRUint8 kRangeSetCJK = 31;
const PRUint8 kRangeSetEnd = 31; // range set definition ends here
// less frequently used range definition
const PRUint8 kRangeSurrogate = 32;
const PRUint8 kRangePrivate = 33;
const PRUint8 kRangeMisc = 34;
const PRUint8 kRangeUnassigned = 35;
const PRUint8 kRangeSyriac = 36;
const PRUint8 kRangeThaana = 37;
const PRUint8 kRangeOriya = 38;
const PRUint8 kRangeTelugu = 39;
const PRUint8 kRangeKannada = 40;
const PRUint8 kRangeSinhala = 41;
const PRUint8 kRangeLao = 42;
const PRUint8 kRangeTibetan = 43;
const PRUint8 kRangeMyanmar = 44;
const PRUint8 kRangeCherokee = 45;
const PRUint8 kRangeOghamRunic = 46;
const PRUint8 kRangeMongolian = 47;
const PRUint8 kRangeMathOperators = 48;
const PRUint8 kRangeMiscTechnical = 49;
const PRUint8 kRangeControlOpticalEnclose = 50;
const PRUint8 kRangeBoxBlockGeometrics = 51;
const PRUint8 kRangeMiscSymbols = 52;
const PRUint8 kRangeDingbats = 53;
const PRUint8 kRangeBraillePattern = 54;
const PRUint8 kRangeYi = 55;
const PRUint8 kRangeCombiningDiacriticalMarks = 56;
const PRUint8 kRangeSpecials = 57;
const PRUint8 kRangeTableBase = 128; //values over 127 are reserved for internal use only
const PRUint8 kRangeTertiaryTable = 145; // leave room for 16 subtable
// indices (kRangeTableBase + 1 ..
// kRangeTableBase + 16)
extern PRUint32 FindCharUnicodeRange(PRUnichar ch);
extern const char* gUnicodeRangeToLangGroupTable[];
inline const char* LangGroupFromUnicodeRange(PRUint8 unicodeRange)
{
if (kRangeSpecificItemNum > unicodeRange)
return gUnicodeRangeToLangGroupTable[unicodeRange];
return nsnull;
}