Compare commits

...

31 Commits

Author SHA1 Message Date
relyea%netscape.com
396894467a UPdate the NSS tag for windows makefile as well as Unix and mac
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@133441 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-09 00:45:56 +00:00
relyea%netscape.com
4c54392306 Roll photon up to NSS_3_6_1
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@133418 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-08 22:04:45 +00:00
rogc%netscape.com
de951c4971 Back out extraneous Linux changes.
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@132970 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-05 00:34:38 +00:00
rogc%netscape.com
93ff9394e9 New x86 unix xptc stuff.
Added Files:
 Tag: PHT_2002_08_08_BRANCH
	xptcinvoke_gcc_x86_unix.cpp xptcstubs_gcc_x86_unix.cpp


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@132946 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-04 22:51:14 +00:00
rogc%netscape.com
fd56b31f29 Restore graphics port to its previous state after drawing.
Modified Files:
 Tag: PHT_2002_08_08_BRANCH
	nsGraphicState.cpp nsGraphicState.h nsRenderingContextMac.cpp
	nsRenderingContextMac.h


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@132932 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-04 17:48:33 +00:00
rogc%netscape.com
78c057ebe4 Port to Jaguar
Modified Files:
 Tag: PHT_2002_08_08_BRANCH
	configure configure.in config/config.mk config/rules.mk
	gfx/src/mac/nsImageMac.cpp gfx/src/mac/nsImageMac.h
	xpcom/reflect/xptcall/src/md/unix/Makefile.in
	xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_rhapsody.s
	xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc_rhapsody.cpp
	xpfe/bootstrap/Makefile.in
Added Files:
 Tag: PHT_2002_08_08_BRANCH
	xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_darwin.s.m4


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@132931 18797224-902f-48f8-a5cc-f745e15eee43
2002-11-04 17:44:43 +00:00
wtc%netscape.com
761b3aa141 Pull the NSS_3_6_BRANCH_20021026 stable snapshot. (Blackflag bug 612565)
Modified Files: client.mak client.mk
Tag: PHT_2002_08_08_BRANCH


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@132559 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-26 14:15:46 +00:00
wtc%netscape.com
cbea8fbd7b Blackflag bug 611840: pull NSPR_4_2_2_RELEASE and NSS_3_6_RTM.
Modified Files: client.mak client.mk
Tag: PHT_2002_08_08_BRANCH


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@131688 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-10 17:50:37 +00:00
rogc%netscape.com
7032064908 Remove dlfcnl.h on Mac OSX, take 2 (thanks to Anthony)
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@131602 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-09 19:00:36 +00:00
rogc%netscape.com
83d6510a3f We don't need this stuff, and it's breaking the build on Mac OSX.
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@131536 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-09 02:09:36 +00:00
rogc%netscape.com
5e83ba4cd0 Merge changes from the following mozilla bugs:
http://bugzilla.mozilla.org/show_bug.cgi?id=69566
    http://bugzilla.mozilla.org/show_bug.cgi?id=142855
    http://bugzilla.mozilla.org/show_bug.cgi?id=159842

To allow copying HTML from Windows apps and pasting into editor windows.

Modified Files:
 Tag: PHT_2002_08_08_BRANCH
	content/build/nsContentCID.h content/build/nsContentModule.cpp
	content/html/document/src/nsHTMLFragmentContentSink.cpp
	docshell/base/nsDocShell.cpp
	editor/libeditor/html/nsHTMLDataTransfer.cpp
	editor/libeditor/html/nsHTMLEditor.h
	htmlparser/public/nsIDTD.h
	htmlparser/public/nsIHTMLFragmentContentSink.h
	htmlparser/public/nsIParser.h htmlparser/src/CNavDTD.cpp
	htmlparser/src/nsParser.cpp layout/html/base/src/nsHTMLParts.h
	widget/public/nsITransferable.idl
	widget/src/windows/nsClipboard.cpp
	widget/src/windows/nsClipboard.h
	widget/src/windows/nsDataObj.cpp
	widget/src/xpwidgets/nsPrimitiveHelpers.cpp


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@131447 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-08 19:27:25 +00:00
ssaux%netscape.com
4d9b83bd3f ssaux for rogermw. Apply patch to bug 169784 to resolve the undo problem
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@130946 18797224-902f-48f8-a5cc-f745e15eee43
2002-10-02 00:22:33 +00:00
(no author)
0975fe1c47 This commit was manufactured by cvs2svn to create branch
'PHT_2002_08_08_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@130273 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-23 19:39:27 +00:00
wtc%netscape.com
d12bb50671 Use NSPR 4.2.2 RC1 and NSS 3.6 Beta1. Starting in NSS 3.6 Beta1, NSS
headers are installed in the 'nss' subdirectory instead of the 'security'
subdirectory.  (blackflag bug 610683)
Tag: PHT_2002_08_08_BRANCH


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@130013 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-19 04:58:27 +00:00
ddrinan%netscape.com
6d69dfb32b Remove pippki from embedding package
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@128997 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-06 21:11:06 +00:00
ddrinan%netscape.com
193a043ad0 Getting the Photon cert entrollment tool to work with gecko
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@128995 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-06 21:09:58 +00:00
ddrinan%netscape.com
4155243a0f Getting the Photon cert entrollment tool to work with gecko
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@128964 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-06 17:36:39 +00:00
rogc%netscape.com
68810eeece Hack by prohr@netscape.com to fix problem with menus and the alt
key in non-XUL embedding on Windows.


git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@128883 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-05 17:45:45 +00:00
ssaux%netscape.com
7aeb5d648e apply the page to bug 142513 to our branch for rogermw
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127503 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-16 23:01:19 +00:00
ssaux%netscape.com
6b07a8676e Make sure nss multi access db tag is used
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127267 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-14 17:40:45 +00:00
ssaux%netscape.com
d173f55b67 Use nss multiaccess tag
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127233 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-14 02:30:30 +00:00
ssaux%netscape.com
39f3f74455 Apply rogc branch changes to new branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127229 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-14 00:57:14 +00:00
ssaux%netscape.com
9907bf1656 Apply rogc branch changes to new branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127228 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-14 00:47:18 +00:00
ssaux%netscape.com
18c00c42ac Apply rogc branch changes to the new branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127227 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-14 00:22:21 +00:00
ssaux%netscape.com
96efee505a Use our branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127222 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 23:59:17 +00:00
ssaux%netscape.com
c396734d75 Use our branch insteadm of the 1_0 branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127218 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 23:56:09 +00:00
ssaux%netscape.com
6b21dd1530 restore 1_0 branch tip to ph branch
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127214 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 23:50:36 +00:00
ssaux%netscape.com
69750674fa merge from ROGC_20020430_BRANCH
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127187 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 18:41:59 +00:00
ssaux%netscape.com
c8639ebcf1 merge from ROGC_20020430_BRANCH
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127183 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 18:35:08 +00:00
ssaux%netscape.com
da800ddb85 merge from ROGC_20020430_BRANCH
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@127182 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-13 18:29:05 +00:00
(no author)
32d746a0c2 This commit was manufactured by cvs2svn to create branch
'PHT_2002_08_08_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@126572 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-07 01:18:31 +00:00
1358 changed files with 3050 additions and 373848 deletions

View File

@@ -0,0 +1,11 @@
prefix=%prefix%
exec_prefix=%exec_prefix%
libdir=%libdir%
includedir=%includedir%
Name: NSS
Description: Mozilla Network Security Services
Version: %MOZILLA_VERSION%
Requires: mozilla-nspr = %MOZILLA_VERSION%
Libs: -L${libdir} -lnss3 -lsmime3 -lssl3 -lsoftokn3
Cflags: -I${includedir}/nss

View File

@@ -40,14 +40,14 @@ MOZ_OBJDIR = WIN32_O.OBJ
#// Figure out how to do the pull.
#//------------------------------------------------------------------------
# uncomment these, modify branch tag, and check in to branch for milestones
MOZ_BRANCH=MOZILLA_1_0_BRANCH
NSPR_CO_TAG=MOZILLA_1_0_BRANCH
PSM_CO_TAG=MOZILLA_1_0_BRANCH
NSS_CO_TAG=MOZILLA_1_0_BRANCH
LDAPCSDK_CO_TAG=MOZILLA_1_0_BRANCH
ACCESSIBLE_CO_TAG=MOZILLA_1_0_BRANCH
IMGLIB2_CO_TAG=MOZILLA_1_0_BRANCH
GFX2_CO_TAG=MOZILLA_1_0_BRANCH
MOZ_BRANCH=PHT_2002_08_08_BRANCH
NSPR_CO_TAG=NSPR_4_2_2_RELEASE
PSM_CO_TAG=PHT_2002_08_08_BRANCH
NSS_CO_TAG=NSS_3_6_1_BETA1
LDAPCSDK_CO_TAG=PHT_2002_08_08_BRANCH
ACCESSIBLE_CO_TAG=PHT_2002_08_08_BRANCH
IMGLIB2_CO_TAG=PHT_2002_08_08_BRANCH
GFX2_CO_TAG=PHT_2002_08_08_BRANCH
!ifdef MOZ_BRANCH
@@ -99,8 +99,11 @@ CVSCO = cvs $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(CVS_BRANCH)
NSPR_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) $(CVS_BRANCH)
!if "$(NSPR_CO_TAG)" != ""
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) -r $(NSPR_CO_TAG)
!else
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) -r NSPRPUB_PRE_4_2_CLIENT_BRANCH
!endif
CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS)
@@ -113,7 +116,11 @@ CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS)
NSS_CO_FLAGS=$(MOZ_CO_FLAGS)
!endif
NSS_CO_FLAGS=$(NSS_CO_FLAGS) $(CVS_BRANCH)
!if "$(NSS_CO_TAG)" != ""
NSS_CO_FLAGS=$(NSS_CO_FLAGS) -r $(NSS_CO_TAG)
!else
NSS_CO_FLAGS=$(NSS_CO_FLAGS) -r NSS_CLIENT_TAG
!endif
CVSCO_NSS = cvs $(CVS_FLAGS) co $(NSS_CO_FLAGS)

View File

@@ -52,14 +52,14 @@
#
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
# and commit this file on that tag.
MOZ_CO_TAG = MOZILLA_1_0_BRANCH
NSPR_CO_TAG = MOZILLA_1_0_BRANCH
PSM_CO_TAG = MOZILLA_1_0_BRANCH
NSS_CO_TAG = MOZILLA_1_0_BRANCH
LDAPCSDK_CO_TAG = MOZILLA_1_0_BRANCH
ACCESSIBLE_CO_TAG = MOZILLA_1_0_BRANCH
GFX2_CO_TAG = MOZILLA_1_0_BRANCH
IMGLIB2_CO_TAG = MOZILLA_1_0_BRANCH
MOZ_CO_TAG = PHT_2002_08_08_BRANCH
NSPR_CO_TAG = NSPR_4_2_2_RELEASE
PSM_CO_TAG = PHT_2002_08_08_BRANCH
NSS_CO_TAG = NSS_3_6_1_BETA1
LDAPCSDK_CO_TAG = PHT_2002_08_08_BRANCH
ACCESSIBLE_CO_TAG = PHT_2002_08_08_BRANCH
GFX2_CO_TAG = PHT_2002_08_08_BRANCH
IMGLIB2_CO_TAG = PHT_2002_08_08_BRANCH
BUILD_MODULES = all
#######################################################################

View File

@@ -59,7 +59,8 @@ JAVAH_PROG = $(JAVA) netscape.tools.jric.Main
# Uncomment for MSVC debug malloc logging...
#
#OPTIMIZER=-Zi -DDEBUG -UNDEBUG -D_DEBUG -D_CRTDBG_MAP_ALLOC
OPTIMIZER=-Zi -DDEBUG -UNDEBUG -D_DEBUG
#OPTIMIZER=-Zi -DDEBUG -UNDEBUG -D_DEBUG
OPTIMIZER=-Zi -UNDEBUG
!if defined(GLOWCODE) && "$(MOZ_BITS)"=="32"
OS_LFLAGS=/DEBUG /DEBUGTYPE:BOTH /INCLUDE:_GlowCode /PDB:NONE
!else

View File

@@ -391,7 +391,11 @@ endif
ifndef _ENABLE_PIC
DSO_CFLAGS=
ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
DSO_PIC_CFLAGS=-mdynamic-no-pic
else
DSO_PIC_CFLAGS=
endif
MKSHLIB=
endif

View File

@@ -451,7 +451,8 @@ ifeq ($(OS_ARCH),Darwin)
ifdef IS_COMPONENT
EXTRA_DSO_LDOPTS += -bundle
else
EXTRA_DSO_LDOPTS += -dynamiclib
EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/\$@ -compatibility_version 1 -current_version 1
endif
endif

4
mozilla/configure vendored
View File

@@ -4633,7 +4633,7 @@ EOF
CFLAGS="$CFLAGS -fpascal-strings -traditional-cpp -fno-common"
CXXFLAGS="$CXXFLAGS -fpascal-strings -traditional-cpp -fno-common"
DLL_SUFFIX=".dylib"
DSO_LDOPTS='-compatibility_version 1 -current_version 1'
DSO_LDOPTS=''
STRIP="$STRIP -x -S"
case "${target_cpu}" in
powerpc*)
@@ -4656,7 +4656,7 @@ EOF
no_x=yes
MACOSX=1
_PLATFORM_DEFAULT_TOOLKIT='mac'
DSO_LDOPTS="$DSO_LDOPTS -arch ppc -install_name @executable_path/\$@"
DSO_LDOPTS="$DSO_LDOPTS -arch ppc"
TK_LIBS='-framework Carbon /System/Library/Frameworks/Carbon.framework/Carbon'
TK_CFLAGS="-I/Developer/Headers/FlatCarbon -F/System/Library/Frameworks"
CFLAGS="$CFLAGS $TK_CFLAGS"

View File

@@ -765,7 +765,7 @@ case "$target" in
CFLAGS="$CFLAGS -fpascal-strings -traditional-cpp -fno-common"
CXXFLAGS="$CXXFLAGS -fpascal-strings -traditional-cpp -fno-common"
DLL_SUFFIX=".dylib"
DSO_LDOPTS='-compatibility_version 1 -current_version 1'
DSO_LDOPTS="$DSO_LDOPTS -arch ppc"
STRIP="$STRIP -x -S"
case "${target_cpu}" in
powerpc*)
@@ -776,7 +776,7 @@ case "$target" in
no_x=yes
MACOSX=1
_PLATFORM_DEFAULT_TOOLKIT='mac'
DSO_LDOPTS="$DSO_LDOPTS -arch ppc -install_name @executable_path/\$@"
DSO_LDOPTS="$DSO_LDOPTS -arch ppc"
TK_LIBS='-framework Carbon /System/Library/Frameworks/Carbon.framework/Carbon'
TK_CFLAGS="-I/Developer/Headers/FlatCarbon -F/System/Library/Frameworks"
CFLAGS="$CFLAGS $TK_CFLAGS"

View File

@@ -223,6 +223,14 @@
// {6030f7ef-32ed-46a7-9a63-6a5d3f90445f}
#define NS_PLAINTEXTSERIALIZER_CID \
{ 0x6030f7ef, 0x32ed, 0x46a7, { 0x9a, 0x63, 0x6a, 0x5d, 0x3f, 0x90, 0x44, 0x5f } }
// {d4f2b600-b5c1-11d6-b483-cc97c63e567c}
#define NS_HTMLFRAGMENTSINK_CID \
{ 0xd4f2b600, 0xb5c1, 0x11d6, { 0xb4, 0x83, 0xcc, 0x97, 0xc6, 0x3e, 0x56, 0x7c } }
// {13111d00-ce81-11d6-8082-ecf3665af67c}
#define NS_HTMLFRAGMENTSINK2_CID \
{ 0x13111d00, 0xce81, 0x11d6, { 0x80, 0x82, 0xec, 0xf3, 0x66, 0x5a, 0xf6, 0x7c } }
// {3986B301-097C-11d3-BF87-00105A1B0627}
#define NS_XULPOPUPLISTENER_CID \

View File

@@ -223,6 +223,14 @@
// {6030f7ef-32ed-46a7-9a63-6a5d3f90445f}
#define NS_PLAINTEXTSERIALIZER_CID \
{ 0x6030f7ef, 0x32ed, 0x46a7, { 0x9a, 0x63, 0x6a, 0x5d, 0x3f, 0x90, 0x44, 0x5f } }
// {d4f2b600-b5c1-11d6-b483-cc97c63e567c}
#define NS_HTMLFRAGMENTSINK_CID \
{ 0xd4f2b600, 0xb5c1, 0x11d6, { 0xb4, 0x83, 0xcc, 0x97, 0xc6, 0x3e, 0x56, 0x7c } }
// {13111d00-ce81-11d6-8082-ecf3665af67c}
#define NS_HTMLFRAGMENTSINK2_CID \
{ 0x13111d00, 0xce81, 0x11d6, { 0x80, 0x82, 0xec, 0xf3, 0x66, 0x5a, 0xf6, 0x7c } }
// {3986B301-097C-11d3-BF87-00105A1B0627}
#define NS_XULPOPUPLISTENER_CID \

View File

@@ -82,6 +82,7 @@
#include "nsHTMLAttributes.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIHTMLContent.h"
#include "nsIHTMLFragmentContentSink.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIHTMLToTextSink.h"
#include "nsILayoutDebugger.h"
@@ -343,6 +344,8 @@ MAKE_CTOR(CreateHTMLCopyTextEncoder, nsIDocumentEncoder, NS_NewHTM
MAKE_CTOR(CreateXMLContentSerializer, nsIContentSerializer, NS_NewXMLContentSerializer)
MAKE_CTOR(CreateHTMLContentSerializer, nsIContentSerializer, NS_NewHTMLContentSerializer)
MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer, NS_NewPlainTextSerializer)
MAKE_CTOR(CreateHTMLFragmentSink, nsIHTMLFragmentContentSink, NS_NewHTMLFragmentContentSink)
MAKE_CTOR(CreateHTMLFragmentSink2, nsIHTMLFragmentContentSink, NS_NewHTMLFragmentContentSink2)
MAKE_CTOR(CreateXBLService, nsIXBLService, NS_NewXBLService)
MAKE_CTOR(CreateBindingManager, nsIBindingManager, NS_NewBindingManager)
MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy)
@@ -720,6 +723,16 @@ static const nsModuleComponentInfo gComponents[] = {
NS_PLAINTEXTSINK_CONTRACTID,
CreatePlainTextSerializer },
{ "html fragment sink",
NS_HTMLFRAGMENTSINK_CID,
NS_FRAGMENTSINK_CONTRACTID,
CreateHTMLFragmentSink },
{ "html fragment sink 2",
NS_HTMLFRAGMENTSINK2_CID,
NS_HTMLFRAGMENTSINK2_CONTRACTID,
CreateHTMLFragmentSink2 },
{ "XBL Service",
NS_XBLSERVICE_CID,
"@mozilla.org/xbl;1",

View File

@@ -1319,11 +1319,13 @@ nsHTMLSelectElement::SetOptionsSelectedByIndex(PRInt32 aStartIndex,
if (domDoc) {
nsCOMPtr<nsIDOMEvent> selectEvent;
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(selectEvent));
selectEvent->InitEvent(NS_LITERAL_STRING("selectedItemChanged"),
PR_TRUE, PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIDOMNode*, this)));
PRBool noDefault;
target->DispatchEvent(selectEvent, &noDefault);
if (selectEvent) {
selectEvent->InitEvent(NS_LITERAL_STRING("selectedItemChanged"),
PR_TRUE, PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIDOMNode*, this)));
PRBool noDefault;
target->DispatchEvent(selectEvent, &noDefault);
}
}
}

View File

@@ -164,6 +164,35 @@ public:
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager;
};
class nsHTMLFragmentContentSink2 : public nsHTMLFragmentContentSink
{
public:
nsHTMLFragmentContentSink2() { mHitSentinel = PR_TRUE; mSeenBody = PR_FALSE;}
virtual ~nsHTMLFragmentContentSink2() {}
NS_IMETHODIMP OpenHead(const nsIParserNode& aNode) { return OpenContainer(aNode); }
NS_IMETHODIMP CloseHead(const nsIParserNode& aNode) { return CloseContainer(aNode); }
};
nsresult
NS_NewHTMLFragmentContentSink2(nsIHTMLFragmentContentSink** aResult)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
nsHTMLFragmentContentSink2* it;
NS_NEWXPCOM(it, nsHTMLFragmentContentSink2);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = it->Init();
if (NS_FAILED(rv)) {
delete it;
return rv;
}
return it->QueryInterface(NS_GET_IID(nsIHTMLFragmentContentSink), (void **)aResult);
}
nsresult
NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aResult)
@@ -249,6 +278,12 @@ nsHTMLFragmentContentSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIContentSink))) {
nsIContentSink* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)this);
NS_ADDREF_THIS();
@@ -380,7 +415,6 @@ nsHTMLFragmentContentSink::CloseHTML(const nsIParserNode& aNode)
NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHead(const nsIParserNode& aNode)
{
// XXX Not likely to get a head in the fragment
return NS_OK;
}

View File

@@ -4813,7 +4813,7 @@ nsDocShell::DoURILoad(nsIURI * aURI,
loadGroup,
NS_STATIC_CAST(nsIInterfaceRequestor *, this));
if (NS_FAILED(rv))
return rv;
return rv;
channel->SetOriginalURI(aURI);

View File

@@ -189,6 +189,12 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const nsAString & aCommandName, nsI
// also udpate the command state.
UpdateCommandState(aCommandName, refCon);
}
else
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (editor)
*outCmdEnabled = PR_TRUE;
}
return NS_OK;
}
@@ -799,6 +805,12 @@ nsIndentCommand::IsCommandEnabled(const nsAString & aCommandName, nsISupports *r
if (editor)
*outCmdEnabled = PR_TRUE; // can always indent (I guess)
}
else
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (editor)
*outCmdEnabled = PR_TRUE;
}
return NS_OK;
}
@@ -868,6 +880,17 @@ nsOutdentCommand::IsCommandEnabled(const nsAString & aCommandName, nsISupports *
*outCmdEnabled = canOutdent;
}
}
else
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
if (htmlEditor)
{
PRBool canIndent, canOutdent;
htmlEditor->GetIndentState(&canIndent, &canOutdent);
*outCmdEnabled = canOutdent;
}
}
return NS_OK;
}
@@ -1643,9 +1666,11 @@ nsRemoveStylesCommand::DoCommand(const nsAString & aCommandName, nsISupports *re
NS_IMETHODIMP
nsRemoveStylesCommand::DoCommandParams(nsICommandParams *aParams, nsISupports *refCon)
{
nsString tString;
aParams->GetStringValue(COMMAND_NAME,tString);
return DoCommand(tString, refCon);
nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);
if (editor)
editor->RemoveAllInlineProperties();
return NS_OK;
}
NS_IMETHODIMP

View File

@@ -243,7 +243,7 @@ nsComposerCommandsUpdater::UpdateDirtyState(PRBool aNowDirty)
}
nsresult
nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommand)
nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommandGroup)
{
if (!mDocShell)
{
@@ -260,9 +260,11 @@ nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommand)
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
theDoc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
mDocShell = docShell.get();
if (scriptGlobalObject) {
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
mDocShell = docShell.get();
}
}
if (!mDocShell) return NS_ERROR_FAILURE;
@@ -271,10 +273,49 @@ nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommand)
nsCOMPtr<nsPICommandUpdater> commandUpdater = do_QueryInterface(commandManager);
if (!commandUpdater) return NS_ERROR_FAILURE;
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_bold"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_italic"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_underline"));
// this hardcoded list of commands in temporary. This code should
// use nsICommandGroup.
if (aCommandGroup.Equals(NS_LITERAL_STRING("undo")))
{
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_undo"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_redo"));
}
else if (aCommandGroup.Equals(NS_LITERAL_STRING("select")) ||
aCommandGroup.Equals(NS_LITERAL_STRING("style")))
{
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_bold"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_italic"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_underline"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_tt"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_strikethrough"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_superscript"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_subscript"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_nobreak"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_em"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_strong"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_cite"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_abbr"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_acronym"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_code"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_samp"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_var"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_increaseFont"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_decreaseFont"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_paragraphState"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_fontFace"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_fontColor"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_backgroundColor"));
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_highlight"));
}
else if (aCommandGroup.Equals(NS_LITERAL_STRING("save")))
{
// save commands (none in C++)
}
return NS_OK;
}

View File

@@ -240,3 +240,18 @@ nsresult nsEditorController::GetEditorCommandManager(nsIControllerCommandManager
return NS_OK;
}
NS_IMETHODIMP nsEditorController::GetCommandState(nsICommandParams *aCommandParams)
{
if (!mCommandRefCon || !mCommandManager)
return NS_ERROR_NOT_INITIALIZED;
return mCommandManager->GetCommandState(aCommandParams,mCommandRefCon);
}
/* void doCommand (in DOMString aCommandName, in nsICommandParams aCommandParams); */
NS_IMETHODIMP nsEditorController::DoCommand(nsICommandParams *aCommandParams)
{
if (!mCommandRefCon || !mCommandManager)
return NS_ERROR_NOT_INITIALIZED;
return mCommandManager->DoCommandParams(aCommandParams,mCommandRefCon);
}

View File

@@ -61,6 +61,7 @@ class nsIEditor;
// commands in composer. The refCon that gets passed to its commands is an nsIEditor.
class nsEditorController : public nsIController,
public nsICommandController,
public nsIEditorController,
public nsIInterfaceRequestor
{
@@ -85,6 +86,9 @@ public:
// nsIInterfaceRequestor
NS_DECL_NSIINTERFACEREQUESTOR
//nsICommandController
NS_DECL_NSICOMMANDCONTROLLER
protected:
//if editor is null then look to mContent. this is for dual use of window and content

View File

@@ -100,6 +100,8 @@
#include "nsAOLCiter.h"
#include "nsInternetCiter.h"
#include "nsISupportsPrimitives.h"
#include "nsLinebreakConverter.h"
#include "nsIHTMLFragmentContentSink.h"
// netwerk
#include "nsIURI.h"
@@ -120,6 +122,7 @@ const PRUnichar nbsp = 160;
static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
// Drag & Drop, Clipboard Support
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
@@ -129,6 +132,10 @@ static NS_DEFINE_CID(kCHTMLFormatConverterCID, NS_HTMLFORMATCONVERTER_CID);
#define kHTMLContext "text/_moz_htmlcontext"
#define kHTMLInfo "text/_moz_htmlinfo"
// some little helpers
static PRInt32 FindPositiveIntegerAfterString( const char * aLeadingString, nsCString & aCStr );
static nsresult RemoveFragComments(nsCString & theStr);
static void RemoveBodyAndHead(nsIDOMNode *aNode);
#if defined(NS_DEBUG) && defined(DEBUG_buster)
static PRBool gNoisy = PR_FALSE;
@@ -636,31 +643,145 @@ nsHTMLEditor::StripFormattingNodes(nsIDOMNode *aNode, PRBool aListOnly)
}
NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable)
{
return NS_OK;
}
NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransferable , PRBool aHavePrivFlavor )
{
// Create generic Transferable for getting the data
nsresult rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
NS_GET_IID(nsITransferable),
(void**)transferable);
(void**)aTransferable);
if (NS_FAILED(rv))
return rv;
// Get the nsITransferable interface for getting the data from the clipboard
if (transferable)
if (aTransferable)
{
// Create the desired DataFlavor for the type of data
// we want to get out of the transferable
if ((mFlags & eEditorPlaintextMask) == 0) // This should only happen in html editors, not plaintext
{
(*transferable)->AddDataFlavor(kJPEGImageMime);
(*transferable)->AddDataFlavor(kHTMLMime);
(*transferable)->AddDataFlavor(kFileMime);
if (!aHavePrivFlavor) (*aTransferable)->AddDataFlavor(kNativeHTMLMime);
(*aTransferable)->AddDataFlavor(kHTMLMime);
(*aTransferable)->AddDataFlavor(kFileMime);
//(*transferable)->AddDataFlavor(kJPEGImageMime);
}
(*transferable)->AddDataFlavor(kUnicodeMime);
(*aTransferable)->AddDataFlavor(kUnicodeMime);
}
return NS_OK;
}
PRInt32
FindPositiveIntegerAfterString( const char * aLeadingString, nsCString & aCStr )
{
char crlf[] = {nsCRT::CR, nsCRT::LF, 0};
// first obtain offsets from cfhtml str
PRInt32 numFront = aCStr.Find(aLeadingString);
if (numFront == -1)
return -1;
numFront += nsCRT::strlen(aLeadingString);
PRInt32 numBack = aCStr.FindCharInSet(crlf, numFront);
if (numBack == -1)
return -1;
nsCAutoString numStr(Substring(aCStr, numFront, numBack-numFront));
PRInt32 errorCode;
return numStr.ToInteger(&errorCode);
}
nsresult
RemoveFragComments(nsCString & aStr)
{
// remove the StartFragment/EndFragment comments from the str, if present
PRInt32 startCommentIndx = aStr.Find("<!--StartFragment");
if (startCommentIndx >= 0)
{
PRInt32 startCommentEnd = aStr.Find("-->", PR_FALSE, startCommentIndx);
if (startCommentEnd > startCommentIndx)
aStr.Cut(startCommentIndx, (startCommentEnd+3)-startCommentIndx);
}
PRInt32 endCommentIndx = aStr.Find("<!--EndFragment");
if (endCommentIndx >= 0)
{
PRInt32 endCommentEnd = aStr.Find("-->", PR_FALSE, endCommentIndx);
if (endCommentEnd > endCommentIndx)
aStr.Cut(endCommentIndx, (endCommentEnd+3)-endCommentIndx);
}
return NS_OK;
}
nsresult
nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, nsAString & aStuffToPaste, nsAString & aCfcontext)
{
// first obtain offsets from cfhtml str
PRInt32 startHTML = FindPositiveIntegerAfterString("StartHTML:", aCfhtml);
PRInt32 endHTML = FindPositiveIntegerAfterString("EndHTML:", aCfhtml);
PRInt32 startFragment = FindPositiveIntegerAfterString("StartFragment:", aCfhtml);
PRInt32 endFragment = FindPositiveIntegerAfterString("EndFragment:", aCfhtml);
if ((startHTML<0) || (endHTML<0) || (startFragment<0) || (endFragment<0))
return NS_ERROR_FAILURE;
// create context string
nsCAutoString contextUTF8(Substring(aCfhtml, startHTML, endHTML-startHTML));
// cut fragment string out of context
contextUTF8.Cut(startFragment-startHTML, endFragment-startFragment);
// create fragment string
nsCAutoString fragmentUTF8(Substring(aCfhtml, startFragment, endFragment-startFragment));
// remove the StartFragment/EndFragment comments from the fragment, if present
RemoveFragComments(fragmentUTF8);
// remove the StartFragment/EndFragment comments from the context, if present
RemoveFragComments(contextUTF8);
// convert both strings to usc2
aStuffToPaste.Assign(NS_ConvertUTF8toUCS2(fragmentUTF8));
aCfcontext.Assign(NS_ConvertUTF8toUCS2(contextUTF8));
// translate platform linebreaks for fragment
PRUnichar* newStr=0;
PRInt32 oldLengthInChars=aStuffToPaste.Length();
PRInt32 newLengthInChars=0;
newStr = nsLinebreakConverter::ConvertUnicharLineBreaks( PromiseFlatString(aStuffToPaste).get(),
nsLinebreakConverter::eLinebreakAny,
nsLinebreakConverter::eLinebreakContent,
oldLengthInChars, &newLengthInChars );
if (newStr)
{
aStuffToPaste.Assign(newStr, newLengthInChars);
nsMemory::Free (newStr);
}
else
{
return NS_ERROR_FAILURE;
}
// translate platform linebreaks for context
newStr=0;
oldLengthInChars=aCfcontext.Length();
newLengthInChars=0;
newStr = nsLinebreakConverter::ConvertUnicharLineBreaks( PromiseFlatString(aCfcontext).get(),
nsLinebreakConverter::eLinebreakAny,
nsLinebreakConverter::eLinebreakContent,
oldLengthInChars, &newLengthInChars );
if (newStr)
{
aCfcontext.Assign(newStr, newLengthInChars);
nsMemory::Free (newStr);
}
// else --- it's ok for context to be empty. frag might be whole doc and contain all it's context.
// we're done!
return NS_OK;
}
NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable,
const nsAString & aContextStr,
const nsAString & aInfoStr)
@@ -677,7 +798,36 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
#ifdef DEBUG_clipboard
printf("Got flavor [%s]\n", bestFlavor);
#endif
if (flavor.Equals(NS_LITERAL_STRING(kHTMLMime)))
if (flavor.Equals(NS_LITERAL_STRING(kNativeHTMLMime)))
{
// note cf_html uses utf8, hence use length = len, not len/2 as in flavors below
nsCOMPtr<nsISupportsString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
{
#if 0
PRUnichar* text = nsnull;
textDataObj->ToString(&text);
#endif
nsCAutoString cfhtml;
char* text = nsnull;
textDataObj->GetData(&text);
cfhtml.Assign(text, len);
#if 0
nsCAutoString cfhtml;
textDataObj->GetData ( cfhtml );
#endif
NS_ASSERTION(cfhtml.Length() <= (len), "Invalid length!");
nsAutoString cfcontext, cfselection; // cfselection left emtpy for now
rv = ParseCFHTML(cfhtml, stuffToPaste, cfcontext);
if ( NS_SUCCEEDED(rv) && !stuffToPaste.IsEmpty() )
{
nsAutoEditBatch beginBatching(this);
rv = InsertHTMLWithContext(stuffToPaste, cfcontext, cfselection);
}
}
}
else if (flavor.Equals(NS_LITERAL_STRING(kHTMLMime)))
{
nsCOMPtr<nsISupportsWString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
@@ -796,9 +946,15 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
dragService->GetCurrentSession(getter_AddRefs(dragSession));
if (!dragSession) return NS_OK;
// find out if we have our internal html flavor on the clipboard. We don't want to mess
// around with cfhtml if we do.
PRBool bHavePrivateHTMLFlavor = PR_FALSE;
rv = dragSession->IsDataFlavorSupported(kHTMLContext, &bHavePrivateHTMLFlavor);
if (NS_FAILED(rv)) return rv;
// Get the nsITransferable interface for getting the data from the drop
nsCOMPtr<nsITransferable> trans;
rv = PrepareTransferable(getter_AddRefs(trans));
rv = PrepareHTMLTransferable(getter_AddRefs(trans), bHavePrivateHTMLFlavor);
if (NS_FAILED(rv)) return rv;
if (!trans) return NS_OK; // NS_ERROR_FAILURE; SHOULD WE FAIL?
@@ -1223,6 +1379,26 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent)
return rv;
}
PRBool nsHTMLEditor::HavePrivateHTMLFlavor( nsIClipboard *aClipboard )
{
// check the clipboard for our special kHTMLContext flavor. If that is there, we know
// we have our own internal html format on clipboard.
if (!aClipboard) return PR_FALSE;
PRBool bHavePrivateHTMLFlavor = PR_FALSE;
nsCOMPtr<nsISupportsArray> flavArray;
nsresult res = NS_NewISupportsArray(getter_AddRefs(flavArray));
if (NS_FAILED(res)) return PR_FALSE;
nsCOMPtr<nsISupportsString> contextString = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
if (!contextString) return PR_FALSE;
contextString->SetData(kHTMLContext);
flavArray->AppendElement(contextString);
if (NS_SUCCEEDED(aClipboard->HasDataMatchingFlavors (flavArray, nsIClipboard::kGlobalClipboard, &bHavePrivateHTMLFlavor )))
return bHavePrivateHTMLFlavor;
return PR_FALSE;
}
NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
{
ForceCompositionEnd();
@@ -1233,50 +1409,56 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
if ( NS_FAILED(rv) )
return rv;
// find out if we have our internal html flavor on the clipboard. We don't want to mess
// around with cfhtml if we do.
PRBool bHavePrivateHTMLFlavor = HavePrivateHTMLFlavor( clipboard );
// Get the nsITransferable interface for getting the data from the clipboard
nsCOMPtr<nsITransferable> trans;
rv = PrepareTransferable(getter_AddRefs(trans));
rv = PrepareHTMLTransferable(getter_AddRefs(trans), bHavePrivateHTMLFlavor);
if (NS_SUCCEEDED(rv) && trans)
{
// Get the Data from the clipboard
if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable())
{
// also get additional html copy hints, if present
nsAutoString contextStr, infoStr;
nsCOMPtr<nsISupports> contextDataObj, infoDataObj;
PRUint32 contextLen, infoLen;
nsCOMPtr<nsISupportsWString> textDataObj;
// also get additional html copy hints, if present
if (bHavePrivateHTMLFlavor) {
nsCOMPtr<nsISupports> contextDataObj, infoDataObj;
PRUint32 contextLen, infoLen;
nsCOMPtr<nsISupportsWString> textDataObj;
nsCOMPtr<nsITransferable> contextTrans = do_CreateInstance(kCTransferableCID);
NS_ENSURE_TRUE(contextTrans, NS_ERROR_NULL_POINTER);
contextTrans->AddDataFlavor(kHTMLContext);
clipboard->GetData(contextTrans, aSelectionType);
contextTrans->GetTransferData(kHTMLContext, getter_AddRefs(contextDataObj), &contextLen);
nsCOMPtr<nsITransferable> contextTrans = do_CreateInstance(kCTransferableCID);
NS_ENSURE_TRUE(contextTrans, NS_ERROR_NULL_POINTER);
contextTrans->AddDataFlavor(kHTMLContext);
clipboard->GetData(contextTrans, aSelectionType);
contextTrans->GetTransferData(kHTMLContext, getter_AddRefs(contextDataObj), &contextLen);
nsCOMPtr<nsITransferable> infoTrans = do_CreateInstance(kCTransferableCID);
NS_ENSURE_TRUE(infoTrans, NS_ERROR_NULL_POINTER);
infoTrans->AddDataFlavor(kHTMLInfo);
clipboard->GetData(infoTrans, aSelectionType);
infoTrans->GetTransferData(kHTMLInfo, getter_AddRefs(infoDataObj), &infoLen);
nsCOMPtr<nsITransferable> infoTrans = do_CreateInstance(kCTransferableCID);
NS_ENSURE_TRUE(infoTrans, NS_ERROR_NULL_POINTER);
infoTrans->AddDataFlavor(kHTMLInfo);
clipboard->GetData(infoTrans, aSelectionType);
infoTrans->GetTransferData(kHTMLInfo, getter_AddRefs(infoDataObj), &infoLen);
if (contextDataObj)
{
PRUnichar* text = nsnull;
textDataObj = do_QueryInterface(contextDataObj);
textDataObj->ToString ( &text );
contextStr.Assign ( text, contextLen / 2 );
if (text)
nsMemory::Free(text);
}
if (contextDataObj)
{
PRUnichar* text = nsnull;
textDataObj = do_QueryInterface(contextDataObj);
textDataObj->ToString ( &text );
contextStr.Assign ( text, contextLen / 2 );
if (text)
nsMemory::Free(text);
}
if (infoDataObj)
{
PRUnichar* text = nsnull;
textDataObj = do_QueryInterface(infoDataObj);
textDataObj->ToString ( &text );
infoStr.Assign ( text, infoLen / 2 );
if (text)
nsMemory::Free(text);
if (infoDataObj)
{
PRUnichar* text = nsnull;
textDataObj = do_QueryInterface(infoDataObj);
textDataObj->ToString ( &text );
infoStr.Assign ( text, infoLen / 2 );
if (text)
nsMemory::Free(text);
}
}
rv = InsertFromTransferable(trans, contextStr, infoStr);
}
@@ -1302,7 +1484,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
// the flavors that we can deal with
const char* const textEditorFlavors[] = { kUnicodeMime, nsnull };
const char* const htmlEditorFlavors[] = { kJPEGImageMime, kHTMLMime, nsnull };
const char* const htmlEditorFlavors[] = { kHTMLMime, kJPEGImageMime, nsnull };
nsCOMPtr<nsISupportsArray> flavorsList;
rv = nsComponentManager::CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, nsnull,
@@ -1658,6 +1840,46 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
return res;
}
void RemoveBodyAndHead(nsIDOMNode *aNode)
{
if (!aNode)
return;
nsCOMPtr<nsIDOMNode> tmp, child, body, head;
// find the body and head nodes if any.
// look only at immediate children of aNode.
aNode->GetFirstChild(getter_AddRefs(child));
while (child)
{
if (nsTextEditUtils::IsBody(child))
{
body = child;
}
else if (nsEditor::NodeIsType(child, NS_LITERAL_STRING("head")))
{
head = child;
}
child->GetNextSibling(getter_AddRefs(tmp));
child = tmp;
}
if (head)
{
aNode->RemoveChild(head, getter_AddRefs(tmp));
}
if (body)
{
body->GetFirstChild(getter_AddRefs(child));
while (child)
{
aNode->InsertBefore(child, body, getter_AddRefs(tmp));
body->GetFirstChild(getter_AddRefs(child));
}
aNode->RemoveChild(body, getter_AddRefs(tmp));
}
}
nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
const nsAString & aInputString,
const nsAString & aContextStr,
@@ -1669,46 +1891,43 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
if (!outFragNode || !outRangeStartHint || !outRangeEndHint || !aNSRange)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMDocumentFragment> docfrag;
nsCOMPtr<nsIDOMNode> contextAsNode;
nsCOMPtr<nsIDOMNode> contextAsNode, tmp;
nsresult res = NS_OK;
// if we have context info, create a fragment for that
nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
nsCOMPtr<nsIDOMNode> contextLeaf;
nsCOMPtr<nsIDOMNode> contextLeaf, junk;
PRInt32 contextDepth = 0;
if (aContextStr.Length())
{
res = aNSRange->CreateContextualFragment(aContextStr, getter_AddRefs(contextfrag));
res = ParseFragment(aContextStr, address_of(contextAsNode));
NS_ENSURE_SUCCESS(res, res);
contextAsNode = do_QueryInterface(contextfrag);
res = StripFormattingNodes(contextAsNode);
NS_ENSURE_TRUE(contextAsNode, NS_ERROR_FAILURE);
res = StripFormattingNodes(contextAsNode);
NS_ENSURE_SUCCESS(res, res);
RemoveBodyAndHead(contextAsNode);
// cache the deepest leaf in the context
nsCOMPtr<nsIDOMNode> junk, child, tmp = contextAsNode;
tmp = contextAsNode;
while (tmp)
{
contextDepth++;
contextLeaf = tmp;
contextLeaf->GetFirstChild(getter_AddRefs(tmp));
}
// tweak aNSRange to point inside contextAsNode
nsCOMPtr<nsIDOMRange> range(do_QueryInterface(aNSRange));
if (range)
{
aNSRange->NSDetach();
range->SetStart(contextLeaf,0);
range->SetEnd(contextLeaf,0);
}
}
// create fragment for pasted html
res = aNSRange->CreateContextualFragment(aInputString, getter_AddRefs(docfrag));
res = ParseFragment(aInputString, outFragNode);
NS_ENSURE_SUCCESS(res, res);
*outFragNode = do_QueryInterface(docfrag);
if (contextfrag)
NS_ENSURE_TRUE(*outFragNode, NS_ERROR_FAILURE);
RemoveBodyAndHead(*outFragNode);
if (contextAsNode)
{
nsCOMPtr<nsIDOMNode> junk;
// unite the two trees
contextLeaf->AppendChild(*outFragNode, getter_AddRefs(junk));
*outFragNode = contextAsNode;
@@ -1738,6 +1957,37 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(nsIDOMNSRange *aNSRange,
return res;
}
nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr, nsCOMPtr<nsIDOMNode> *outNode)
{
// create the parser to do the conversion.
nsCOMPtr<nsIParser> parser;
nsresult res = nsComponentManager::CreateInstance(kCParserCID, nsnull, NS_GET_IID(nsIParser),
getter_AddRefs(parser));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(parser, NS_ERROR_FAILURE);
// create the html fragment sink
nsCOMPtr<nsIContentSink> sink;
sink = do_CreateInstance(NS_HTMLFRAGMENTSINK2_CONTRACTID);
NS_ENSURE_TRUE(sink, NS_ERROR_FAILURE);
nsCOMPtr<nsIHTMLFragmentContentSink> fragSink(do_QueryInterface(sink));
NS_ENSURE_TRUE(fragSink, NS_ERROR_FAILURE);
// parse the fragment
parser->SetContentSink(sink);
parser->Parse(aFragStr, 0, NS_LITERAL_CSTRING("text/html"), PR_FALSE, PR_TRUE, eDTDMode_fragment);
// get the fragment node
nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
res = fragSink->GetFragment(getter_AddRefs(contextfrag));
NS_ENSURE_SUCCESS(res, res);
*outNode = do_QueryInterface(contextfrag);
return res;
}
nsresult nsHTMLEditor::CreateListOfNodesToPaste(nsIDOMNode *aFragmentAsNode,
nsCOMPtr<nsISupportsArray> *outNodeList,
PRInt32 aRangeStartHint,

View File

@@ -67,6 +67,7 @@ class nsITransferable;
class nsIDOMEventReceiver;
class nsIDOMNSRange;
class nsIDocumentEncoder;
class nsIClipboard;
class TypeInState;
/**
@@ -611,9 +612,12 @@ protected:
// factored methods for handling insertion of data from transferables (drag&drop or clipboard)
NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, PRBool havePrivFlavor);
NS_IMETHOD InsertFromTransferable(nsITransferable *transferable,
const nsAString & aContextStr,
const nsAString & aInfoStr);
PRBool HavePrivateHTMLFlavor( nsIClipboard *clipboard );
nsresult ParseCFHTML(nsCString & cfhtml, nsAString & stuffToPaste, nsAString & cfcontext);
nsresult InsertHTMLWithContext(const nsAString & aInputString,
const nsAString & aContextStr,
const nsAString & aInfoStr);
@@ -629,6 +633,7 @@ protected:
nsCOMPtr<nsIDOMNode> *outFragNode,
PRInt32 *outRangeStartHint,
PRInt32 *outRangeEndHint);
nsresult ParseFragment(const nsAString & aStr, nsCOMPtr<nsIDOMNode> *outNode);
nsresult CreateListOfNodesToPaste(nsIDOMNode *aFragmentAsNode,
nsCOMPtr<nsISupportsArray> *outNodeList,
PRInt32 aRangeStartHint,

View File

@@ -168,8 +168,6 @@ Components:pipboot.shlb
Components:pipboot.xpt
Components:PIPNSS.shlb
Components:pipnss.xpt
Components:PIPPKI.shlb
Components:pippki.xpt
defaults:pref:security-prefs.js
Essential Files:NSS3.shlb
Essential Files:SMIME3.shlb

View File

@@ -168,8 +168,6 @@ Components:pipbootDebug.shlb
Components:pipboot.xpt
Components:PIPNSSDebug.shlb
Components:pipnss.xpt
Components:PIPPKIDebug.shlb
Components:pippki.xpt
defaults:pref:security-prefs.js
Essential Files:NSS3Debug.shlb
Essential Files:SMIME3Debug.shlb

View File

@@ -173,9 +173,6 @@ components/pipboot.xpt
components/libpipnss.dylib
components/pipnss.xpt
chrome/pipnss.jar
components/libpippki.dylib
components/pippki.xpt
chrome/pippki.jar
defaults/pref/security-prefs.js
libnss3.dylib
libsmime3.dylib

View File

@@ -184,9 +184,6 @@ components/pipboot.xpt
components/libpipnss.so
components/pipnss.xpt
chrome/pipnss.jar
components/libpippki.so
components/pippki.xpt
chrome/pippki.jar
defaults/pref/security-prefs.js
libnss3.so
libsmime3.so

View File

@@ -201,9 +201,6 @@ components\pipboot.xpt
components\pipnss.dll
components\pipnss.xpt
chrome\pipnss.jar
components\pippki.dll
components\pippki.xpt
chrome\pippki.jar
defaults\pref\security-prefs.js
nss3.dll
smime3.dll

View File

@@ -17,9 +17,21 @@
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=..\..
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
DIRS = src
include $(DEPTH)/config/autoconf.mk
!include $(DEPTH)\config\rules.mak
include $(topsrcdir)/config/rules.mk
libs::
@$(REGCHROME) content autoconfig comm.jar
@$(REGCHROME) locale en-US/autoconfig en-US.jar
install::
@$(REGCHROME_INSTALL) content autoconfig comm.jar
@$(REGCHROME_INSTALL) locale en-US/autoconfig en-US.jar

View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the packages being supplied -->
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:autoconfig"/>
</RDF:Seq>
<!-- package information -->
<RDF:Description about="urn:mozilla:package:autoconfig"
chrome:displayName="AutoConfig"
chrome:author="mozilla.org"
chrome:name="autoconfig"
chrome:localeVersion="1.0.1rc1">
</RDF:Description>
</RDF:RDF>

View File

@@ -0,0 +1,6 @@
comm.jar:
content/autoconfig/contents.rdf (content/contents.rdf)
en-US.jar:
locale/en-US/autoconfig/contents.rdf (locale/en-US/contents.rdf)
locale/en-US/autoconfig/autoconfig.properties (locale/en-US/autoconfig.properties)

View File

@@ -0,0 +1,5 @@
readConfigTitle = Configuration Error
readConfigMsg = Failed to read the configuration file. Please contact your system administrator.
autoConfigTitle = AutoConfig Alert
autoConfigMsg = Netscape.cfg/AutoConfig failed. Please contact your system administrator. \n Error: %S failed:

View File

@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the locales being supplied -->
<RDF:Seq about="urn:mozilla:locale:root">
<RDF:li resource="urn:mozilla:locale:en-US"/>
</RDF:Seq>
<!-- locale information -->
<RDF:Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
<RDF:li resource="urn:mozilla:locale:en-US:autoconfig"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
<!-- Version Information. State that we work only with major version of this
package. -->
<RDF:Description about="urn:mozilla:locale:en-US:autoconfig"
chrome:localeVersion="1.0.1rc1"/>
</RDF:RDF>

View File

@@ -1,3 +1,4 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
@@ -18,11 +19,10 @@
#
# Contributor(s):
DEPTH=..\..\..
DEPTH=..\..\..\..
DIRS = libical \
libicalss \
libicalvcal \
$(NULL)
include <$(DEPTH)\config\rules.mak>
!include $(DEPTH)\config\rules.mak
chrome::
$(REGCHROME) content autoconfig comm.jar
$(REGCHROME) locale en-US/autoconfig en-US.jar

View File

@@ -0,0 +1,136 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Interface to the Service for gwetting the Global PrintSettings object
or a unique PrintSettings object
*/
#include "nsISupports.idl"
interface nsIPrintSettings;
[scriptable, uuid(841387C8-72E6-484b-9296-BF6EEA80D58A)]
interface nsIPrintSettingsService : nsISupports
{
/**
* Returns a "global" PrintSettings object
* Creates a new the first time, if one doesn't exist.
*
* Then returns the same object each time after that.
*
* Initializes the globalPrintSettings from the default printer
*/
readonly attribute nsIPrintSettings globalPrintSettings;
/**
* Returns a new, unique PrintSettings object each time.
*
* For example, if each browser was to have its own unique
* PrintSettings, then each browser window would call this to
* create its own unique PrintSettings object.
*
* If each browse window was to use the same PrintSettings object
* then it should use "globalPrintSettings"
*
* Initializes the newPrintSettings from the default printer
*
*/
readonly attribute nsIPrintSettings newPrintSettings;
/**
* The name of the default printer
*/
readonly attribute wstring defaultPrinterName;
/**
* Initializes certain settings from the native printer into the PrintSettings
* if aPrinterName is null then it uses the default printer name if it can
* These settings include, but are not limited to:
* Page Orientation
* Page Size
* Number of Copies
*/
void initPrintSettingsFromPrinter(in wstring aPrinterName, in nsIPrintSettings aPrintSettings);
/**
* Reads PrintSettings values from Prefs,
* the values to be read are indicated by the "flags" arg.
*
* First it reads in the "generic" set of PrintSetings not associated with any printer
* then it uses the PrinterName in the PrinterSettings to read any settings that were saved
* just for that printer.
*
* aPS - PrintSettings to have its settings read
* aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix
* aFlags - indicates which prefs to read, see nsIPrintSettings.idl for the const values.
*
* Items not read:
* startPageRange, endPageRange, scaling, printRange, title
* docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage
* printFrameType, printSilent, shrinkToFit, numCopies
*
*/
void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags);
/**
* Writes PrintSettings values to Prefs,
* the values to be written are indicated by the "flags" arg.
*
* If there is no PrinterName in the PrinterSettings
* the values are saved as the "generic" values not associated with any printer.
* If a PrinterName is there, then it saves the items qualified for that Printer
*
* aPS - PrintSettings to have its settings saved
* aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix
* aFlags - indicates which prefs to save, see nsIPrintSettings.idl for the const values.
*
* Items not written:
* startPageRange, endPageRange, scaling, printRange, title
* docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage
* printFrameType, printSilent, shrinkToFit, numCopies
*
*/
void savePrintSettingsToPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags);
};
%{C++
// {841387C8-72E6-484b-9296-BF6EEA80D58A}
#define NS_PRINTSETTINGSSERVICE_IID \
{0x841387c8, 0x72e6, 0x484b, { 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a}}
%}

View File

@@ -125,6 +125,8 @@ void nsGraphicState::Clear()
mOffx = 0;
mOffy = 0;
mSaveOffx = 0;
mSaveOffy = 0;
mColor = NS_RGB(255,255,255);
mFont = 0;
mFontMetrics = nsnull;
@@ -196,6 +198,9 @@ void nsGraphicState::Duplicate(nsGraphicState* aGS)
mOffx = aGS->mOffx;
mOffy = aGS->mOffy;
mSaveOffx = aGS->mSaveOffx;
mSaveOffy = aGS->mSaveOffy;
mMainRegion = DuplicateRgn(aGS->mMainRegion, mMainRegion);
mClipRegion = DuplicateRgn(aGS->mClipRegion, mClipRegion);

View File

@@ -76,6 +76,9 @@ public:
PRInt32 mOffx;
PRInt32 mOffy;
PRInt32 mSaveOffx;
PRInt32 mSaveOffy;
RgnHandle mMainRegion;
RgnHandle mClipRegion;

View File

@@ -39,13 +39,52 @@
#include "nsRenderingContextMac.h"
#include "nsDeviceContextMac.h"
#include "nsCarbonHelpers.h"
#include "nsRegionPool.h"
#include <MacTypes.h>
#include <Quickdraw.h>
#include "nsGfxUtils.h"
#include "nsRegionPool.h"
#if 0
#if TARGET_CARBON
// useful region debugging code.
static OSStatus PrintRgnRectProc(UInt16 message, RgnHandle rgn, const Rect *inRect, void *refCon)
{
UInt32* rectCount = (UInt32*)refCon;
switch (message)
{
case kQDRegionToRectsMsgInit:
printf("Dumping region 0x%X\n", rgn);
break;
case kQDRegionToRectsMsgParse:
printf("Rect %d t,l,r,b: %ld, %ld, %ld, %ld\n", *rectCount, inRect->top, inRect->left, inRect->right, inRect->bottom);
(*rectCount)++;
break;
case kQDRegionToRectsMsgTerminate:
printf("\n");
break;
}
return noErr;
}
static void PrintRegionOutline(RgnHandle inRgn)
{
static RegionToRectsUPP sCountRectProc = nsnull;
if (!sCountRectProc)
sCountRectProc = NewRegionToRectsUPP(PrintRgnRectProc);
UInt32 rectCount = 0;
::QDRegionToRects(inRgn, kQDParseRegionFromTopLeft, sCountRectProc, &rectCount);
}
#endif // TARGET_CARBON
#endif
#pragma mark -
/** ---------------------------------------------------
* See documentation in nsImageMac.h
@@ -68,7 +107,7 @@ nsImageMac::nsImageMac()
, mIsTopToBottom(PR_TRUE)
{
NS_INIT_REFCNT();
NS_INIT_ISUPPORTS();
::memset(&mImagePixmap, 0, sizeof(PixMap));
::memset(&mMaskPixmap, 0, sizeof(PixMap));
@@ -362,6 +401,10 @@ NS_IMETHODIMP nsImageMac :: DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt3
if (!mImageBitsHandle)
return NS_ERROR_FAILURE;
#ifdef MOZ_WIDGET_COCOA
nsGraphicsUtils::SetPortToKnownGoodPort();
#endif
// lock and set up bits handles
LockImagePixels(PR_FALSE);
LockImagePixels(PR_TRUE);
@@ -382,7 +425,7 @@ NS_IMETHODIMP nsImageMac :: DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt3
PixMap* destPixels;
dstMacImage->GetPixMap(&destPixels);
NS_ASSERTION(destPixels, "No dest pixels!");
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(destPixels), srcRect, maskRect, dstRect, PR_FALSE);
@@ -778,24 +821,26 @@ OSErr nsImageMac::AllocateGWorld(PRInt16 depth, CTabHandle colorTable, const Rec
return memFullErr;
}
void nsImageMac::CopyBitsWithMask(BitMap* srcBits, BitMap* maskBits, PRInt16 maskDepth, BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort)
void nsImageMac::CopyBitsWithMask(const BitMap* srcBits, const BitMap* maskBits, PRInt16 maskDepth, const BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort)
{
if (maskBits)
{
StRegionFromPool clipRegion;
StRegionFromPool clipRegion;
if (inDrawingToPort)
{
// we need to pass in the clip region, even if it doesn't intersect the image, to avoid a bug
// on Mac OS X that causes bad image drawing (see bug 137295).
::GetClip(clipRegion);
}
}
::CopyDeepMask(srcBits, maskBits, destBits, &srcRect, &maskRect, &destRect, srcCopy, inDrawingToPort ? clipRegion : nsnull);
::CopyDeepMask(srcBits, maskBits, destBits, &srcRect, &maskRect, &destRect, srcCopy, inDrawingToPort ? clipRegion : (RgnHandle)nsnull);
}
else
::CopyBits(srcBits, destBits, &srcRect, &destRect, srcCopy, nsnull);
{
::CopyBits(srcBits, destBits, &srcRect, &destRect, srcCopy, nsnull);
}
}
@@ -1563,12 +1608,23 @@ nsresult nsImageMac::DrawTileQuickly(nsIRenderingContext &aContext,
for (PRInt32 x = aX0; x < aX1; x += mWidth)
{
Rect imageDestRect = imageRect;
Rect imageSrcRect = imageRect;
::OffsetRect(&imageDestRect, x, y);
if (x == aX1 - mWidth) {
imageDestRect.right = PR_MIN(imageDestRect.right, aX1);
imageSrcRect.right = imageRect.left + (imageDestRect.right - imageDestRect.left);
}
if (y == aY1 - mHeight) {
imageDestRect.bottom = PR_MIN(imageDestRect.bottom, aY1);
imageSrcRect.bottom = imageRect.top + (imageDestRect.bottom - imageDestRect.top);
}
// CopyBits will do the truncation for us at the edges
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(*destPixels), imageRect, imageRect, imageDestRect, PR_TRUE);
(BitMap*)(*destPixels), imageSrcRect, imageSrcRect, imageDestRect, PR_TRUE);
}
}

View File

@@ -180,8 +180,9 @@ protected:
const PRInt32 aDepth,
Handle *aMask);
static void CopyBitsWithMask(BitMap* srcBits, BitMap* maskBits, PRInt16 maskDepth, BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort);
static void CopyBitsWithMask(const BitMap* srcBits, const BitMap* maskBits, PRInt16 maskDepth, const BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort);
static PRBool RenderingToPrinter(nsIRenderingContext &aContext);
private:

View File

@@ -68,6 +68,36 @@
#define STACK_THRESHOLD 1000
//
// This object sits on the stack, saving the state of the port so it
// can be restored when the object goes out of scope.
//
class nsRenderingContextMacPortState {
public:
nsRenderingContextMacPortState(CGrafPtr port, nsGraphicState* gs)
: mPortSetter(port), mOriginSetter(port),
mSaveClip(sNativeRegionPool.GetNewRegion())
{
if (mSaveClip) {
::GetClip(mSaveClip);
}
::SetClip(gs->mClipRegion);
::SetOrigin(-gs->mOffx, -gs->mOffy);
}
~nsRenderingContextMacPortState()
{
if (mSaveClip) {
::SetClip(mSaveClip);
}
}
private:
StPortSetter mPortSetter;
StOriginSetter mOriginSetter;
RgnHandle mSaveClip;
};
//------------------------------------------------------------------------
nsRenderingContextMac::nsRenderingContextMac()
@@ -214,7 +244,8 @@ void nsRenderingContextMac::SelectDrawingSurface(nsDrawingSurfaceMac* aSurface,
mGS = aSurface->GetGS();
mTranMatrix = &(mGS->mTMatrix);
nsGraphicsUtils::SafeSetPort(mPort);
StPortSetter portSetter(mPort);
StOriginSetter originSetter(mPort);
::SetOrigin(-mGS->mOffx, -mGS->mOffy); // line order...
@@ -276,16 +307,8 @@ nsresult nsRenderingContextMac::SetPortTextState()
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac::SetupPortState()
{
nsGraphicsUtils::SafeSetPort(mPort);
::SetOrigin(-mGS->mOffx, -mGS->mOffy);
::SetClip(mGS->mClipRegion);
}
#pragma mark -
//------------------------------------------------------------------------
@@ -303,6 +326,12 @@ NS_IMETHODIMP nsRenderingContextMac::PushState(void)
// copy the current GS into it
gs->Duplicate(mGS);
Rect rect;
::GetPortBounds(mPort, &rect);
gs->mSaveOffx = -rect.left;
gs->mSaveOffy = -rect.top;
::SetOrigin(-gs->mOffx, -gs->mOffy);
// put the new GS at the end of the stack
mGSStack.AppendElement(gs);
@@ -326,6 +355,10 @@ NS_IMETHODIMP nsRenderingContextMac::PopState(PRBool &aClipEmpty)
// get the GS from the stack
nsGraphicState* gs = (nsGraphicState *)mGSStack.ElementAt(index);
::SetOrigin(-gs->mSaveOffx, -gs->mSaveOffy);
gs->mSaveOffx = 0;
gs->mSaveOffy = 0;
// copy the GS into the current one and tell the current surface to use it
mGS->Duplicate(gs);
@@ -750,7 +783,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetClipRegion(nsIRegion **aRegion)
NS_IMETHODIMP nsRenderingContextMac::SetColor(nscolor aColor)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
#define COLOR8TOCOLOR16(color8) ((color8 << 8) | color8)
@@ -762,7 +795,7 @@ NS_IMETHODIMP nsRenderingContextMac::SetColor(nscolor aColor)
mGS->mColor = aColor ;
mChanges |= kColorChanged;
return NS_OK;
}
@@ -858,7 +891,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetCurrentTransform(nsTransform2D *&aTransf
NS_IMETHODIMP nsRenderingContextMac::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
mGS->mTMatrix.TransformCoord(&aX0,&aY0);
mGS->mTMatrix.TransformCoord(&aX1,&aY1);
@@ -884,7 +917,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawLine(nscoord aX0, nscoord aY0, nscoord
NS_IMETHODIMP nsRenderingContextMac::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
// make the line one pixel shorter to match other platforms
nscoord diffX = aX1 - aX0;
@@ -907,7 +940,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawStdLine(nscoord aX0, nscoord aY0, nscoo
NS_IMETHODIMP nsRenderingContextMac::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
PRUint32 i;
PRInt32 x,y;
@@ -957,7 +990,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -985,7 +1018,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac::FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -1007,7 +1040,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillRect(nscoord aX, nscoord aY, nscoord aW
NS_IMETHODIMP nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
PRUint32 i;
PolyHandle thepoly;
@@ -1043,7 +1076,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt3
NS_IMETHODIMP nsRenderingContextMac::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
PRUint32 i;
PolyHandle thepoly;
@@ -1084,7 +1117,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -1112,7 +1145,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -1142,7 +1175,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextMac::DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -1172,7 +1205,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextMac::FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;
@@ -1235,7 +1268,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetWidth(const char *aString, nscoord &aWid
NS_IMETHODIMP
nsRenderingContextMac::GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
// set native font and attributes
SetPortTextState();
@@ -1254,7 +1287,7 @@ nsRenderingContextMac::GetWidth(const char* aString, PRUint32 aLength, nscoord&
NS_IMETHODIMP nsRenderingContextMac::GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nsresult rv = SetPortTextState();
if (NS_FAILED(rv))
@@ -1263,7 +1296,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetWidth(const PRUnichar *aString, PRUint32
rv = mUnicodeRenderingToolkit.PrepareToDraw(mP2T, mContext, mGS, mPort, mRightToLeftText);
if (NS_SUCCEEDED(rv))
rv = mUnicodeRenderingToolkit.GetWidth(aString, aLength, aWidth, aFontID);
return rv;
}
@@ -1286,7 +1319,7 @@ NS_IMETHODIMP
nsRenderingContextMac::GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
nsTextDimensions& aDimensions, PRInt32* aFontID)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nsresult rv = SetPortTextState();
if (NS_FAILED(rv))
@@ -1295,7 +1328,7 @@ nsRenderingContextMac::GetTextDimensions(const PRUnichar* aString, PRUint32 aLen
rv = mUnicodeRenderingToolkit.PrepareToDraw(mP2T, mContext, mGS, mPort, mRightToLeftText);
if (NS_SUCCEEDED(rv))
rv = mUnicodeRenderingToolkit.GetTextDimensions(aString, aLength, aDimensions, aFontID);
return rv;
}
@@ -1306,7 +1339,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawString(const char *aString, PRUint32 aL
nscoord aX, nscoord aY,
const nscoord* aSpacing)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
PRInt32 x = aX;
PRInt32 y = aY;
@@ -1353,7 +1386,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawString(const PRUnichar *aString, PRUint
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nsresult rv = SetPortTextState();
if (NS_FAILED(rv))
@@ -1413,7 +1446,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, nscoord aX, nsc
NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nsRect sr = aSRect;
nsRect dr = aDRect;
@@ -1430,7 +1463,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& a
NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& aRect)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nsRect tr = aRect;
mGS->mTMatrix.TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
@@ -1465,7 +1498,7 @@ NS_IMETHODIMP nsRenderingContextMac::InvertRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac::InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
SetupPortState();
nsRenderingContextMacPortState state(mPort, mGS);
nscoord x,y,w,h;
Rect therect;

View File

@@ -202,7 +202,6 @@ protected:
};
void SelectDrawingSurface(nsDrawingSurfaceMac* aSurface, PRUint32 aChanges = kEverythingChanged);
void SetupPortState();
protected:
float mP2T; // Pixel to Twip conversion factor

View File

@@ -456,8 +456,9 @@ extern "C" NS_GFX_(nscolor) NS_DarkenColor(nscolor inColor)
extern "C" NS_GFX_(void)
NS_RGB2HSV(nscolor aColor,PRUint16 &aHue,PRUint16 &aSat,PRUint16 &aValue)
{
PRUint16 r,g,b,max,min,delta;
float hue;
PRUint8 r,g,b;
PRInt16 delta,min,max,r1,b1,g1;
float hue;
r = NS_GET_R(aColor);
g = NS_GET_G(aColor);
@@ -481,18 +482,20 @@ float hue;
// value or brightness will always be the max of all the colors(RGB)
aValue = max;
delta = max-min;
aSat = (max!=0)?((delta*255)/max):0;
r1 = r;
b1 = b;
g1 = g;
if (aSat==0) {
hue = 1000;
} else {
if(r==max){
hue=(float)(g-b)/(float)delta;
} else if (g==max) {
hue= 2.0f+(float)(b-r)/(float)delta;
} else { // b must be the max
hue = 4.0f+(float)(r-g)/(float)delta;
hue=(float)(g1-b1)/(float)delta;
} else if (g1==max) {
hue= 2.0f+(float)(b1-r1)/(float)delta;
} else {
hue = 4.0f+(float)(r1-g1)/(float)delta;
}
}

View File

@@ -74,7 +74,8 @@ enum nsDTDMode {
eDTDMode_quirks, //pre 4.0 versions
eDTDMode_almost_standards,
eDTDMode_full_standards,
eDTDMode_autodetect
eDTDMode_autodetect,
eDTDMode_fragment
};

View File

@@ -40,6 +40,9 @@
#include "nsIHTMLContentSink.h"
#define NS_FRAGMENTSINK_CONTRACTID "@mozilla.org/layout/htmlfragmentsink;1"
#define NS_HTMLFRAGMENTSINK2_CONTRACTID "@mozilla.org/layout/htmlfragmentsink;2"
class nsIDOMDocumentFragment;
#define NS_IHTML_FRAGMENT_CONTENT_SINK_IID \

View File

@@ -73,6 +73,7 @@ class nsIChannel;
enum eParserCommands {
eViewNormal,
eViewSource,
eViewFragment,
eViewErrors
};

View File

@@ -1212,36 +1212,38 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
nsresult result=NS_OK;
PRBool theChildAgrees=PR_TRUE;
PRInt32 theIndex=mBodyContext->GetCount();
PRBool theChildIsContainer=nsHTMLElement::IsContainer(aChildTag);
PRBool theParentContains=-1;
if (mParserCommand != eViewFragment) {
PRBool theChildAgrees=PR_TRUE;
PRInt32 theIndex=mBodyContext->GetCount();
PRBool theParentContains=-1;
do {
do {
eHTMLTags theParentTag=mBodyContext->TagAt(--theIndex);
theParentContains=CanContain(theParentTag,aChildTag); //precompute containment, and pass it to CanOmit()...
eHTMLTags theParentTag=mBodyContext->TagAt(--theIndex);
theParentContains=CanContain(theParentTag,aChildTag); //precompute containment, and pass it to CanOmit()...
if(CanOmit(theParentTag,aChildTag,theParentContains)) {
result=HandleOmittedTag(aToken,aChildTag,theParentTag,aNode);
return result;
}
if(CanOmit(theParentTag,aChildTag,theParentContains)) {
result=HandleOmittedTag(aToken,aChildTag,theParentTag,aNode);
return result;
}
eProcessRule theRule=eNormalOp;
eProcessRule theRule=eNormalOp;
if((!theParentContains) &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if((!theParentContains) &&
(IsBlockElement(aChildTag,theParentTag) &&
IsInlineElement(theParentTag,theParentTag))) { //broaden this to fix <inline><block></block></inline>
if(eHTMLTag_li!=aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode= NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if(theParentNode->mToken->IsWellFormed()) {
theRule=eLetInlineContainBlock;
if(eHTMLTag_li!=aChildTag) { //remove test for table to fix 57554
nsCParserNode* theParentNode= NS_STATIC_CAST(nsCParserNode*, mBodyContext->PeekNode());
if(theParentNode->mToken->IsWellFormed()) {
theRule=eLetInlineContainBlock;
}
}
}
}
switch(theRule){
switch(theRule){
case eNormalOp:
@@ -1262,25 +1264,25 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
/*-------------------------------------------------------------------------------------
1 Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
/*-------------------------------------------------------------------------------------
1 Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
3. Fix for 26583
Ex. <A href=foo.html><B>foo<A href-bar.html>bar</A></B></A> <-- A legal HTML
In the above example clicking on "foo" or "bar" should link to
foo.html or bar.html respectively. That is, the inner <A> should be informed
about the presence of an open <A> above <B>..so that the inner <A> can close out
the outer <A>. The following code does it for us.
3. Fix for 26583
Ex. <A href=foo.html><B>foo<A href-bar.html>bar</A></B></A> <-- A legal HTML
In the above example clicking on "foo" or "bar" should link to
foo.html or bar.html respectively. That is, the inner <A> should be informed
about the presence of an open <A> above <B>..so that the inner <A> can close out
the outer <A>. The following code does it for us.
4. Fix for 27865 [ similer to 22596 ]. Ex: <DL><DD><LI>one<DD><LI>two
-------------------------------------------------------------------------------------*/
4. Fix for 27865 [ similer to 22596 ]. Ex: <DL><DD><LI>one<DD><LI>two
-------------------------------------------------------------------------------------*/
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
} //if
@@ -1319,8 +1321,9 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
default:
break;
}//switch
} while(!(theParentContains && theChildAgrees));
}//switch
} while(!(theParentContains && theChildAgrees));
}
if(theChildIsContainer){
result=OpenContainer(aNode,aChildTag,PR_TRUE);
@@ -2484,8 +2487,8 @@ CNavDTD::CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLine
* @param aChild -- tag enum of child container
* @return PR_TRUE if parent can contain child
*/
PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const
{
PRBool result=gHTMLElements[aParent].CanContain((eHTMLTags)aChild);
#ifdef ALLOW_TR_AS_CHILD_OF_TABLE

View File

@@ -1559,6 +1559,10 @@ nsresult nsParser::Parse(const nsAString& aSourceBuffer, void* aKey,
return result;
}
// hack to pass on to the dtd the caller's desire to
// parse a fragment without worrying about containment rules
if (aMode == eDTDMode_fragment)
mCommand = eViewFragment;
// Maintain a reference to ourselves so we don't go away
// till we're completely done.

View File

@@ -1,227 +0,0 @@
#! /usr/local/bin/perl5
use File::Path;
# The development branch is where primary development and checkins
# are done on a day-to-day basis.
$development_branch_prefix = "SpiderMonkey140";
# Space-separated list of CVS-controlled directories to tag/merge
$merge_dirs =
"mozilla/js/src " ;
# When line below uncommented, don't recurse into subdirs
#$recurse_flag = '-l';
#----------------------------------------------------------------------------
# The merge branch is itself a branch off of the development branch
# at a point where the development branch is thought to be stable.
# (A branch is used rather than a static tag because, inevitably,
# the development branch is not quite as stable/buildable as was
# thought.) The contents of the merge branch will be copied to
# the trunk when merging takes place.
# The following tags are created automatically by this script:
#
# JS_STABLE_DROP
#
# A static tag on the development branch (or a branch off the
# development branch) that indicates the code that should be merged
# into the trunk. This is a "variable" tag in the sense that it is
# redefined after each merge.
#
# JS_LAST_STABLE_DROP
#
# A static tag that is a copy of what the JS_STABLE_DROP tag was in
# the previous merge cycle. This is a "variable" tag that is
# redefined after each merge. Changes in the branch can be merged
# to the trunk by using:
#
# cvs up -jJS_LAST_STABLE_DROP -jJS_STABLE_DROP
#
# JS_LANDING
#
# A static tag that identifies the code on the trunk after the merge
# from the branch to the trunk takes place. This is a "variable"
# tag that is redefined after each merge. Changes on the trunk
# since the last branch landing can be seen by using:
#
# cvs diff -rJS_LANDING -rHEAD
#
# JS_LANDING_mmddyyyy
#
# This is a tag on the trunk which may be used for archaeological
# purposes. This tag is made from the JS_LANDING tag.
$development_branch = $development_branch_prefix . "_BRANCH";
$development_base = $development_branch_prefix . "_BASE";
sub help {
print <<"END";
$0: A tool for merging stable snapshots of JavaScript from a CVS
development branch onto the trunk
Landing a snapshot of the development branch consists of
the following steps:
1) Tag all/some files on the branch to identify files to be merged.
2) Merge files from the branch into the trunk using a temporary
working directory.
3) Resolve any conflicts that arise as a result of the merge.
4) Commit merged changes to the trunk.
5) Make changes to resolve (build) difficulties and re-commit.
Repeat as necessary.
6) Backpropagate changes on the trunk to the development branch.
This script will assist with steps #2, #4 and #6:
$0 -merge JS_STABLE_10131998
$0 -commit
$0 -backpatch
END
}
sub log {
local($msg) = @_;
print LOGFILE $msg if $logfile;
}
# Similar to die built-in
sub die {
local($msg) = @_;
&log($msg);
chomp($msg);
if ($logfile) {
$msg .= "\nSee $logfile for details.";
}
die "$msg\n";
}
# Similar to system() built-in
sub system {
local(@args) = @_;
local($cmd) = join(" ", @args);
&log("Executing: $cmd\n");
if ($logfile) {
$cmd .= " >> $logfile 2>&1";
close(LOGFILE);
}
local($result) = 0xffff & system($cmd);
if ($logfile) {
open(LOGFILE, ">>$logfile");
}
return unless ($result);
$msg = "Died while executing $cmd";
if ($result == 0xff00) {
&die("$msg\nWhile executExecution failed due to perl error: $!. ");
} else {
$result >>= 8;
&die("$msg\nExecution failed; exit status: $result. ");
}
}
chomp($root_dir = `pwd`);
# Default log file
$logfile = $root_dir . "/log";
while ($#ARGV >=0) {
$_ = shift;
if (/-merge/) {
$do_tag = 1;
$do_checkout = 1;
$do_merge = 1;
$tag = shift;
} elsif (/-commit/ || /-ci/) {
$do_commit = 1;
} elsif (/-backpatch/) {
$do_backpatch = 1;
} elsif (/-log/) {
$logfile = shift;
} elsif (/-tag/) { # Debugging option
$do_tag = 1;
$tag = shift;
} elsif (/-co/) { # Debugging option
$do_checkout = 1;
} else {
print STDERR "Illegal option: $_\n" unless (/-h/);
&help();
exit(1);
}
}
die "You must set your CVSROOT environment variable" if !$ENV{"CVSROOT"};
if ($logfile) {
open(LOGFILE, ">$logfile") || die "Couldn't open log file \"$logfile\"";
print("Logging to file \"$logfile\".\n");
}
$trunk_dir = $root_dir . "/trunk";
if ($do_tag) {
if (!$tag) {
&die("Must specify tag on command-line\n");
}
print("Tagging tree with tag JS_STABLE_DROP.\n");
&system("cvs rtag $recurse_flag -F -r $tag JS_STABLE_DROP $merge_dirs");
}
if ($do_checkout) {
# Delete trunk subdir if it already exists
if (-d $trunk_dir) {
&log("Deleting directory $trunk_dir\n");
rmtree ($trunk_dir, 0, 1);
}
&log("Creating directory $trunk_dir\n");
mkdir($trunk_dir, 0777) || die "Couldn't create directory $trunk_dir";
# Check out on trunk
print("Checking out $merge_dirs.\n");
chdir $trunk_dir;
&system("cvs co $recurse_flag -A $merge_dirs");
}
if ($do_merge) {
chdir $trunk_dir;
print("Merging from JS_STABLE_DROP into trunk\n");
&system("cvs up -jJS_LAST_STABLE_DROP -jJS_STABLE_DROP");
}
if ($do_commit) {
&die("No merged tree found. Wrong directory ?") if (!chdir $trunk_dir);
($_,$_,$_,$day,$mon,$year,$_,$_) = localtime(time());
if ($year < 30) {
$year = "20" . $year;
} else {
$year = "19" . $year;
}
$mmddyyyy = sprintf("%02d%02d%s", $mon, $day, $year);
print("Checking in code on trunk");
&system("cvs ci -m 'Stable drop of JavaScript interpreter code from " .
"$development_branch'");
# Tag merged result
&system("cvs tag -F JS_LANDING");
&system("cvs tag -F JS_LANDING_$mmddyyyy");
# Move JS_LAST_STABLE_DROP tag forward
&system("cvs tag -F -rJS_STABLE_DROP JS_LAST_STABLE_DROP");
}

View File

@@ -214,6 +214,7 @@ extern nsresult NS_NewHTMLContentSink(nsIHTMLContentSink** aInstancePtrResult,
nsIWebShell* aWebShell,
nsIChannel* aChannel);
extern nsresult NS_NewHTMLFragmentContentSink(nsIHTMLFragmentContentSink** aInstancePtrResult);
extern nsresult NS_NewHTMLFragmentContentSink2(nsIHTMLFragmentContentSink** aInstancePtrResult);
/** Create a new HTML reflow command */
extern nsresult

View File

@@ -0,0 +1,137 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@mozilla.org>
* Randell Jesup <rjesup@wgate.com>
* Chris Waterson <waterson@netscape.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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include "pldhash.h"
#include "prenv.h"
#include "nsReflowPath.h"
#include "nsFrame.h"
#include "nsIFrame.h"
#include "nsHTMLReflowCommand.h"
nsReflowPath::~nsReflowPath()
{
for (PRInt32 i = mChildren.Count() - 1; i >= 0; --i)
delete NS_STATIC_CAST(nsReflowPath *, mChildren[i]);
delete mReflowCommand;
#ifdef DEBUG
::memset(this, 0xdd, sizeof(*this));
#endif
}
nsReflowPath::iterator
nsReflowPath::FindChild(nsIFrame *aFrame)
{
for (PRInt32 i = mChildren.Count() - 1; i >= 0; --i) {
nsReflowPath *subtree = NS_STATIC_CAST(nsReflowPath *, mChildren[i]);
if (subtree->mFrame == aFrame)
return iterator(this, i);
}
return iterator(this, -1);
}
nsReflowPath *
nsReflowPath::GetSubtreeFor(nsIFrame *aFrame) const
{
for (PRInt32 i = mChildren.Count() - 1; i >= 0; --i) {
nsReflowPath *subtree = NS_STATIC_CAST(nsReflowPath *, mChildren[i]);
if (subtree->mFrame == aFrame)
return subtree;
}
return nsnull;
}
nsReflowPath *
nsReflowPath::EnsureSubtreeFor(nsIFrame *aFrame)
{
for (PRInt32 i = mChildren.Count() - 1; i >= 0; --i) {
nsReflowPath *subtree = NS_STATIC_CAST(nsReflowPath *, mChildren[i]);
if (subtree->mFrame == aFrame)
return subtree;
}
nsReflowPath *subtree = new nsReflowPath(aFrame);
mChildren.AppendElement(subtree);
return subtree;
}
void
nsReflowPath::Remove(iterator &aIterator)
{
NS_ASSERTION(aIterator.mNode == this, "inconsistent iterator");
if (aIterator.mIndex >= 0 && aIterator.mIndex < mChildren.Count()) {
delete NS_STATIC_CAST(nsReflowPath *, mChildren[aIterator.mIndex]);
mChildren.RemoveElementAt(aIterator.mIndex);
}
}
#ifdef DEBUG
void
DebugListReflowPath(nsIPresContext *aPresContext, nsReflowPath *aReflowPath)
{
aReflowPath->Dump(aPresContext, stdout, 0);
}
void
nsReflowPath::Dump(nsIPresContext *aPresContext, FILE *aFile, int depth)
{
fprintf(aFile, "%*s nsReflowPath(%p): ", depth, "", this);
nsFrame::ListTag(aFile, mFrame);
if (mReflowCommand) {
fprintf(aFile, " <- ");
mReflowCommand->List(aFile);
}
fprintf(aFile, "\n");
for (PRInt32 i = 0; i < mChildren.Count(); ++i) {
nsReflowPath *child = NS_STATIC_CAST(nsReflowPath *, mChildren[i]);
child->Dump(aPresContext, aFile, depth + 1);
}
}
#endif

View File

@@ -0,0 +1,232 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mike Shaver <shaver@mozilla.org>
* Randell Jesup <rjesup@wgate.com>
* Chris Waterson <waterson@netscape.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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsReflowPath_h__
#define nsReflowPath_h__
#include "nscore.h"
#include "pldhash.h"
#include "nsReflowType.h"
#include "nsVoidArray.h"
#ifdef DEBUG
#include <stdio.h>
#endif
class nsIFrame;
class nsHTMLReflowCommand;
class nsIPresContext;
/**
* A reflow `path' that is a sparse tree the parallels the frame
* hierarchy. This is used during an incremental reflow to record the
* path which the reflow must trace through the frame hierarchy.
*/
class nsReflowPath
{
public:
/**
* Construct a reflow path object that parallels the specified
* frame.
*/
nsReflowPath(nsIFrame *aFrame)
: mFrame(aFrame),
mReflowCommand(nsnull) {}
~nsReflowPath();
/**
* An iterator for enumerating the reflow path's immediate
* children.
*/
class iterator
{
protected:
nsReflowPath *mNode;
PRInt32 mIndex;
friend class nsReflowPath;
iterator(nsReflowPath *aNode, PRInt32 aIndex)
: mNode(aNode), mIndex(aIndex) {}
void
Advance() { --mIndex; }
public:
iterator()
: mNode(nsnull) {}
iterator(const iterator &iter)
: mNode(iter.mNode), mIndex(iter.mIndex) {}
iterator &
operator=(const iterator &iter) {
mNode = iter.mNode;
mIndex = iter.mIndex;
return *this; }
nsReflowPath *
get() const {
return NS_STATIC_CAST(nsReflowPath *, mNode->mChildren[mIndex]); }
nsReflowPath *
get() {
return NS_STATIC_CAST(nsReflowPath *, mNode->mChildren[mIndex]); }
nsIFrame *
operator*() const {
return get()->mFrame; }
nsIFrame *&
operator*() {
return get()->mFrame; }
iterator &
operator++() { Advance(); return *this; }
iterator
operator++(int) {
iterator temp(*this);
Advance();
return temp; }
PRBool
operator==(const iterator &iter) const {
return (mNode == iter.mNode) && (mIndex == iter.mIndex); }
PRBool
operator!=(const iterator &iter) const {
return !iter.operator==(*this); }
};
/**
* Return an iterator that points to the first immediate child of
* the reflow path.
*/
iterator FirstChild() { return iterator(this, mChildren.Count() - 1); }
/**
* Return an iterator that points `one past the end' of the
* immediate children of the reflow path.
*/
iterator EndChildren() { return iterator(this, -1); }
/**
* Determine if the reflow path contains the specified frame as
* one of its immediate children.
*/
PRBool
HasChild(nsIFrame *aFrame) const {
return GetSubtreeFor(aFrame) != nsnull; }
/**
* Return an iterator over the current reflow path that
* corresponds to the specified child frame. Returns EndChildren
* if aFrame is not an immediate child of the reflow path.
*/
iterator
FindChild(nsIFrame *aFrame);
/**
* Remove the specified child frame from the reflow path, along
* with any of its descendants. Does nothing if aFrame is not an
* immediate child of the reflow path.
*/
void
RemoveChild(nsIFrame *aFrame) {
iterator iter = FindChild(aFrame);
Remove(iter); }
/**
* Return the child reflow path that corresponds to the specified
* frame, or null if the frame is not an immediate descendant.
*/
nsReflowPath *
GetSubtreeFor(nsIFrame *aFrame) const;
/**
* Return the child reflow path that corresponds to the specified
* frame, constructing a new child reflow path if one doesn't
* exist already.
*/
nsReflowPath *
EnsureSubtreeFor(nsIFrame *aFrame);
/**
* Remove the child reflow path that corresponds to the specified
* iterator.
*/
void
Remove(iterator &aIterator);
#ifdef DEBUG
/**
* Recursively dump the reflow path object and its descendants.
*/
void
Dump(nsIPresContext *aPresContext, FILE *aFile, int aDepth);
#endif
/**
* The frame that this reflow path object is associated with.
*/
nsIFrame *mFrame;
/**
* If mFrame is the immediate target of an incremental reflow,
* this contains the reflow command that targeted it. Otherwise,
* this is null (and mFrame simply lies along the path to a target
* frame). The reflow path object assumes ownership of the reflow
* command.
*/
nsHTMLReflowCommand *mReflowCommand;
protected:
/**
* The children of this reflow path; also contains pointers to
* nsReflowPath objects.
*/
nsSmallVoidArray mChildren;
friend class iterator;
};
#endif

View File

@@ -1,149 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Simon Fraser sfraser@netscape.com
*/
/*
About this file
---------------
This file contains some handy macros, and a stack-based class that makes
instrumenting functions with Apple's Instrumentation SDK easier.
Instrumentation SDK
-------------------
The Instrumentation SDK allows you to do code performance analysis,
collecting time-based data, and other data by putting instrumentation
points in your code, and running.
You can get the instrumentation SDK from:
ftp://ftp.apple.com/developer/Development_Kits/Instrumentation_SDK.hqx
To find out how to use the Instrumentation Toolkit, read the documentation
that comes with the SDK. I'm not going to explain all that here.
Setting up your tree
--------------------
Put the headers and libraries from the Instrumentation SDK into
a folder in your CodeWarrior 'Mac OS Support' folder.
How to use
----------
In C++ code, the following macros can be used thusly:
NS_IMETHODIMP nsBigThing::SlowFunction()
{
INST_TRACE("SomeLocationDescription"); // Descriptive label. Don't use :: here.
// code that might return anywhere.
...
return NS_OK;
}
Because the INST_TRACE macro makes a stack-based StInstrumentationLog,
exit from the function will be traced wherever it occurs.
You will also need to add the "InstrumentationLib" stub library to the
project.
Such instrumentation points will give you data for the
'Trace Time Line Viewer' in the viewer. There are many other types
of instrumentation data you can collect; see the docs in the SDK
for more information.
Stalking the wild time sink
---------------------------
Your general strategy when using the Instrumentation tools to
track down performance problems should be to start at the high
level, then drill down into subroutines. You want to avoid
instrumenting routines that are called hundreds of thousands
of times, because you'll end up with massive data files. Rather,
instrument their calling routines to get a good sense of where
the time goes.
This kind of performance analysis does not replace the more
traditional profiling tools. Rather, it allows you to analyse
performance problems in terms of behaviour and timing, rather
than a simply overview of % of time spent in different routines.
*/
#include <InstrumentationMacros.h>
#ifdef __cplusplus
/* Stack-based class to do logging */
class StInstrumentationLog
{
public:
StInstrumentationLog(const char* traceName, InstTraceClassRef &ioTraceClassRef)
{
if (ioTraceClassRef == 0)
{
if (InstCreateTraceClass( kInstRootClassRef, traceName, 0, kInstEnableClassMask, &ioTraceClassRef) != noErr)
{
DebugStr("\pFailed to make instrumentation trace class");
return;
}
}
mTraceClassRef = ioTraceClassRef;
mEventTag = InstCreateEventTag();
InstLogTraceEvent(mTraceClassRef, mEventTag, kInstStartEvent);
}
~StInstrumentationLog()
{
InstLogTraceEvent(mTraceClassRef, mEventTag, kInstEndEvent);
}
void LogMiddleEvent()
{
InstLogTraceEvent(mTraceClassRef, mEventTag, kInstMiddleEvent);
}
void LogMiddleEventWithData(const char* inFormatString, void* inEventData)
{
InstDataDescriptorRef dataDesc;
InstCreateDataDescriptor(inFormatString, &dataDesc);
InstLogTraceEventWithData(mTraceClassRef, mEventTag, kInstMiddleEvent, dataDesc, inEventData);
InstDisposeDataDescriptor(dataDesc);
}
protected:
InstTraceClassRef mTraceClassRef;
InstEventTag mEventTag;
};
#define INST_TRACE(n) static InstTraceClassRef __sTrace = 0; StInstrumentationLog traceLog((n), __sTrace)
#define INST_TRACE_MIDDLE do { traceLog.LogMiddleEvent(); } while(0)
#define INST_TRACE_DATA(s, d) do { traceLog.LogMiddleEventWithData((s), (d)); } while (0)
#endif /* __cplusplus */

View File

@@ -1 +0,0 @@
InstrumentationHelpers.h

View File

@@ -0,0 +1,289 @@
/* ***** 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 Communicator.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* 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 ***** */
/* We expect the following arguments:
- pref name of LDAP directory to fetch from
- array with email addresses
Display modal dialog with message and stop button.
In onload, kick off binding to LDAP.
When bound, kick off the searches.
On finding certificates, import into permanent cert database.
When all searches are finished, close the dialog.
*/
const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
const CertAttribute = "usercertificate;binary";
var gEmailAddresses;
var gDirectoryPref;
var gLdapServerURL;
var gLdapConnection;
var gCertDB;
var gLdapOperation;
function onLoad()
{
gDirectoryPref = window.arguments[0];
gEmailAddresses = window.arguments[1];
if (!gEmailAddresses.length)
{
window.close();
return;
}
setTimeout(search, 1);
}
function search()
{
var prefService =
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getBranch(null);
gLdapServerURL =
Components.classes["@mozilla.org/network/ldap-url;1"]
.createInstance().QueryInterface(Components.interfaces.nsILDAPURL);
try {
gLdapServerURL.spec = prefs.getCharPref(gDirectoryPref + ".uri");
gLdapConnection = Components.classes["@mozilla.org/network/ldap-connection;1"]
.createInstance().QueryInterface(Components.interfaces.nsILDAPConnection);
gLdapConnection.init(
gLdapServerURL.asciiHost,
gLdapServerURL.port,
gLdapServerURL.options,
null,
getProxyOnUIThread(new boundListener(),
Components.interfaces.nsILDAPMessageListener));
} catch (ex) {
window.close();
}
}
function stopFetching()
{
if (gLdapOperation) {
try {
gLdapOperation.abandon();
}
catch (e) {
}
}
window.close();
}
function importCert(ber_value)
{
if (!gCertDB) {
gCertDB = Components.classes[nsX509CertDB].getService(nsIX509CertDB);
}
var cert_length = new Object();
var cert_bytes = ber_value.get(cert_length);
if (cert_bytes) {
gCertDB.importEmailCertificate2(cert_length.value, cert_bytes);
}
}
function kickOffBind()
{
try {
gLdapOperation = Components.classes["@mozilla.org/network/ldap-operation;1"]
.createInstance().QueryInterface(Components.interfaces.nsILDAPOperation);
gLdapOperation.init(gLdapConnection,
getProxyOnUIThread(new ldapMessageListener(),
Components.interfaces.nsILDAPMessageListener));
gLdapOperation.simpleBind(null);
}
catch (e) {
window.close();
}
}
function kickOffSearch()
{
try {
var prefix1 = "";
var suffix1 = "";
var urlFilter = gLdapServerURL.filter;
if (urlFilter != null && urlFilter.length > 0 && urlFilter != "(objectclass=*)") {
if (urlFilter[0] == '(') {
prefix1 = "(&" + urlFilter;
}
else {
prefix1 = "(&(" + urlFilter + ")";
}
suffix1 = ")";
}
var prefix2 = "";
var suffix2 = "";
if (gEmailAddresses.length > 1) {
prefix2 = "(|";
suffix2 = ")";
}
var mailFilter = "";
for (var i = 0; i < gEmailAddresses.length; ++i) {
mailFilter += "(mail=" + gEmailAddresses[i] + ")";
}
var filter = prefix1 + prefix2 + mailFilter + suffix2 + suffix1;
var wanted_attributes = new Array();
wanted_attributes[0] = CertAttribute;
// Max search results =>
// Double number of email addresses, because each person might have
// multiple certificates listed. We expect at most two certificates,
// one for signing, one for encrypting.
// Maybe that number should be larger, to allow for deployments,
// where even more certs can be stored per user???
var maxEntriesWanted = gEmailAddresses.length * 2;
gLdapOperation.searchExt(gLdapServerURL.dn, gLdapServerURL.scope,
filter, 1, wanted_attributes, 0, maxEntriesWanted);
}
catch (e) {
window.close();
}
}
function boundListener() {
}
boundListener.prototype.QueryInterface =
function(iid) {
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(Components.interfaces.nsILDAPMessageListener))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
boundListener.prototype.onLDAPMessage =
function(aMessage) {
}
boundListener.prototype.onLDAPInit =
function(aStatus) {
kickOffBind();
}
function ldapMessageListener() {
}
ldapMessageListener.prototype.QueryInterface =
function(iid) {
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(Components.interfaces.nsILDAPMessageListener))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
ldapMessageListener.prototype.onLDAPMessage =
function(aMessage) {
if (Components.interfaces.nsILDAPMessage.RES_SEARCH_RESULT == aMessage.type) {
window.close();
return;
}
if (Components.interfaces.nsILDAPMessage.RES_BIND == aMessage.type) {
if (Components.interfaces.nsILDAPErrors.SUCCESS != aMessage.errorCode) {
window.close();
}
else {
kickOffSearch();
}
return;
}
if (Components.interfaces.nsILDAPMessage.RES_SEARCH_ENTRY == aMessage.type) {
var outSize = new Object();
try {
var outBinValues = aMessage.getBinaryValues(CertAttribute, outSize);
var i;
for (i=0; i < outSize.value; ++i) {
importCert(outBinValues[i]);
}
}
catch (e) {
}
return;
}
}
ldapMessageListener.prototype.onLDAPInit =
function(aStatus) {
}
function getProxyOnUIThread(aObject, aInterface) {
var eventQSvc = Components.
classes["@mozilla.org/event-queue-service;1"].
getService(Components.interfaces.nsIEventQueueService);
var uiQueue = eventQSvc.
getSpecialEventQueue(Components.interfaces.
nsIEventQueueService.UI_THREAD_EVENT_QUEUE);
var proxyMgr = Components.
classes["@mozilla.org/xpcomproxy;1"].
getService(Components.interfaces.nsIProxyObjectManager);
return proxyMgr.getProxyForObject(uiQueue,
aInterface, aObject, 5);
// 5 == PROXY_ALWAYS | PROXY_SYNC
}

View File

@@ -0,0 +1,65 @@
<?xml version="1.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 Communicator
-
- The Initial Developer of the Original Code is
- Netscape Communications Corp..
- Portions created by the Initial Developer are Copyright (C) 2002
- 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 LGPL or the GPL. 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 ***** -->
<?xml-sheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/smime/certFetchingStatus.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://messenger-smime/locale/certFetchingStatus.dtd">
<window id="certFetchingStatus" title="&title.label;"
class="dialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="width: 50em;"
onload="onLoad();">
<script type="application/x-javascript" src="chrome://messenger-smime/content/certFetchingStatus.js"/>
<vbox>
<description>&info.message;</description>
<separator class="thin"/>
<hbox align="center">
<button id="stopButton"
label="&stop.label;"
oncommand="stopFetching();"/>
</hbox>
</vbox>
</window>

View File

@@ -0,0 +1,54 @@
#
# 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 Netscape are
# Copyright (C) 2001 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Christian Biesinger <cbiesinger@web.de>
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = imgxbm
LIBRARY_NAME = imgxbm
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsXBMModule
ifeq ($(OS_ARCH),WINNT)
EXTRA_DSO_LIBS = gkgfx
endif
REQUIRES = xpcom \
gfx \
gfx2 \
imglib2 \
string \
$(NULL)
CPPSRCS = nsXBMDecoder.cpp nsXBMModule.cpp
EXTRA_DSO_LDOPTS = \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,51 @@
#!nmake
#
# 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 Netscape are
# Copyright (C) 2001 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Christian Biesinger <cbiesinger@web.de>
#
DEPTH=..\..\..\..
MODULE = imgxbm
REQUIRES = xpcom \
necko \
gfx \
gfx2 \
imglib2 \
string \
$(NULL)
include <$(DEPTH)/config/config.mak>
LIBRARY_NAME = imgxbm
MODULE_NAME = nsXBMModule
OBJS = \
.\$(OBJDIR)\nsXBMModule.obj \
.\$(OBJDIR)\nsXBMDecoder.obj \
$(NULL)
LLIBS=\
$(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\gkgfx.lib \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,247 @@
/* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/LGPL 2.1/GPL 2.0
*
* 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 the Mozilla XBM Decoder.
*
* The Initial Developer of the Original Code is Christian Biesinger
* <cbiesinger@web.de>. Portions created by Christian Biesinger are
* Copyright (C) 2001 Christian Biesinger. 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 LGPL or the GPL. 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 ----- */
/* KNOWN BUGS:
* o first #define line is assumed to be width, second height */
#include <string.h>
#include <stdlib.h>
#include "nsXBMDecoder.h"
#include "nsIInputStream.h"
#include "nsIComponentManager.h"
#include "nsIImage.h"
#include "nsMemory.h"
#include "imgIContainerObserver.h"
#include "nsRect.h"
#include "nsReadableUtils.h"
#include "imgILoad.h"
NS_IMPL_ISUPPORTS1(nsXBMDecoder, imgIDecoder)
nsXBMDecoder::nsXBMDecoder() : mBuf(nsnull), mPos(nsnull), mRow(nsnull)
{
NS_INIT_ISUPPORTS();
}
nsXBMDecoder::~nsXBMDecoder()
{
if (mBuf)
free(mBuf);
if (mRow)
delete[] mRow;
}
NS_IMETHODIMP nsXBMDecoder::Init(imgILoad *aLoad)
{
nsresult rv;
mObserver = do_QueryInterface(aLoad);
mImage = do_CreateInstance("@mozilla.org/image/container;1", &rv);
if (NS_FAILED(rv))
return rv;
mFrame = do_CreateInstance("@mozilla.org/gfx/image/frame;2", &rv);
if (NS_FAILED(rv))
return rv;
aLoad->SetImage(mImage);
mCurRow = mBufSize = mWidth = mHeight = 0;
mState = RECV_HEADER;
return NS_OK;
}
NS_IMETHODIMP nsXBMDecoder::Close()
{
mObserver->OnStopContainer(nsnull, nsnull, mImage);
mObserver->OnStopDecode(nsnull, nsnull, NS_OK, nsnull);
mObserver = nsnull;
mImage = nsnull;
mFrame = nsnull;
if (mRow) {
delete[] mRow;
mRow = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP nsXBMDecoder::Flush()
{
mFrame->SetMutable(PR_FALSE);
return NS_OK;
}
NS_METHOD nsXBMDecoder::ReadSegCb(nsIInputStream* aIn, void* aClosure,
const char* aFromRawSegment, PRUint32 aToOffset,
PRUint32 aCount, PRUint32 *aWriteCount) {
nsXBMDecoder *decoder = NS_REINTERPRET_CAST(nsXBMDecoder*, aClosure);
*aWriteCount = aCount;
return decoder->ProcessData(aFromRawSegment, aCount);
}
NS_IMETHODIMP nsXBMDecoder::WriteFrom(nsIInputStream *aInStr, PRUint32 aCount, PRUint32 *aRetval)
{
return aInStr->ReadSegments(ReadSegCb, this, aCount, aRetval);
}
nsresult nsXBMDecoder::ProcessData(const char* aData, PRUint32 aCount) {
char *endPtr;
// calculate the offset since the absolute position might no longer
// be valid after realloc
const PRPtrdiff posOffset = mPos ? (mPos - mBuf) : 0;
mBuf = (char*)realloc(mBuf, mBufSize + aCount + 1);
if (!mBuf) {
mState = RECV_DONE;
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(mBuf + mBufSize, aData, aCount);
mBufSize += aCount;
mBuf[mBufSize] = 0;
mPos = mBuf + posOffset;
if (mState == RECV_HEADER) {
mPos = strstr(mBuf, "#define");
if (!mPos)
// #define not found. return for now, waiting for more data.
return NS_OK;
// Convert width and height to numbers
if (sscanf(mPos, "#define %*s %d #define %*s %d", &mWidth, &mHeight) != 2)
return NS_OK;
mImage->Init(mWidth, mHeight, mObserver);
mObserver->OnStartContainer(nsnull, nsnull, mImage);
nsresult rv = mFrame->Init(0, 0, mWidth, mHeight, GFXFORMAT);
if (NS_FAILED(rv))
return rv;
mImage->AppendFrame(mFrame);
mObserver->OnStartFrame(nsnull, nsnull, mFrame);
PRUint32 bpr;
mFrame->GetImageBytesPerRow(&bpr);
mRow = new PRUint8[bpr];
mState = RECV_SEEK;
mCurRow = 0;
mCurCol = 0;
}
if (mState == RECV_SEEK) {
if ((endPtr = strchr(mPos, '{')) != NULL) {
mPos = endPtr+1;
mState = RECV_DATA;
} else {
mPos = mBuf + mBufSize;
return NS_OK;
}
}
if (mState == RECV_DATA) {
#if defined(XP_MAC) || defined(XP_MACOSX)
// bytes per pixel
const PRUint32 bpp = 4;
#else
const PRUint32 bpp = 3;
#endif
PRUint32 bpr;
mFrame->GetImageBytesPerRow(&bpr);
do {
PRUint32 pixel = strtoul(mPos, &endPtr, 0);
if (endPtr == mPos)
return NS_OK; // no number to be found - need more data
if (!*endPtr)
return NS_OK; // number at the end - might be missing a digit
if (pixel == 0 && *endPtr == 'x')
return NS_OK; // 0x at the end, actual number is missing
while (*endPtr && isspace(*endPtr))
endPtr++; // skip whitespace looking for comma
if (*endPtr && (*endPtr != ',')) {
*endPtr = '\0';
mState = RECV_DONE; // strange character (or ending '}')
}
mPos = endPtr;
for (int i = 1; i <= 128; i <<= 1) {
// if bit is set, use black, else white
PRUint8 val = (pixel & i) ? 0 : 255;
#if defined(XP_MAC) || defined(XP_MACOSX)
#define DATA_OFFSET 1
mRow[mCurCol * bpp] = 0; // padding byte
#else
#define DATA_OFFSET 0
#endif
for (int j = DATA_OFFSET; j < (DATA_OFFSET + 3); j++)
mRow[mCurCol * bpp + j] = val;
mCurCol++;
if (mCurCol == mWidth)
break;
}
if (mCurCol == mWidth || mState == RECV_DONE) {
// Row finished. Set Data.
mFrame->SetImageData(mRow, bpr, mCurRow * bpr);
nsRect r(0, (mCurRow + 1), mWidth, 1);
mObserver->OnDataAvailable(nsnull, nsnull, mFrame, &r);
if ((mCurRow + 1) == mHeight) {
mState = RECV_DONE;
return mObserver->OnStopFrame(nsnull, nsnull, mFrame);
}
mCurRow++;
mCurCol = 0;
}
mPos++;
} while (*mPos && (mState == RECV_DATA));
}
else
return NS_ERROR_FAILURE;
return NS_OK;
}

View File

@@ -0,0 +1,104 @@
/* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/LGPL 2.1/GPL 2.0
*
* 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 the Mozilla XBM Decoder.
*
* The Initial Developer of the Original Code is Christian Biesinger
* <cbiesinger@web.de>. Portions created by Christian Biesinger are
* Copyright (C) 2001 Christian Biesinger. 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 LGPL or the GPL. 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 _nsXBMDecoder_h
#define _nsXBMDecoder_h
#include "nsCOMPtr.h"
#include "imgIDecoder.h"
#include "imgIContainer.h"
#include "imgIDecoderObserver.h"
#include "gfxIImageFrame.h"
#define NS_XBMDECODER_CID \
{ /* {dbfd145d-3298-4f3c-902f-2c5e1a1494ce} */ \
0xdbfd145d, \
0x3298, \
0x4f3c, \
{ 0x90, 0x2f, 0x2c, 0x5e, 0x1a, 0x14, 0x94, 0xce } \
}
#if defined(XP_PC) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON)
#define GFXFORMAT gfxIFormats::BGR
#else
#define USE_RGB
#define GFXFORMAT gfxIFormats::RGB
#endif
class nsXBMDecoder : public imgIDecoder
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGIDECODER
nsXBMDecoder();
virtual ~nsXBMDecoder();
nsresult ProcessData(const char* aData, PRUint32 aCount);
private:
static NS_METHOD ReadSegCb(nsIInputStream* aIn, void* aClosure,
const char* aFromRawSegment, PRUint32 aToOffset,
PRUint32 aCount, PRUint32 *aWriteCount);
nsCOMPtr<imgIDecoderObserver> mObserver;
nsCOMPtr<imgIContainer> mImage;
nsCOMPtr<gfxIImageFrame> mFrame;
PRInt32 mCurRow;
PRInt32 mCurCol;
char* mBuf; // Holds the received data
char* mPos;
PRUint32 mBufSize; // number of bytes in mBuf
PRInt32 mWidth;
PRInt32 mHeight;
PRUint8* mRow; // Hold the decoded row
enum {
RECV_HEADER,
RECV_SEEK,
RECV_DATA,
RECV_DONE
} mState;
};
#endif

View File

@@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4:
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chris Saari <saari@netscape.com>
* Christian Biesinger <cbiesinger@web.de>
* David Hyatt <hyatt@netscape.com>
*/
#include "nsXBMDecoder.h"
#include "nsIComponentManager.h"
#include "nsIGenericFactory.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXBMDecoder)
static nsModuleComponentInfo components[] =
{
{ "XBM Decoder",
NS_XBMDECODER_CID,
"@mozilla.org/image/decoder;2?type=image/x-xbitmap",
nsXBMDecoderConstructor, },
{ "XBM Decoder",
NS_XBMDECODER_CID,
"@mozilla.org/image/decoder;2?type=image/x-xbm",
nsXBMDecoderConstructor, },
{ "XBM Decoder",
NS_XBMDECODER_CID,
"@mozilla.org/image/decoder;2?type=image/xbm",
nsXBMDecoderConstructor, },
};
NS_IMPL_NSGETMODULE(nsXBMModule, components)

File diff suppressed because one or more lines are too long

View File

@@ -1,22 +0,0 @@
The subdirectories of the other-licenses directory contain Mozilla-related
source code that is _not_ licensed under the traditional Mozilla licensing
schemes (i.e., the Mozilla Public License, Netscape Public License, MPL/GPL
or NPL/GPL dual licenses, or the MPL/GPL/LGPL or NPL/GPL/LGPL tri-licenses).
In particular, the requirements imposed by the license terms for the source
code in the other-licenses directory may be different from the requirements
imposed by the terms of the MPL or NPL.
For example, when distributing some or all of this source code (or binary
executable products based on it) you may be required to provide additional
notices to those to whom you distribute the source code or executables,
above and beyond those notices required by the MPL or NPL for other Mozilla
code. The licenses for some or all of this source code may also impose
additional restrictions on the uses that you or others may make of the code,
restrictions not imposed by the MPL or NPL.
For complete information on the terms on which you can use this source code,
and the requirements placed upon you and people to whom you distribute the
source code or executables incorporating it, please read the information
files (e.g,, README, LICENSE, and/or COPYING) in the individual sub-
directories of the other-licenses directory. If you have any further
questions after reading this information, please contact staff@mozilla.org.

View File

@@ -1,11 +0,0 @@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = Xrender fontconfig Xft
include $(topsrcdir)/config/rules.mk

View File

@@ -1,47 +0,0 @@
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = Xft/X11/Xft
LIBRARY_NAME = Xft
EXPORT_LIBRARY = 1
EXPORTS = \
Xft.h \
XftCompat.h
REQUIRES = \
freetype2 \
fontconfig \
Xrender
CSRCS = \
xftcolor.c \
xftdbg.c \
xftdpy.c \
xftdraw.c \
xftextent.c \
xftfont.c \
xftinit.c \
xftlist.c \
xftname.c \
xftstr.c \
xftswap.c \
xftxlfd.c \
xftfreetype.c \
xftglyphs.c \
xftrender.c \
xftcore.c
# make it a static lib only
FORCE_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk
ifdef MOZ_XFT_SYSTEM_FREETYPE2
CFLAGS += $(FT2_CFLAGS)
endif

View File

@@ -1,150 +0,0 @@
LIBRARY Xft
VERSION LIBRARY_VERSION
EXPORTS
XftConfigAddDir
XftConfigAddEdit
XftConfigGetCache
XftConfigSetCache
XftConfigSubstitute
_XftConfigCompareValue
XftColorAllocName
XftColorAllocValue
XftColorFree
XftCoreConvert16
XftCoreConvert32
XftCoreConvertUtf8
XftCoreExtents16
XftCoreExtents32
XftCoreExtents8
XftCoreExtentsUtf8
XftCoreGlyphExists
XftEditPrint
XftExprPrint
XftFontSetPrint
XftOpPrint
XftPatternPrint
XftSubstPrint
XftTestPrint
XftValueListPrint
XftValuePrint
XftDefaultGetBool
XftDefaultGetDouble
XftDefaultGetInteger
XftDefaultHasRender
XftDefaultParseBool
XftDefaultSet
XftDefaultSubstitute
XftDisplayGetFontSet
XftDrawChange
XftDrawCorePrepare
XftDrawCreate
XftDrawCreateBitmap
XftDrawDestroy
XftDrawRect
XftDrawRenderPrepare
XftDrawSetClip
XftDrawString16
XftDrawString32
XftDrawString8
XftDrawStringUtf8
XftTextExtents16
XftTextExtents32
XftTextExtents8
XftTextExtentsUtf8
XftFontClose
XftFontMatch
XftFontOpen
XftFontOpenName
XftFontOpenPattern
XftFontOpenXlfd
XftGlyphExists
_XftFontDebug
XftFontSetAdd
XftFontSetCreate
XftFontSetDestroy
XftConfigSaveField
XftConfigerror
XftConfigparse
XftConfigwrap
XftEditCreate
XftEditDestroy
XftExprCreateBool
XftExprCreateDouble
XftExprCreateField
XftExprCreateInteger
XftExprCreateNil
XftExprCreateOp
XftExprCreateString
XftExprDestroy
XftTestCreate
XftInit
XftConfigLexFile
XftConfigPushInput
XftConfig_create_buffer
XftConfig_delete_buffer
XftConfig_flush_buffer
XftConfig_init_buffer
XftConfig_load_buffer_state
XftConfig_scan_buffer
XftConfig_scan_bytes
XftConfig_scan_string
XftConfig_switch_to_buffer
XftConfiglex
XftConfigrestart
XftListAppend
XftListFontSets
XftListFonts
XftListFontsPatternObjects
XftListMatch
XftListValueCompare
XftListValueListCompare
XftObjectSetAdd
XftObjectSetBuild
XftObjectSetCreate
XftObjectSetDestroy
XftObjectSetVaBuild
XftFontSetMatch
XftNameConstant
XftNameParse
XftNameUnparse
XftPatternAdd
XftPatternAddBool
XftPatternAddDouble
XftPatternAddInteger
XftPatternAddString
XftPatternBuild
XftPatternCreate
XftPatternDel
XftPatternDestroy
XftPatternDuplicate
XftPatternFind
XftPatternGet
XftPatternGetBool
XftPatternGetDouble
XftPatternGetInteger
XftPatternGetString
XftPatternVaBuild
XftValueDestroy
XftValueListDestroy
XftUtf8Len
XftUtf8ToUcs4
_XftDownStr
_XftGetInt
_XftMatchSymbolic
_XftSaveString
_XftSplitField
_XftSplitStr
_XftSplitValue
_XftStrCmpIgnoreCase
XftCoreAddFonts
XftCoreClose
XftCoreOpen
XftXlfdParse
XftInitFtLibrary
XftConfigDirs
XftDirScan
XftDirSave
/* $XFree86: xc/lib/Xft/Xft-def.cpp,v 1.2 2001/04/05 19:29:38 dawes Exp $ */

View File

@@ -1,561 +0,0 @@
/*
* $XFree86: xc/lib/Xft/Xft.h,v 1.22 2002/02/21 05:30:31 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XFT_H_
#define _XFT_H_
#define XftVersion 20000
#include <stdarg.h>
#include <freetype/freetype.h>
#include <fontconfig/fontconfig.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xfuncproto.h>
/* #include <X11/Xosdefs.h>*/
#ifndef _XFT_NO_COMPAT_
#include <X11/Xft/XftCompat.h>
#endif
#define XFT_CORE "core"
#define XFT_RENDER "render"
#define XFT_XLFD "xlfd"
#define XFT_MAX_GLYPH_MEMORY "maxglyphmemory"
extern FT_Library _XftFTlibrary;
typedef struct _XftFont {
int ascent;
int descent;
int height;
int max_advance_width;
FcCharSet *charset;
FcPattern *pattern;
} XftFont;
typedef struct _XftDraw XftDraw;
typedef struct _XftColor {
unsigned long pixel;
XRenderColor color;
} XftColor;
typedef struct _XftCharSpec {
FcChar32 ucs4;
short x;
short y;
} XftCharSpec;
typedef struct _XftCharFontSpec {
XftFont *font;
FcChar32 ucs4;
short x;
short y;
} XftCharFontSpec;
typedef struct _XftGlyphSpec {
FT_UInt glyph;
short x;
short y;
} XftGlyphSpec;
typedef struct _XftGlyphFontSpec {
XftFont *font;
FT_UInt glyph;
short x;
short y;
} XftGlyphFontSpec;
_XFUNCPROTOBEGIN
/* xftcolor.c */
Bool
XftColorAllocName (Display *dpy,
Visual *visual,
Colormap cmap,
char *name,
XftColor *result);
Bool
XftColorAllocValue (Display *dpy,
Visual *visual,
Colormap cmap,
XRenderColor *color,
XftColor *result);
void
XftColorFree (Display *dpy,
Visual *visual,
Colormap cmap,
XftColor *color);
/* xftcore.c */
/* xftdir.c */
FcBool
XftDirScan (FcFontSet *set, const char *dir, FcBool force);
FcBool
XftDirSave (FcFontSet *set, const char *dir);
/* xftdpy.c */
Bool
XftDefaultHasRender (Display *dpy);
Bool
XftDefaultSet (Display *dpy, FcPattern *defaults);
void
XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern);
/* xftdraw.c */
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap);
XftDraw *
XftDrawCreateBitmap (Display *dpy,
Pixmap bitmap);
XftDraw *
XftDrawCreateAlpha (Display *dpy,
Pixmap pixmap,
int depth);
void
XftDrawChange (XftDraw *draw,
Drawable drawable);
Display *
XftDrawDisplay (XftDraw *draw);
Drawable
XftDrawDrawable (XftDraw *draw);
Colormap
XftDrawColormap (XftDraw *draw);
Visual *
XftDrawVisual (XftDraw *draw);
void
XftDrawDestroy (XftDraw *draw);
Picture
XftDrawPicture (XftDraw *draw);
void
XftDrawGlyphs (XftDraw *draw,
XftColor *color,
XftFont *pub,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftDrawString8 (XftDraw *d,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar8 *string,
int len);
void
XftDrawString16 (XftDraw *draw,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar16 *string,
int len);
void
XftDrawString32 (XftDraw *draw,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar32 *string,
int len);
void
XftDrawStringUtf8 (XftDraw *d,
XftColor *color,
XftFont *font,
int x,
int y,
FcChar8 *string,
int len);
void
XftDrawCharSpec (XftDraw *d,
XftColor *color,
XftFont *font,
XftCharSpec *chars,
int len);
void
XftDrawCharFontSpec (XftDraw *d,
XftColor *color,
XftCharFontSpec *chars,
int len);
void
XftDrawGlyphSpec (XftDraw *d,
XftColor *color,
XftFont *font,
XftGlyphSpec *glyphs,
int len);
void
XftDrawGlyphFontSpec (XftDraw *d,
XftColor *color,
XftGlyphFontSpec *glyphs,
int len);
void
XftDrawRect (XftDraw *d,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
Bool
XftDrawSetClip (XftDraw *d,
Region r);
/* xftextent.c */
void
XftGlyphExtents (Display *dpy,
XftFont *pub,
FT_UInt *glyphs,
int nglyphs,
XGlyphInfo *extents);
void
XftTextExtents8 (Display *dpy,
XftFont *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtents16 (Display *dpy,
XftFont *font,
FcChar16 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtents32 (Display *dpy,
XftFont *font,
FcChar32 *string,
int len,
XGlyphInfo *extents);
void
XftTextExtentsUtf8 (Display *dpy,
XftFont *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
/* xftfont.c */
FcPattern *
XftFontMatch (Display *dpy, int screen, FcPattern *pattern, FcResult *result);
XftFont *
XftFontOpen (Display *dpy, int screen, ...);
XftFont *
XftFontOpenName (Display *dpy, int screen, const char *name);
XftFont *
XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd);
/* xftfreetype.c */
FT_Face
XftLockFace (XftFont *font);
void
XftUnlockFace (XftFont *font);
XftFont *
XftFontOpenPattern (Display *dpy, FcPattern *pattern);
XftFont *
XftFontCopy (Display *dpy, XftFont *font);
void
XftFontClose (Display *dpy, XftFont *font);
FcBool
XftInitFtLibrary(void);
/* xftglyphs.c */
void
XftFontLoadGlyphs (Display *dpy,
XftFont *font,
FcBool need_bitmaps,
FT_UInt *glyphs,
int nglyph);
void
XftFontUnloadGlyphs (Display *dpy,
XftFont *pub,
FT_UInt *glyphs,
int nglyph);
#define XFT_NMISSING 256
FcBool
XftFontCheckGlyph (Display *dpy,
XftFont *font,
FcBool need_bitmaps,
FT_UInt glyph,
FT_UInt *missing,
int *nmissing);
FcBool
XftCharExists (Display *dpy,
XftFont *pub,
FcChar32 ucs4);
FT_UInt
XftCharIndex (Display *dpy,
XftFont *pub,
FcChar32 ucs4);
/* xftgram.y */
/* xftinit.c */
FcBool
XftInit (char *config);
/* xftlex.l */
/* xftlist.c */
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...);
/* xftmatch.c */
/* xftmatrix.c */
/* xftname.c */
FcPattern
*XftNameParse (const char *name);
/* xftpat.c */
/* xftrender.c */
void
XftGlyphRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftGlyphSpecRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
XftGlyphSpec *glyphs,
int nglyphs);
void
XftCharSpecRender (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
XftCharSpec *chars,
int len);
void
XftGlyphFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftGlyphFontSpec *glyphs,
int nglyphs);
void
XftCharFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftCharFontSpec *chars,
int len);
void
XftTextRender8 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender16 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar16 *string,
int len);
void
XftTextRender16BE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender16LE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender32 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar32 *string,
int len);
void
XftTextRender32BE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRender32LE (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
void
XftTextRenderUtf8 (Display *dpy,
int op,
Picture src,
XftFont *pub,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len);
/* xftstr.c */
/* xftxlfd.c */
FcPattern *
XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
XFontStruct *
XftCoreOpen (Display *dpy, FcPattern *pattern);
void
XftCoreClose (Display *dpy, XFontStruct *font);
_XFUNCPROTOEND
#endif /* _XFT_H_ */

View File

@@ -1,181 +0,0 @@
.\"
.\" $XFree86: xc/lib/Xft/Xft.man,v 1.2 2000/11/30 06:59:45 keithp Exp $
.\"
.\" Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation, and that the name of Keith Packard not be used in
.\" advertising or publicity pertaining to distribution of the software without
.\" specific, written prior permission. Keith Packard makes no
.\" representations about the suitability of this software for any purpose. It
.\" is provided "as is" without express or implied warranty.
.\"
.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.de TQ
.br
.ns
.TP \\$1
..
.TH XFT 3 "Version 1.0" "XFree86"
.SH NAME
XFT \- X FreeType interface library
.SH DESCRIPTION
.B Xft
is a simple library designed to interface the FreeType rasterizer with the X
Rendering Extension. This manual page barely scratches the surface of this
library.
.SH DATATYPES
.B XftPattern
holds a set of names with associated value lists; each name refers to a
property of a font. XftPatterns are used as inputs to the matching code as
well as holding information about specific fonts.
.B XftFont
contains general font metrics and a pointer to either the core XFontStruct
data or a structure holding FreeType and X Render Extension data.
.B XftFontStruct
contains information about FreeType fonts used with the X Render Extension.
.B XftFontSet
contains a list of XftPatterns. Internally Xft uses this data structure to
hold sets of fonts. Externally, Xft returns the results of listing fonts in
this format.
.B XftObjectSet
holds a set of names and is used to specify which fields from fonts are
placed in the the list of returned patterns when listing fonts.
.B XftDraw
is an opaque object which holds information used to render to an X drawable
using either core protocol or the X Rendering extension.
.SH FUNCTIONS
.nf
XftFont *
XftFontOpen (Display *dpy, int screen, ...);
.fi
.B XftFontOpen
takes a list of pattern elements of the form (field, type, value) terminated
with a 0, matches that pattern against the available fonts and opens the
matching font.
.PP
Example:
.br
font = XftFontOpen (dpy, scr,
XFT_FAMILY, XftTypeString, "charter",
XFT_SIZE, XftTypeDouble, 12.0);
.PP
This opens the charter font at 12 points. The point size is automatically
converted to the correct pixel size based on the resolution of the monitor.
.PP
.nf
void
XftTextExtents8 (Display *dpy,
XftFont *font,
unsigned char *string,
int len,
XGlyphInfo *extents);
.fi
.B XftTextExtents8
computes the pixel extents of "string" when drawn with "font".
.PP
.nf
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap);
.fi
.B XtDrawCreate
creates a structure that can be used to render text and rectangles
to the screen.
.PP
.nf
void
XftDrawString8 (XftDraw *d,
XRenderColor *color,
XftFont *font,
int x,
int y,
unsigned char *string,
int len);
.fi
.B XftDrawString8
draws "string" using "font" in "color" at "x, y".
.PP
.nf
void
XftDrawRect (XftDraw *d,
XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
.fi
.B XftDrawRect
fills a solid rectangle in the specified color.
.SH XftConfig
The
.B XftConfig
file contains configuration information for the Xft library consisting of
directories to look at for font information as well as instructions on
editing program specified font patterns before attempting to match the
available fonts.
.PP
.nf
config : "dir" STRING
| "include" STRING
| "includeif" STRING
| "match" tests "edit" edits
;
test : qual FIELD-NAME COMPARE CONSTANT
;
qual : "any"
| "all"
;
edit : FIELD-NAME ASSIGN expr SEMI
;
.fi
.PP
STRINGs are double-quote delimited. FIELD-NAMEs are identifiers,
ASSIGN is one of "=", "+=" or "=+". expr can contain the usual
arithmetic operators and can include FIELD-NAMEs.
.PP
"dir" adds a directory to the list of places Xft will look for fonts.
There is no particular order implied by the list; Xft treats all fonts about
the same.
.PP
"include" and "includeif" cause Xft to load more configuration parameters
from the indicated file. "includeif" doesn't elicit a complaint if the file
doesn't exist. If the file name begins with a '~' character, it refers to a
path relative to the home directory of the user.
.PP
If the tests in a "match" statement all match a user-specified pattern, the
pattern will be edited with the specified instructions.
.PP
Where ASSIGN is "=", the matching value in the pattern will be replaced by
the given expression. "+="/"=+" will prepend/append a new value to the list
of values for the indicated field.
.SH RESTRICTIONS
.B Xft
will probably change radically in the future; weak attempts will be made to
retain some level of source-file compatibility.
.SH AUTHOR
Keith Packard, member of the XFree86 Project, Inc.

View File

@@ -1,166 +0,0 @@
/*
* $XFree86: xc/lib/Xft/XftCompat.h,v 1.2 2002/02/19 07:51:20 keithp Exp $
*
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XFTCOMPAT_H_
#define _XFTCOMPAT_H_
#include <X11/Xfuncproto.h>
/*
* Compatibility definitions -- map Fc names to Xft names
*/
typedef FcChar8 XftChar8;
typedef FcChar16 XftChar16;
typedef FcChar32 XftChar32;
#define XFT_FAMILY FC_FAMILY
#define XFT_STYLE FC_STYLE
#define XFT_SLANT FC_SLANT
#define XFT_WEIGHT FC_WEIGHT
#define XFT_SIZE FC_SIZE
#define XFT_PIXEL_SIZE FC_PIXEL_SIZE
#define XFT_SPACING FC_SPACING
#define XFT_FOUNDRY FC_FOUNDRY
#define XFT_ANTIALIAS FC_ANTIALIAS
#define XFT_FILE FC_FILE
#define XFT_INDEX FC_INDEX
#define XFT_RASTERIZER FC_RASTERIZER
#define XFT_OUTLINE FC_OUTLINE
#define XFT_SCALABLE FC_SCALABLE
#define XFT_RGBA FC_RGBA
/* defaults from resources */
#define XFT_SCALE FC_SCALE
#define XFT_MINSPACE FC_MINSPACE
#define XFT_DPI FC_DPI
/* specific to FreeType rasterizer */
#define XFT_CHAR_WIDTH FC_CHAR_WIDTH
#define XFT_CHAR_HEIGHT FC_CHAR_HEIGHT
#define XFT_MATRIX FC_MATRIX
#define XFT_WEIGHT_LIGHT FC_WEIGHT_LIGHT
#define XFT_WEIGHT_MEDIUM FC_WEIGHT_MEDIUM
#define XFT_WEIGHT_DEMIBOLD FC_WEIGHT_DEMIBOLD
#define XFT_WEIGHT_BOLD FC_WEIGHT_BOLD
#define XFT_WEIGHT_BLACK FC_WEIGHT_BLACK
#define XFT_SLANT_ROMAN FC_SLANT_ROMAN
#define XFT_SLANT_ITALIC FC_SLANT_ITALIC
#define XFT_SLANT_OBLIQUE FC_SLANT_OBLIQUE
#define XFT_PROPORTIONAL FC_PROPORTIONAL
#define XFT_MONO FC_MONO
#define XFT_CHARCELL FC_CHARCELL
#define XFT_RGBA_NONE FC_RGBA_NONE
#define XFT_RGBA_RGB FC_RGBA_RGB
#define XFT_RGBA_BGR FC_RGBA_BGR
#define XFT_RGBA_VRGB FC_RGBA_VRGB
#define XFT_RGBA_VBGR FC_RGBA_VBGR
/*
* Old constants
*/
#define XFT_ENCODING "encoding"
typedef FcType XftType;
typedef FcMatrix XftMatrix;
#define XftMatrixInit(m) FcMatrixInit(m)
typedef FcResult XftResult;
#define XftResultMatch FcResultMatch
#define XftResultNoMatch FcResultNoMatch
#define XftResultTypeMismatch FcResultTypeMismatch
#define XftResultNoId FcResultNoId
typedef FcValue XftValue;
typedef FcPattern XftPattern;
typedef FcFontSet XftFontSet;
typedef FcObjectSet XftObjectSet;
#define XftGlyphExists XftCharExists
#define XftObjectSetCreate FcObjectSetCreate
#define XftObjectSetAdd FcObjectSetAdd
#define XftObjectSetDestroy FcObjectSetDestroy
#define XftObjectSetVaBuild FcObjectSetVaBuild
#define XftObjectSetBuild FcObjectSetBuild
#define XftListFontsPatternObjects FcListFontsPatternObjects
#define XftFontSetMatch FcFontSetMatch
#define XftFontSetDestroy FcFontSetDestroy
#define XftMatrixEqual FcMatrixEqual
#define XftMatrixMultiply FcMatrixMultiply
#define XftMatrixRotate FcMatrixRotate
#define XftMatrixScale FcMatrixScale
#define XftMatrixShear FcMatrixShear
#define XftPatternCreate FcPatternCreate
#define XftPatternDuplicate FcPatternDuplicate
#define XftValueDestroy FcValueDestroy
#define XftValueListDestroy FcValueListDestroy
#define XftPatternDestroy FcPatternDestroy
#define XftPatternFind FcPatternFind
#define XftPatternAdd FcPatternAdd
#define XftPatternGet FcPatternGet
#define XftPatternDel FcPatternDel
#define XftPatternAddInteger FcPatternAddInteger
#define XftPatternAddDouble FcPatternAddDouble
#define XftPatternAddString FcPatternAddString
#define XftPatternAddMatrix FcPatternAddMatrix
#define XftPatternAddBool FcPatternAddBool
#define XftPatternGetInteger FcPatternGetInteger
#define XftPatternGetDouble FcPatternGetDouble
#define XftPatternGetString FcPatternGetString
#define XftPatternGetMatrix FcPatternGetMatrix
#define XftPatternGetBool FcPatternGetBool
#define XftPatternVaBuild FcPatternVaBuild
#define XftPatternBuild FcPatternBuild
#define XftUtf8ToUcs4 FcUtf8ToUcs4
#define XftUtf8Len FcUtf8Len
#define XftTypeVoid FcTypeVoid
#define XftTypeInteger FcTypeInteger
#define XftTypeDouble FcTypeDouble
#define XftTypeString FcTypeString
#define XftTypeBool FcTypeBool
#define XftTypeMatrix FcTypeMatrix
#define XftConfigSubstitute(p) FcConfigSubstitute (0, p, FcMatchPattern)
_XFUNCPROTOBEGIN
FcBool
XftNameUnparse (XftPattern *pat, char *dest, int len);
_XFUNCPROTOEND
#endif /* _XFTCOMPAT_H_ */

View File

@@ -1,164 +0,0 @@
/*
* $XFree86: xc/lib/Xft/XftFreetype.h,v 1.16 2002/02/15 07:36:10 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* This file is strictly for backwards compatibility with
* old Xft applications
*/
#ifndef _XFTFREETYPE_H_
#define _XFTFREETYPE_H_
/* #include <Xft/Xft.h> */
/* #include <X11/Xft/Xft.h>*/
#include "Xft.h"
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
typedef struct _XftFontStruct {
FT_Face __DEPRECATED_face; /* handle to face object */
GlyphSet __DEPRECATED_glyphset;
int min_char;
int max_char;
FT_F26Dot6 size;
int ascent;
int descent;
int height;
int max_advance_width;
int __DEPRECATED_spacing;
int __DEPRECATED_rgba;
Bool __DEPRECATED_antialias;
int __DEPRECATED_charmap; /* -1 for unencoded */
XRenderPictFormat *__DEPRECATED_format;
XGlyphInfo **__DEPRECATED_realized;
int __DEPRECATED_nrealized;
FcBool __DEPRECATED_transform;
FT_Matrix __DEPRECATED_matrix;
/* private field */
XftFont *font;
} XftFontStruct;
_XFUNCPROTOBEGIN
XftFontStruct *
XftFreeTypeOpen (Display *dpy, FcPattern *pattern);
XftFontStruct *
XftFreeTypeGet (XftFont *font);
void
XftFreeTypeClose (Display *dpy, XftFontStruct *font);
void
XftGlyphLoad (Display *dpy,
XftFontStruct *font,
FcChar32 *glyphs,
int nglyph);
void
XftGlyphCheck (Display *dpy,
XftFontStruct *font,
FcChar32 glyph,
FcChar32 *missing,
int *nmissing);
void
XftGlyphLoad (Display *dpy,
XftFontStruct *font,
FcChar32 *glyphs,
int nglyph);
void
XftGlyphCheck (Display *dpy,
XftFontStruct *font,
FcChar32 glyph,
FcChar32 *missing,
int *nmissing);
Bool
XftFreeTypeGlyphExists (Display *dpy,
XftFontStruct *font,
FcChar32 glyph);
/* xftrender.c */
void
XftRenderString8 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar8 *string, int len);
void
XftRenderString16 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar16 *string, int len);
void
XftRenderString32 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar32 *string, int len);
void
XftRenderStringUtf8 (Display *dpy, Picture src,
XftFontStruct *font, Picture dst,
int srcx, int srcy,
int x, int y,
FcChar8 *string, int len);
void
XftRenderExtents8 (Display *dpy,
XftFontStruct *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtents16 (Display *dpy,
XftFontStruct *font,
FcChar16 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtents32 (Display *dpy,
XftFontStruct *font,
FcChar32 *string,
int len,
XGlyphInfo *extents);
void
XftRenderExtentsUtf8 (Display *dpy,
XftFontStruct *font,
FcChar8 *string,
int len,
XGlyphInfo *extents);
_XFUNCPROTOEND
#endif /* _XFTFREETYPE_H_ */

View File

@@ -1,125 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftcolor.c,v 1.2 2001/05/16 17:20:06 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "xftint.h"
Bool
XftColorAllocName (Display *dpy,
Visual *visual,
Colormap cmap,
char *name,
XftColor *result)
{
XColor screen, exact;
if (!XAllocNamedColor (dpy, cmap, name, &screen, &exact))
{
/* XXX stick standard colormap stuff here */
return False;
}
result->pixel = screen.pixel;
result->color.red = exact.red;
result->color.green = exact.green;
result->color.blue = exact.blue;
result->color.alpha = 0xffff;
return True;
}
static short
maskbase (unsigned long m)
{
short i;
if (!m)
return 0;
i = 0;
while (!(m&1))
{
m>>=1;
i++;
}
return i;
}
static short
masklen (unsigned long m)
{
unsigned long y;
y = (m >> 1) &033333333333;
y = m - y - ((y >>1) & 033333333333);
return (short) (((y + (y >> 3)) & 030707070707) % 077);
}
Bool
XftColorAllocValue (Display *dpy,
Visual *visual,
Colormap cmap,
XRenderColor *color,
XftColor *result)
{
if (visual->class == TrueColor)
{
int red_shift, red_len;
int green_shift, green_len;
int blue_shift, blue_len;
red_shift = maskbase (visual->red_mask);
red_len = masklen (visual->red_mask);
green_shift = maskbase (visual->green_mask);
green_len = masklen (visual->green_mask);
blue_shift = maskbase (visual->blue_mask);
blue_len = masklen (visual->blue_mask);
result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
((color->green >> (16 - green_len)) << green_shift) |
((color->blue >> (16 - blue_len)) << blue_shift));
}
else
{
XColor xcolor;
xcolor.red = color->red;
xcolor.green = color->green;
xcolor.blue = color->blue;
if (!XAllocColor (dpy, cmap, &xcolor))
return False;
result->pixel = xcolor.pixel;
}
result->color.red = color->red;
result->color.green = color->green;
result->color.blue = color->blue;
result->color.alpha = color->alpha;
return True;
}
void
XftColorFree (Display *dpy,
Visual *visual,
Colormap cmap,
XftColor *color)
{
if (visual->class != TrueColor)
XFreeColors (dpy, cmap, &color->pixel, 1, 0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,50 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftdbg.c,v 1.4 2002/02/15 07:36:10 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include "xftint.h"
int
XftDebug (void)
{
static int initialized;
static int debug;
if (!initialized)
{
char *e;
initialized = 1;
e = getenv ("XFT_DEBUG");
if (e)
{
printf ("XFT_DEBUG=%s\n", e);
debug = atoi (e);
if (debug <= 0)
debug = 1;
}
}
return debug;
}

View File

@@ -1,442 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftdpy.c,v 1.9 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <X11/Xlibint.h>
#include "xftint.h"
XftDisplayInfo *_XftDisplayInfo;
static int
_XftCloseDisplay (Display *dpy, XExtCodes *codes)
{
XftDisplayInfo *info, **prev;
for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
if (info->codes == codes)
break;
if (!info)
return 0;
*prev = info->next;
if (info->defaults)
FcPatternDestroy (info->defaults);
free (info);
return 0;
}
XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy)
{
XftDisplayInfo *info, **prev;
XRenderPictFormat pf;
int i;
for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
{
if (info->display == dpy)
{
/*
* MRU the list
*/
if (prev != &_XftDisplayInfo)
{
*prev = info->next;
info->next = _XftDisplayInfo;
_XftDisplayInfo = info;
}
return info;
}
}
info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
if (!info)
goto bail0;
info->codes = XAddExtension (dpy);
if (!info->codes)
goto bail1;
(void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);
info->display = dpy;
info->defaults = 0;
info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
info->use_free_glyphs = FcTrue;
if (info->hasRender)
{
int major, minor;
XRenderQueryVersion (dpy, &major, &minor);
if (major < 0 || (major == 0 && minor <= 2))
info->use_free_glyphs = FcFalse;
}
pf.type = PictTypeDirect;
pf.depth = 32;
pf.direct.redMask = 0xff;
pf.direct.greenMask = 0xff;
pf.direct.blueMask = 0xff;
pf.direct.alphaMask = 0xff;
info->solidFormat = XRenderFindFormat (dpy,
(PictFormatType|
PictFormatDepth|
PictFormatRedMask|
PictFormatGreenMask|
PictFormatBlueMask|
PictFormatAlphaMask),
&pf,
0);
if (XftDebug () & XFT_DBG_RENDER)
{
Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
printf ("XftDisplayInfoGet Default visual 0x%x ",
(int) visual->visualid);
if (format)
{
if (format->type == PictTypeDirect)
{
printf ("format %d,%d,%d,%d\n",
format->direct.alpha,
format->direct.red,
format->direct.green,
format->direct.blue);
}
else
{
printf ("format indexed\n");
}
}
else
printf ("No Render format for default visual\n");
printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
info->hasRender ? "True" : "False");
}
for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
{
info->colors[i].screen = -1;
info->colors[i].pict = 0;
}
info->fonts = 0;
info->next = _XftDisplayInfo;
_XftDisplayInfo = info;
info->glyph_memory = 0;
info->max_glyph_memory = XftDefaultGetInteger (dpy,
XFT_MAX_GLYPH_MEMORY, 0,
XFT_DPY_MAX_GLYPH_MEMORY);
if (XftDebug () & XFT_DBG_CACHE)
printf ("global max cache memory %ld\n", info->max_glyph_memory);
return info;
bail1:
free (info);
bail0:
if (XftDebug () & XFT_DBG_RENDER)
{
printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
}
return 0;
}
/*
* Reduce memory usage in X server
*/
void
_XftDisplayManageMemory (Display *dpy)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
unsigned long glyph_memory;
XftFont *public;
XftFontInt *font;
if (!info || !info->max_glyph_memory)
return;
if (XftDebug () & XFT_DBG_CACHE)
{
if (info->glyph_memory > info->max_glyph_memory)
printf ("Reduce global memory from %ld to %ld\n",
info->glyph_memory, info->max_glyph_memory);
}
while (info->glyph_memory > info->max_glyph_memory)
{
glyph_memory = rand () % info->glyph_memory;
public = info->fonts;
while (public)
{
font = (XftFontInt *) public;
if (font->glyph_memory > glyph_memory)
{
_XftFontUncacheGlyph (dpy, public);
break;
}
public = font->next;
glyph_memory -= font->glyph_memory;
}
}
}
Bool
XftDefaultHasRender (Display *dpy)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
if (!info)
return False;
return info->hasRender;
}
Bool
XftDefaultSet (Display *dpy, FcPattern *defaults)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
if (!info)
return False;
if (info->defaults)
FcPatternDestroy (info->defaults);
info->defaults = defaults;
if (!info->max_glyph_memory)
info->max_glyph_memory = XFT_DPY_MAX_GLYPH_MEMORY;
info->max_glyph_memory = XftDefaultGetInteger (dpy,
XFT_MAX_GLYPH_MEMORY, 0,
info->max_glyph_memory);
return True;
}
int
XftDefaultParseBool (char *v)
{
char c0, c1;
c0 = *v;
if (isupper (c0))
c0 = tolower (c0);
if (c0 == 't' || c0 == 'y' || c0 == '1')
return 1;
if (c0 == 'f' || c0 == 'n' || c0 == '0')
return 0;
if (c0 == 'o')
{
c1 = v[1];
if (isupper (c1))
c1 = tolower (c1);
if (c1 == 'n')
return 1;
if (c1 == 'f')
return 0;
}
return -1;
}
static Bool
_XftDefaultInitBool (Display *dpy, FcPattern *pat, char *option)
{
char *v;
int i;
v = XGetDefault (dpy, "Xft", option);
if (v && (i = XftDefaultParseBool (v)) >= 0)
return FcPatternAddBool (pat, option, i != 0);
return True;
}
static Bool
_XftDefaultInitDouble (Display *dpy, FcPattern *pat, char *option)
{
char *v, *e;
double d;
v = XGetDefault (dpy, "Xft", option);
if (v)
{
d = strtod (v, &e);
if (e != v)
return FcPatternAddDouble (pat, option, d);
}
return True;
}
static Bool
_XftDefaultInitInteger (Display *dpy, FcPattern *pat, char *option)
{
char *v, *e;
int i;
v = XGetDefault (dpy, "Xft", option);
if (v)
{
if (FcNameConstant ((FcChar8 *) v, &i))
return FcPatternAddInteger (pat, option, i);
i = strtol (v, &e, 0);
if (e != v)
return FcPatternAddInteger (pat, option, i);
}
return True;
}
static FcPattern *
_XftDefaultInit (Display *dpy)
{
FcPattern *pat;
pat = FcPatternCreate ();
if (!pat)
goto bail0;
if (!_XftDefaultInitDouble (dpy, pat, FC_SCALE))
goto bail1;
if (!_XftDefaultInitDouble (dpy, pat, FC_DPI))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
goto bail1;
if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS))
goto bail1;
if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE))
goto bail1;
if (!_XftDefaultInitInteger (dpy, pat, XFT_MAX_GLYPH_MEMORY))
goto bail1;
return pat;
bail1:
FcPatternDestroy (pat);
bail0:
return 0;
}
static FcResult
_XftDefaultGet (Display *dpy, const char *object, int screen, FcValue *v)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
FcResult r;
if (!info)
return FcResultNoMatch;
if (!info->defaults)
{
info->defaults = _XftDefaultInit (dpy);
if (!info->defaults)
return FcResultNoMatch;
}
r = FcPatternGet (info->defaults, object, screen, v);
if (r == FcResultNoId && screen > 0)
r = FcPatternGet (info->defaults, object, 0, v);
return r;
}
Bool
XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeBool)
return def;
return v.u.b;
}
int
XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeInteger)
return def;
return v.u.i;
}
double
XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
{
FcResult r;
FcValue v;
r = _XftDefaultGet (dpy, object, screen, &v);
if (r != FcResultMatch || v.type != FcTypeDouble)
return def;
return v.u.d;
}
void
XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern)
{
FcValue v;
double dpi;
if (FcPatternGet (pattern, XFT_RENDER, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, XFT_RENDER,
XftDefaultGetBool (dpy, XFT_RENDER, screen,
XftDefaultHasRender (dpy)));
}
if (FcPatternGet (pattern, FC_ANTIALIAS, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, FC_ANTIALIAS,
XftDefaultGetBool (dpy, FC_ANTIALIAS, screen,
True));
}
if (FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, FC_RGBA,
XftDefaultGetInteger (dpy, FC_RGBA, screen,
FC_RGBA_NONE));
}
if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch)
{
FcPatternAddBool (pattern, FC_MINSPACE,
XftDefaultGetBool (dpy, FC_MINSPACE, screen,
False));
}
if (FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
{
dpi = (((double) DisplayHeight (dpy, screen) * 25.4) /
(double) DisplayHeightMM (dpy, screen));
FcPatternAddDouble (pattern, FC_DPI,
XftDefaultGetDouble (dpy, FC_DPI, screen,
dpi));
}
if (FcPatternGet (pattern, FC_SCALE, 0, &v) == FcResultNoMatch)
{
FcPatternAddDouble (pattern, FC_SCALE,
XftDefaultGetDouble (dpy, FC_SCALE, screen, 1.0));
}
if (FcPatternGet (pattern, XFT_MAX_GLYPH_MEMORY, 0, &v) == FcResultNoMatch)
{
FcPatternAddInteger (pattern, XFT_MAX_GLYPH_MEMORY,
XftDefaultGetInteger (dpy, XFT_MAX_GLYPH_MEMORY,
screen,
XFT_FONT_MAX_GLYPH_MEMORY));
}
FcDefaultSubstitute (pattern);
}

View File

@@ -1,774 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftdraw.c,v 1.17 2002/02/19 07:56:29 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
/*
* Ok, this is a pain. To share source pictures across multiple destinations,
* the screen for each drawable must be discovered.
*/
static int
_XftDrawScreen (Display *dpy, Drawable drawable, Visual *visual)
{
int s;
Window root;
int x, y;
unsigned int width, height, borderWidth, depth;
/* Special case the most common environment */
if (ScreenCount (dpy) == 1)
return 0;
/*
* If we've got a visual, look for the screen that points at it.
* This requires no round trip.
*/
if (visual)
{
for (s = 0; s < ScreenCount (dpy); s++)
{
XVisualInfo template, *ret;
int nret;
template.visualid = visual->visualid;
template.screen = s;
ret = XGetVisualInfo (dpy, VisualIDMask|VisualScreenMask,
&template, &nret);
if (ret)
{
XFree (ret);
return s;
}
}
}
/*
* Otherwise, as the server for the drawable geometry and find
* the screen from the root window.
* This takes a round trip.
*/
if (XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
&borderWidth, &depth))
{
for (s = 0; s < ScreenCount (dpy); s++)
{
if (RootWindow (dpy, s) == root)
return s;
}
}
/*
* Make a guess -- it's probably wrong, but then the app probably
* handed us a bogus drawable in this case
*/
return 0;
}
unsigned int
XftDrawDepth (XftDraw *draw)
{
if (!draw->depth)
{
Window root;
int x, y;
unsigned int width, height, borderWidth, depth;
if (XGetGeometry (draw->dpy, draw->drawable,
&root, &x, &y, &width, &height,
&borderWidth, &depth))
draw->depth = depth;
}
return draw->depth;
}
unsigned int
XftDrawBitsPerPixel (XftDraw *draw)
{
if (!draw->bits_per_pixel)
{
XPixmapFormatValues *formats;
int nformats;
unsigned int depth;
if ((depth = XftDrawDepth (draw)) &&
(formats = XListPixmapFormats (draw->dpy, &nformats)))
{
int i;
for (i = 0; i < nformats; i++)
{
if (formats[i].depth == depth)
{
draw->bits_per_pixel = formats[i].bits_per_pixel;
break;
}
}
XFree (formats);
}
}
return draw->bits_per_pixel;
}
XftDraw *
XftDrawCreate (Display *dpy,
Drawable drawable,
Visual *visual,
Colormap colormap)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = drawable;
draw->screen = _XftDrawScreen (dpy, drawable, visual);
draw->depth = 0; /* don't find out unless we need to know */
draw->bits_per_pixel = 0; /* don't find out unless we need to know */
draw->visual = visual;
draw->colormap = colormap;
draw->render.pict = 0;
draw->core.gc = 0;
draw->core.use_pixmap = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
XftDraw *
XftDrawCreateBitmap (Display *dpy,
Pixmap bitmap)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = (Drawable) bitmap;
draw->screen = _XftDrawScreen (dpy, bitmap, 0);
draw->depth = 1;
draw->bits_per_pixel = 1;
draw->visual = 0;
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
XftDraw *
XftDrawCreateAlpha (Display *dpy,
Pixmap pixmap,
int depth)
{
XftDraw *draw;
draw = (XftDraw *) malloc (sizeof (XftDraw));
if (!draw)
return 0;
draw->dpy = dpy;
draw->drawable = (Drawable) pixmap;
draw->screen = _XftDrawScreen (dpy, pixmap, 0);
draw->depth = depth;
draw->bits_per_pixel = 0; /* don't find out until we need it */
draw->visual = 0;
draw->colormap = 0;
draw->render.pict = 0;
draw->core.gc = 0;
draw->clip = 0;
XftMemAlloc (XFT_MEM_DRAW, sizeof (XftDraw));
return draw;
}
static XRenderPictFormat *
_XftDrawFormat (XftDraw *draw)
{
XftDisplayInfo *info = _XftDisplayInfoGet (draw->dpy);
if (!info->hasRender)
return 0;
if (draw->visual == 0)
{
XRenderPictFormat pf;
pf.type = PictTypeDirect;
pf.depth = XftDrawDepth (draw);
pf.direct.alpha = 0;
pf.direct.alphaMask = (1 << pf.depth) - 1;
return XRenderFindFormat (draw->dpy,
(PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask),
&pf,
0);
}
else
return XRenderFindVisualFormat (draw->dpy, draw->visual);
}
void
XftDrawChange (XftDraw *draw,
Drawable drawable)
{
draw->drawable = drawable;
if (draw->render.pict)
{
XRenderFreePicture (draw->dpy, draw->render.pict);
draw->render.pict = 0;
}
if (draw->core.gc)
{
XFreeGC (draw->dpy, draw->core.gc);
draw->core.gc = 0;
}
}
Display *
XftDrawDisplay (XftDraw *draw)
{
return draw->dpy;
}
Drawable
XftDrawDrawable (XftDraw *draw)
{
return draw->drawable;
}
Colormap
XftDrawColormap (XftDraw *draw)
{
return draw->colormap;
}
Visual *
XftDrawVisual (XftDraw *draw)
{
return draw->visual;
}
void
XftDrawDestroy (XftDraw *draw)
{
if (draw->render.pict)
XRenderFreePicture (draw->dpy, draw->render.pict);
if (draw->core.gc)
XFreeGC (draw->dpy, draw->core.gc);
if (draw->clip)
XDestroyRegion (draw->clip);
XftMemFree (XFT_MEM_DRAW, sizeof (XftDraw));
free (draw);
}
static Picture
_XftDrawSrcPicture (XftDraw *draw, XftColor *color)
{
Display *dpy = draw->dpy;
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
int i;
XftColor bitmapColor;
if (!info)
return 0;
/*
* Monochrome targets require special handling; the PictOp controls
* the color, and the color must be opaque
*/
if (!draw->visual && draw->depth == 1)
{
bitmapColor.color.alpha = 0xffff;
bitmapColor.color.red = 0xffff;
bitmapColor.color.green = 0xffff;
bitmapColor.color.blue = 0xffff;
color = &bitmapColor;
}
/*
* See if there's one already available
*/
for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
{
if (info->colors[i].pict &&
info->colors[i].screen == draw->screen &&
!memcmp ((void *) &color->color,
(void *) &info->colors[i].color,
sizeof (XRenderColor)))
return info->colors[i].pict;
}
/*
* Pick one to replace at random
*/
i = (unsigned int) rand () % XFT_NUM_SOLID_COLOR;
/*
* Recreate if it was for the wrong screen
*/
if (info->colors[i].screen != draw->screen && info->colors[i].pict)
{
XRenderFreePicture (dpy, info->colors[i].pict);
info->colors[i].pict = 0;
}
/*
* Create picture if necessary
*/
if (!info->colors[i].pict)
{
Pixmap pix;
XRenderPictureAttributes pa;
pix = XCreatePixmap (dpy, RootWindow (dpy, draw->screen), 1, 1,
info->solidFormat->depth);
pa.repeat = True;
info->colors[i].pict = XRenderCreatePicture (draw->dpy,
pix,
info->solidFormat,
CPRepeat, &pa);
XFreePixmap (dpy, pix);
}
/*
* Set to the new color
*/
info->colors[i].color = color->color;
info->colors[i].screen = draw->screen;
XRenderFillRectangle (dpy, PictOpSrc,
info->colors[i].pict,
&color->color, 0, 0, 1, 1);
return info->colors[i].pict;
}
static int
_XftDrawOp (XftDraw *draw, XftColor *color)
{
if (draw->visual || draw->depth != 1)
return PictOpOver;
if (color->color.alpha >= 0x8000)
return PictOpOver;
return PictOpOutReverse;
}
static FcBool
_XftDrawRenderPrepare (XftDraw *draw)
{
if (!draw->render.pict)
{
XRenderPictFormat *format;
format = _XftDrawFormat (draw);
if (!format)
return FcFalse;
draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
format, 0, 0);
if (!draw->render.pict)
return FcFalse;
if (draw->clip)
XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
draw->clip);
}
return FcTrue;
}
static FcBool
_XftDrawCorePrepare (XftDraw *draw, XftColor *color)
{
if (!draw->core.gc)
{
draw->core.gc = XCreateGC (draw->dpy, draw->drawable, 0, 0);
if (!draw->core.gc)
return FcFalse;
if (draw->clip)
XSetRegion (draw->dpy, draw->core.gc, draw->clip);
}
XSetForeground (draw->dpy, draw->core.gc, color->pixel);
return FcTrue;
}
Picture
XftDrawPicture (XftDraw *draw)
{
if (!_XftDrawRenderPrepare (draw))
return 0;
return draw->render.pict;
}
#define NUM_LOCAL 1024
void
XftDrawGlyphs (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FT_UInt *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
if (font->format)
{
Picture src;
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
XftGlyphRender (draw->dpy, _XftDrawOp (draw, color),
src, public, draw->render.pict,
0, 0, x, y, glyphs, nglyphs);
}
else
{
if (_XftDrawCorePrepare (draw, color))
XftGlyphCore (draw, color, public, x, y, glyphs, nglyphs);
}
}
void
XftDrawString8 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (XftDebug () & XFT_DBG_DRAW)
printf ("DrawString \"%*.*s\"\n", len, len, string);
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawString16 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar16 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawString32 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar32 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (draw->dpy, public, string[i]);
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawStringUtf8 (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = ucs4;
string += l;
len -= l;
}
XftDrawGlyphs (draw, color, public, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawGlyphSpec (XftDraw *draw,
XftColor *color,
XftFont *public,
XftGlyphSpec *glyphs,
int len)
{
XftFontInt *font = (XftFontInt *) public;
if (font->format)
{
Picture src;
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
{
XftGlyphSpecRender (draw->dpy, _XftDrawOp (draw, color),
src, public, draw->render.pict,
0, 0, glyphs, len);
}
}
else
{
if (_XftDrawCorePrepare (draw, color))
XftGlyphSpecCore (draw, color, public, glyphs, len);
}
}
void
XftDrawGlyphFontSpec (XftDraw *draw,
XftColor *color,
XftGlyphFontSpec *glyphs,
int len)
{
int i;
int start;
i = 0;
while (i < len);
{
start = i;
if (((XftFontInt *) glyphs[i].font)->format)
{
Picture src;
while (((XftFontInt *) glyphs[i].font)->format)
{
i++;
}
if (_XftDrawRenderPrepare (draw) &&
(src = _XftDrawSrcPicture (draw, color)))
{
XftGlyphFontSpecRender (draw->dpy, _XftDrawOp (draw, color),
src, draw->render.pict,
0, 0, glyphs, i - start);
}
}
else
{
while (!((XftFontInt *) glyphs[i].font)->format)
{
i++;
}
if (_XftDrawCorePrepare (draw, color))
XftGlyphFontSpecCore (draw, color, glyphs, len);
}
}
}
void
XftDrawCharSpec (XftDraw *draw,
XftColor *color,
XftFont *public,
XftCharSpec *chars,
int len)
{
XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].glyph = XftCharIndex(draw->dpy, public, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftDrawGlyphSpec (draw, color, public, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawCharFontSpec (XftDraw *draw,
XftColor *color,
XftCharFontSpec *chars,
int len)
{
XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphFontSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].font = chars[i].font;
glyphs[i].glyph = XftCharIndex(draw->dpy, glyphs[i].font, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftDrawGlyphFontSpec (draw, color, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftDrawRect (XftDraw *draw,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height)
{
if (_XftDrawRenderPrepare (draw))
{
XRenderFillRectangle (draw->dpy, PictOpOver, draw->render.pict,
&color->color, x, y, width, height);
}
else if (_XftDrawCorePrepare (draw, color))
{
XftRectCore (draw, color, x, y, width, height);
}
}
Bool
XftDrawSetClip (XftDraw *draw,
Region r)
{
Region n = 0;
if (!r && !draw->clip)
return True;
if (r && draw->clip && XEqualRegion (r, draw->clip))
return True;
if (r)
{
n = XCreateRegion ();
if (n)
{
if (!XUnionRegion (n, r, n))
{
XDestroyRegion (n);
return False;
}
}
}
if (draw->clip)
XDestroyRegion (draw->clip);
draw->clip = n;
if (draw->render.pict)
{
if (n)
XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
else
{
XRenderPictureAttributes pa;
pa.clip_mask = None;
XRenderChangePicture (draw->dpy, draw->render.pict,
CPClipMask, &pa);
}
}
if (draw->core.gc)
{
if (n)
XSetRegion (draw->dpy, draw->core.gc, draw->clip);
else
XSetClipMask (draw->dpy, draw->core.gc, None);
}
return True;
}

View File

@@ -1,247 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftextent.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
void
XftGlyphExtents (Display *dpy,
XftFont *public,
FT_UInt *glyphs,
int nglyphs,
XGlyphInfo *extents)
{
XftFontInt *font = (XftFontInt *) public;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt *g;
FT_UInt glyph;
XftGlyph *xftg;
FcBool glyphs_loaded;
int x, y;
int left, right, top, bottom;
int overall_left, overall_right;
int overall_top, overall_bottom;
g = glyphs;
n = nglyphs;
nmissing = 0;
glyphs_loaded = FcFalse;
while (n--)
if (XftFontCheckGlyph (dpy, public, FcFalse, *g++, missing, &nmissing))
glyphs_loaded = FcTrue;
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcFalse, missing, nmissing);
g = glyphs;
n = nglyphs;
xftg = 0;
while (n)
{
glyph = *g++;
n--;
if (glyph < font->num_glyphs &&
(xftg = font->glyphs[glyph]))
break;
}
if (n == 0 && !xftg)
{
extents->width = 0;
extents->height = 0;
extents->x = 0;
extents->y = 0;
extents->yOff = 0;
extents->xOff = 0;
}
else
{
x = 0;
y = 0;
overall_left = x - xftg->metrics.x;
overall_top = y - xftg->metrics.y;
overall_right = overall_left + (int) xftg->metrics.width;
overall_bottom = overall_top + (int) xftg->metrics.height;
x += xftg->metrics.xOff;
y += xftg->metrics.yOff;
while (n--)
{
glyph = *g++;
if (glyph < font->num_glyphs && (xftg = font->glyphs[glyph]))
{
left = x - xftg->metrics.x;
top = y - xftg->metrics.y;
right = left + (int) xftg->metrics.width;
bottom = top + (int) xftg->metrics.height;
if (left < overall_left)
overall_left = left;
if (top < overall_top)
overall_top = top;
if (right > overall_right)
overall_right = right;
if (bottom > overall_bottom)
overall_bottom = bottom;
x += xftg->metrics.xOff;
y += xftg->metrics.yOff;
}
}
extents->x = -overall_left;
extents->y = -overall_top;
extents->width = overall_right - overall_left;
extents->height = overall_bottom - overall_top;
extents->xOff = x;
extents->yOff = y;
}
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
#define NUM_LOCAL 1024
void
XftTextExtents8 (Display *dpy,
XftFont *public,
FcChar8 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtents16 (Display *dpy,
XftFont *public,
FcChar16 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtents32 (Display *dpy,
XftFont *public,
FcChar32 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
{
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphExtents (dpy, public, glyphs, len, extents);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextExtentsUtf8 (Display *dpy,
XftFont *public,
FcChar8 *string,
int len,
XGlyphInfo *extents)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
memset (extents, '\0', sizeof (XGlyphInfo));
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = ucs4;
string += l;
len -= l;
}
XftGlyphExtents (dpy, public, glyphs, i, extents);
if (glyphs != glyphs_local)
free (glyphs);
}

View File

@@ -1,199 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftfont.c,v 1.9 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include "xftint.h"
FcPattern *
XftFontMatch (Display *dpy, int screen, FcPattern *pattern, FcResult *result)
{
FcPattern *new;
FcPattern *match;
if (!XftInit (0))
return 0;
new = FcPatternDuplicate (pattern);
if (!new)
return 0;
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch pattern ");
FcPatternPrint (new);
}
FcConfigSubstitute (0, new, FcMatchPattern);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch after FcConfig substitutions ");
FcPatternPrint (new);
}
XftDefaultSubstitute (dpy, screen, new);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch after X resource substitutions ");
FcPatternPrint (new);
}
match = FcFontMatch (0, new, result);
if (XftDebug () & XFT_DBG_OPENV)
{
printf ("XftFontMatch result ");
FcPatternPrint (match);
}
FcPatternDestroy (new);
return match;
}
XftFont *
XftFontOpen (Display *dpy, int screen, ...)
{
va_list va;
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
va_start (va, screen);
pat = FcPatternVaBuild (0, va);
va_end (va);
if (!pat)
{
if (XftDebug () & XFT_DBG_OPEN)
printf ("XftFontOpen: Invalid pattern argument\n");
return 0;
}
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("Pattern ");
FcPatternPrint (pat);
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
{
if (XftDebug () & XFT_DBG_OPEN)
printf ("No Font\n");
FcPatternDestroy (match);
}
return font;
}
XftFont *
XftFontOpenName (Display *dpy, int screen, const char *name)
{
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
pat = FcNameParse ((FcChar8 *) name);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("XftFontOpenName \"%s\": ", name);
if (pat)
FcPatternPrint (pat);
else
printf ("Invalid name\n");
}
if (!pat)
return 0;
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
FcPatternDestroy (match);
return font;
}
XftFont *
XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
{
FcPattern *pat;
FcPattern *match;
FcResult result;
XftFont *font;
pat = XftXlfdParse (xlfd, FcFalse, FcFalse);
if (XftDebug () & XFT_DBG_OPEN)
{
printf ("XftFontOpenXlfd \"%s\": ", xlfd);
if (pat)
printf ("Invalid xlfd\n");
else
FcPatternPrint (pat);
}
if (!pat)
return 0;
match = XftFontMatch (dpy, screen, pat, &result);
if (XftDebug () & XFT_DBG_OPEN)
{
if (match)
{
printf ("Match ");
FcPatternPrint (match);
}
else
printf ("No Match\n");
}
FcPatternDestroy (pat);
if (!match)
return 0;
font = XftFontOpenPattern (dpy, match);
if (!font)
FcPatternDestroy (match);
return font;
}

View File

@@ -1,788 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftfreetype.c,v 1.18 2002/02/19 07:56:29 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "xftint.h"
#include <X11/Xlibint.h>
FT_Library _XftFTlibrary;
#define FT_Matrix_Equal(a,b) ((a)->xx == (b)->xx && \
(a)->yy == (b)->yy && \
(a)->xy == (b)->xy && \
(a)->yx == (b)->yx)
/*
* List of all open files (each face in a file is managed separately)
*/
static XftFtFile *_XftFtFiles;
int XftMaxFreeTypeFiles = 5;
static XftFtFile *
_XftGetFile (const FcChar8 *file, int id)
{
XftFtFile *f;
if (!XftInitFtLibrary ())
return 0;
for (f = _XftFtFiles; f; f = f->next)
{
if (!strcmp (f->file, (FcChar8 *) file) && f->id == id)
{
++f->ref;
if (XftDebug () & XFT_DBG_REF)
printf ("FontFile %s/%d matches existing (%d)\n",
file, id, f->ref);
return f;
}
}
f = malloc (sizeof (XftFtFile) + strlen ((char *) file) + 1);
if (!f)
return 0;
XftMemAlloc (XFT_MEM_FILE, sizeof (XftFtFile) + strlen ((char *) file) + 1);
if (XftDebug () & XFT_DBG_REF)
printf ("FontFile %s/%d matches new\n",
file, id);
f->next = _XftFtFiles;
_XftFtFiles = f;
f->ref = 1;
f->file = (char *) (f+1);
strcpy (f->file, file);
f->id = id;
f->lock = 0;
f->face = 0;
f->size = 0;
return f;
}
static int
_XftNumFiles (void)
{
XftFtFile *f;
int count = 0;
for (f = _XftFtFiles; f; f = f->next)
if (f->face && !f->lock)
++count;
return count;
}
static XftFtFile *
_XftNthFile (int n)
{
XftFtFile *f;
int count = 0;
for (f = _XftFtFiles; f; f = f->next)
if (f->face && !f->lock)
if (count++ == n)
break;
return f;
}
static void
_XftUncacheFiles (void)
{
int n;
XftFtFile *f;
while ((n = _XftNumFiles ()) > XftMaxFreeTypeFiles)
{
f = _XftNthFile (rand () % n);
if (f)
{
if (XftDebug() & XFT_DBG_REF)
printf ("Discard file %s/%d from cache\n",
f->file, f->id);
FT_Done_Face (f->face);
f->face = 0;
}
}
}
static FT_Face
_XftLockFile (XftFtFile *f)
{
++f->lock;
if (!f->face)
{
if (XftDebug() & XFT_DBG_REF)
printf ("Loading file %s/%d\n", f->file, f->id);
if (FT_New_Face (_XftFTlibrary, f->file, f->id, &f->face))
--f->lock;
f->size = 0;
f->matrix.xx = f->matrix.xy = f->matrix.yx = f->matrix.yy = 0;
_XftUncacheFiles ();
}
return f->face;
}
static void
_XftLockError (char *reason)
{
fprintf (stderr, "Xft: locking error %s\n", reason);
}
static void
_XftUnlockFile (XftFtFile *f)
{
if (--f->lock < 0)
_XftLockError ("too many file unlocks");
}
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 size, FT_Matrix *matrix)
{
FT_Face face = f->face;
if (f->size != size)
{
if (XftDebug() & XFT_DBG_GLYPH)
printf ("Set face size to %d (%d)\n",
(int) (size >> 6), (int) size);
if (FT_Set_Char_Size (face, size, size, 0, 0))
return False;
f->size = size;
}
if (!FT_Matrix_Equal (&f->matrix, matrix))
{
if (XftDebug() & XFT_DBG_GLYPH)
printf ("Set face matrix to (%g,%g,%g,%g)\n",
(double) matrix->xx / 0x10000,
(double) matrix->xy / 0x10000,
(double) matrix->yx / 0x10000,
(double) matrix->yy / 0x10000);
FT_Set_Transform (face, matrix, 0);
f->matrix = *matrix;
}
return True;
}
static void
_XftReleaseFile (XftFtFile *f)
{
XftFtFile **prev;
if (--f->ref != 0)
return;
if (f->lock)
_XftLockError ("Attempt to close locked file");
for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
{
if (*prev == f)
{
*prev = f->next;
break;
}
}
if (f->face)
FT_Done_Face (f->face);
XftMemFree (XFT_MEM_FILE, sizeof (XftFtFile) + strlen (f->file) + 1);
free (f);
}
/*
* Find a prime larger than the minimum reasonable hash size
*/
static FcChar32
_XftSqrt (FcChar32 a)
{
FcChar32 l, h, m;
l = 2;
h = a/2;
while ((h-l) > 1)
{
m = (h+l) >> 1;
if (m * m < a)
l = m;
else
h = m;
}
return h;
}
static FcBool
_XftIsPrime (FcChar32 i)
{
FcChar32 l, t;
if (i < 2)
return FcFalse;
if ((i & 1) == 0)
{
if (i == 2)
return FcTrue;
return FcFalse;
}
l = _XftSqrt (i) + 1;
for (t = 3; t <= l; t += 2)
if (i % t == 0)
return FcFalse;
return FcTrue;
}
static FcChar32
_XftHashSize (FcChar32 num_unicode)
{
/* at least 31.25 % extra space */
FcChar32 hash = num_unicode + (num_unicode >> 2) + (num_unicode >> 4);
if ((hash & 1) == 0)
hash++;
while (!_XftIsPrime (hash))
hash += 2;
return hash;
}
FT_Face
XftLockFace (XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
return _XftLockFile (font->file);
}
void
XftUnlockFace (XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
_XftUnlockFile (font->file);
}
XftFont *
XftFontOpenPattern (Display *dpy, FcPattern *pattern)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFtFile *file;
FT_Face face;
FcChar8 *filename;
int id;
double dsize;
FT_F26Dot6 size;
int spacing;
int char_width;
Bool minspace;
XftFont *public;
XftFontInt *font;
FcBool render;
int i;
FcCharSet *charset;
FcChar32 num_unicode;
FcChar32 hash_value;
FcChar32 rehash_value;
int max_glyph_memory;
int alloc_size;
/*
* Font information placed in XftFontInt
*/
FcBool antialias;
int rgba;
FcBool transform;
FT_Matrix matrix;
FT_Int load_flags;
FcBool hinting, vertical_layout, autohint, global_advance;
FcMatrix *font_matrix;
int height, ascent, descent;
XRenderPictFormat pf, *format;
if (!info)
goto bail0;
/*
* Find the associated file
*/
if (FcPatternGetString (pattern, FC_FILE, 0, &filename) != FcResultMatch)
goto bail0;
if (FcPatternGetInteger (pattern, FC_INDEX, 0, &id) != FcResultMatch)
goto bail0;
file = _XftGetFile (filename, id);
if (!file)
goto bail0;
face = _XftLockFile (file);
if (!face)
goto bail1;
/*
* Extract the glyphset information from the pattern
*/
if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &dsize) != FcResultMatch)
goto bail2;
switch (FcPatternGetBool (pattern, FC_MINSPACE, 0, &minspace)) {
case FcResultNoMatch:
minspace = False;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
switch (FcPatternGetInteger (pattern, FC_SPACING, 0, &spacing)) {
case FcResultNoMatch:
spacing = FC_PROPORTIONAL;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (FcPatternGetInteger (pattern, FC_CHAR_WIDTH,
0, &char_width) != FcResultMatch)
{
char_width = 0;
}
else if (char_width)
spacing = FC_MONO;
if (face->face_flags & FT_FACE_FLAG_SCALABLE)
{
switch (FcPatternGetBool (pattern, FC_ANTIALIAS, 0, &antialias)) {
case FcResultNoMatch:
antialias = True;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
}
else
antialias = False;
switch (FcPatternGetInteger (pattern, FC_RGBA, 0, &rgba)) {
case FcResultNoMatch:
rgba = FC_RGBA_NONE;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
matrix.xx = matrix.yy = 0x10000;
matrix.xy = matrix.yx = 0;
switch (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &font_matrix)) {
case FcResultNoMatch:
break;
case FcResultMatch:
matrix.xx = 0x10000L * font_matrix->xx;
matrix.yy = 0x10000L * font_matrix->yy;
matrix.xy = 0x10000L * font_matrix->xy;
matrix.yx = 0x10000L * font_matrix->yx;
break;
default:
goto bail2;
}
transform = (matrix.xx != 0x10000 || matrix.xy != 0 ||
matrix.yx != 0 || matrix.yy != 0x10000);
if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
{
charset = 0;
}
if (FcPatternGetInteger (pattern, FC_CHAR_WIDTH,
0, &char_width) != FcResultMatch)
{
char_width = 0;
}
else if (char_width)
spacing = FC_MONO;
switch (FcPatternGetBool (pattern, XFT_RENDER, 0, &render)) {
case FcResultNoMatch:
render = info->hasRender;
break;
case FcResultMatch:
if (render && !info->hasRender)
render = FcFalse;
break;
default:
goto bail2;
}
/*
* Compute glyph load flags
*/
load_flags = FT_LOAD_DEFAULT;
/* disable bitmaps when anti-aliasing or transforming glyphs */
if (antialias || transform)
load_flags |= FT_LOAD_NO_BITMAP;
/* disable hinting if requested */
switch (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting)) {
case FcResultNoMatch:
hinting = FcTrue;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (!hinting)
load_flags |= FT_LOAD_NO_HINTING;
/* set vertical layout if requested */
switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) {
case FcResultNoMatch:
vertical_layout = FcFalse;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (vertical_layout)
load_flags |= FT_LOAD_VERTICAL_LAYOUT;
/* force autohinting if requested */
switch (FcPatternGetBool (pattern, FC_AUTOHINT, 0, &autohint)) {
case FcResultNoMatch:
autohint = FcFalse;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (autohint)
load_flags |= FT_LOAD_FORCE_AUTOHINT;
/* disable global advance width (for broken DynaLab TT CJK fonts) */
switch (FcPatternGetBool (pattern, FC_GLOBAL_ADVANCE, 0, &global_advance)) {
case FcResultNoMatch:
global_advance = FcTrue;
break;
case FcResultMatch:
break;
default:
goto bail2;
}
if (!global_advance)
load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
if (FcPatternGetInteger (pattern, XFT_MAX_GLYPH_MEMORY,
0, &max_glyph_memory) != FcResultMatch)
{
max_glyph_memory = XFT_FONT_MAX_GLYPH_MEMORY;
}
size = (FT_F26Dot6) (dsize * 64.0);
/*
* Match an existing font
*/
for (public = info->fonts; public; public = font->next)
{
font = (XftFontInt *) public;
if (font->file == file &&
font->minspace == minspace &&
font->char_width == char_width &&
font->size == size &&
font->spacing == spacing &&
font->rgba == rgba &&
font->antialias == antialias &&
font->load_flags == load_flags &&
(font->format != 0) == render &&
FT_Matrix_Equal (&font->matrix, &matrix))
{
++font->ref;
if (XftDebug () & XFT_DBG_REF)
{
printf ("Face size %g matches existing (%d)\n",
dsize, font->ref);
}
_XftUnlockFile (file);
_XftReleaseFile (file);
FcPatternDestroy (pattern);
return &font->public;
}
}
if (XftDebug () & XFT_DBG_REF)
printf ("Face size %g matches new\n", dsize);
/*
* No existing glyphset, create another.
*/
if (render)
{
if (antialias)
{
if (rgba)
{
pf.depth = 32;
pf.type = PictTypeDirect;
pf.direct.alpha = 24;
pf.direct.alphaMask = 0xff;
pf.direct.red = 16;
pf.direct.redMask = 0xff;
pf.direct.green = 8;
pf.direct.greenMask = 0xff;
pf.direct.blue = 0;
pf.direct.blueMask = 0xff;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask|
PictFormatRed|
PictFormatRedMask|
PictFormatGreen|
PictFormatGreenMask|
PictFormatBlue|
PictFormatBlueMask,
&pf, 0);
}
else
{
pf.depth = 8;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0xff;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
}
}
else
{
pf.depth = 1;
pf.type = PictTypeDirect;
pf.direct.alpha = 0;
pf.direct.alphaMask = 0x1;
format = XRenderFindFormat(dpy,
PictFormatType|
PictFormatDepth|
PictFormatAlpha|
PictFormatAlphaMask,
&pf, 0);
}
if (!format)
goto bail2;
}
else
format = 0;
if (!_XftSetFace (file, size, &matrix))
goto bail2;
if (charset)
{
num_unicode = FcCharSetCount (charset);
hash_value = _XftHashSize (num_unicode);
rehash_value = hash_value - 2;
}
else
{
num_unicode = 0;
hash_value = 0;
rehash_value = 0;
}
alloc_size = (sizeof (XftFontInt) +
face->num_glyphs * sizeof (XftGlyph *) +
hash_value * sizeof (XftUcsHash));
font = malloc (alloc_size);
if (!font)
goto bail2;
XftMemAlloc (XFT_MEM_FONT, alloc_size);
/*
* Public fields
*/
descent = -(face->size->metrics.descender >> 6);
ascent = face->size->metrics.ascender >> 6;
if (minspace)
{
height = ascent + descent;
}
else
{
height = face->size->metrics.height >> 6;
}
font->public.ascent = ascent;
font->public.descent = descent;
font->public.height = height;
if (char_width)
font->public.max_advance_width = char_width;
else
font->public.max_advance_width = face->size->metrics.max_advance >> 6;
font->public.charset = charset;
font->public.pattern = pattern;
/*
* Management fields
*/
font->next = info->fonts;
info->fonts = &font->public;
font->file = file;
font->ref = 1;
/*
* Per glyph information
*/
font->glyphs = (XftGlyph **) (font + 1);
memset (font->glyphs, '\0', face->num_glyphs * sizeof (XftGlyph *));
font->num_glyphs = face->num_glyphs;
/*
* Unicode hash table information
*/
font->hash_table = (XftUcsHash *) (font->glyphs + font->num_glyphs);
for (i = 0; i < hash_value; i++)
{
font->hash_table[i].ucs4 = ((FcChar32) ~0);
font->hash_table[i].glyph = 0;
}
font->hash_value = hash_value;
font->rehash_value = rehash_value;
/*
* X specific fields
*/
font->glyphset = 0;
font->format = format;
/*
* Rendering options
*/
font->size = size;
font->antialias = antialias;
font->rgba = rgba;
font->transform = transform;
font->matrix = matrix;
font->load_flags = load_flags;
font->minspace = minspace;
font->char_width = char_width;
font->spacing = spacing;
/*
* Glyph memory management fields
*/
font->glyph_memory = 0;
font->max_glyph_memory = max_glyph_memory;
font->use_free_glyphs = info->use_free_glyphs;
_XftUnlockFile (file);
return &font->public;
bail2:
_XftUnlockFile (file);
bail1:
_XftReleaseFile (file);
bail0:
return 0;
}
XftFont *
XftFontCopy (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
font->ref++;
return public;
}
void
XftFontClose (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFont **prev;
int i;
if (--font->ref == 0)
{
if (info)
{
/* Unhook from display list */
for (prev = &info->fonts; *prev; prev = &(*(XftFontInt **) prev)->next)
{
if (*prev == public)
{
*prev = font->next;
break;
}
}
}
/* Free resources */
/* Dereference the file */
_XftReleaseFile (font->file);
/* Free the glyphset */
if (font->glyphset)
XRenderFreeGlyphSet (dpy, font->glyphset);
/* Free the glyphs */
for (i = 0; i < font->num_glyphs; i++)
{
XftGlyph *xftg = font->glyphs[i];
if (xftg)
{
if (xftg->bitmap)
free (xftg->bitmap);
free (xftg);
}
}
/* Finally, free the font structure */
XftMemFree (XFT_MEM_FONT, sizeof (XftFontInt) +
font->num_glyphs * sizeof (XftGlyph *) +
font->hash_value * sizeof (XftUcsHash));
free (font);
}
}
FcBool
XftInitFtLibrary (void)
{
if (_XftFTlibrary)
return FcTrue;
if (FT_Init_FreeType (&_XftFTlibrary))
return FcFalse;
return FcTrue;
}

View File

@@ -1,769 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftglyphs.c,v 1.15 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
#include <freetype/ftoutln.h>
#include <fontconfig/fcfreetype.h>
static const int filters[3][3] = {
/* red */
#if 0
{ 65538*4/7,65538*2/7,65538*1/7 },
/* green */
{ 65536*1/4, 65536*2/4, 65537*1/4 },
/* blue */
{ 65538*1/7,65538*2/7,65538*4/7 },
#endif
{ 65538*9/13,65538*3/13,65538*1/13 },
/* green */
{ 65538*1/6, 65538*4/6, 65538*1/6 },
/* blue */
{ 65538*1/13,65538*3/13,65538*9/13 },
};
void
XftFontLoadGlyphs (Display *dpy,
XftFont *public,
FcBool need_bitmaps,
FT_UInt *glyphs,
int nglyph)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFontInt *font = (XftFontInt *) public;
FT_Error error;
FT_UInt glyphindex;
FT_GlyphSlot glyphslot;
XftGlyph *xftg;
Glyph glyph;
unsigned char bufLocal[4096];
unsigned char *bufBitmap = bufLocal;
int bufSize = sizeof (bufLocal);
int size, pitch;
unsigned char bufLocalRgba[4096];
unsigned char *bufBitmapRgba = bufLocalRgba;
int bufSizeRgba = sizeof (bufLocalRgba);
int sizergba, pitchrgba, widthrgba;
int width;
int height;
int left, right, top, bottom;
int hmul = 1;
int vmul = 1;
FT_Bitmap ftbit;
FT_Matrix matrix;
FT_Vector vector;
Bool subpixel = False;
FT_Face face;
if (!info)
return;
face = XftLockFace (&font->public);
if (!_XftSetFace (font->file, font->size, &font->matrix))
{
XftUnlockFace (&font->public);
return;
}
matrix.xx = matrix.yy = 0x10000L;
matrix.xy = matrix.yx = 0;
if (font->antialias)
{
switch (font->rgba) {
case FC_RGBA_RGB:
case FC_RGBA_BGR:
matrix.xx *= 3;
subpixel = True;
hmul = 3;
break;
case FC_RGBA_VRGB:
case FC_RGBA_VBGR:
matrix.yy *= 3;
vmul = 3;
subpixel = True;
break;
}
}
while (nglyph--)
{
glyphindex = *glyphs++;
xftg = font->glyphs[glyphindex];
if (!xftg)
continue;
error = FT_Load_Glyph (face, glyphindex, font->load_flags);
if (error)
{
/*
* If anti-aliasing or transforming glyphs and
* no outline version exists, fallback to the
* bitmap and let things look bad instead of
* missing the glyph
*/
if (font->load_flags & FT_LOAD_NO_BITMAP)
error = FT_Load_Glyph (face, glyphindex,
font->load_flags & ~FT_LOAD_NO_BITMAP);
if (error)
continue;
}
#define FLOOR(x) ((x) & -64)
#define CEIL(x) (((x)+63) & -64)
#define TRUNC(x) ((x) >> 6)
#define ROUND(x) (((x)+32) & -64)
glyphslot = face->glyph;
/*
* Compute glyph metrics from FreeType information
*/
if(font->transform && glyphslot->format != ft_glyph_format_bitmap)
{
/*
* calculate the true width by transforming all four corners.
*/
int xc, yc;
left = right = top = bottom = 0;
for(xc = 0; xc <= 1; xc ++) {
for(yc = 0; yc <= 1; yc++) {
vector.x = glyphslot->metrics.horiBearingX + xc * glyphslot->metrics.width;
vector.y = glyphslot->metrics.horiBearingY - yc * glyphslot->metrics.height;
FT_Vector_Transform(&vector, &font->matrix);
if (XftDebug() & XFT_DBG_GLYPH)
printf("Trans %d %d: %d %d\n", (int) xc, (int) yc,
(int) vector.x, (int) vector.y);
if(xc == 0 && yc == 0) {
left = right = vector.x;
top = bottom = vector.y;
} else {
if(left > vector.x) left = vector.x;
if(right < vector.x) right = vector.x;
if(bottom > vector.y) bottom = vector.y;
if(top < vector.y) top = vector.y;
}
}
}
left = FLOOR(left);
right = CEIL(right);
bottom = FLOOR(bottom);
top = CEIL(top);
} else {
left = FLOOR( glyphslot->metrics.horiBearingX );
right = CEIL( glyphslot->metrics.horiBearingX + glyphslot->metrics.width );
top = CEIL( glyphslot->metrics.horiBearingY );
bottom = FLOOR( glyphslot->metrics.horiBearingY - glyphslot->metrics.height );
}
width = TRUNC(right - left);
height = TRUNC( top - bottom );
/*
* Try to keep monospace fonts ink-inside
* XXX transformed?
*/
if (font->spacing != FC_PROPORTIONAL && !font->transform)
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
if (TRUNC(bottom) > font->public.max_advance_width)
{
int adjust;
adjust = bottom - (font->public.max_advance_width << 6);
if (adjust > top)
adjust = top;
top -= adjust;
bottom -= adjust;
height = font->public.max_advance_width;
}
}
else
{
if (TRUNC(right) > font->public.max_advance_width)
{
int adjust;
adjust = right - (font->public.max_advance_width << 6);
if (adjust > left)
adjust = left;
left -= adjust;
right -= adjust;
width = font->public.max_advance_width;
}
}
}
if (font->antialias)
pitch = (width * hmul + 3) & ~3;
else
pitch = ((width + 31) & ~31) >> 3;
size = pitch * height * vmul;
xftg->metrics.width = width;
xftg->metrics.height = height;
xftg->metrics.x = -TRUNC(left);
xftg->metrics.y = TRUNC(top);
if (font->spacing != FC_PROPORTIONAL)
{
if (font->transform)
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
vector.x = 0;
vector.y = -font->public.max_advance_width;
}
else
{
vector.x = font->public.max_advance_width;
vector.y = 0;
}
FT_Vector_Transform (&vector, &font->matrix);
xftg->metrics.xOff = vector.x;
xftg->metrics.yOff = -vector.y;
}
else
{
if (font->load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
xftg->metrics.xOff = 0;
xftg->metrics.yOff = -font->public.max_advance_width;
}
else
{
xftg->metrics.xOff = font->public.max_advance_width;
xftg->metrics.yOff = 0;
}
}
}
else
{
xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x));
xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y));
}
/*
* If the glyph is relatively large (> 1% of server memory),
* don't send it until necessary
*/
if (!need_bitmaps && size > info->max_glyph_memory / 100)
continue;
/*
* Make sure there's enough buffer space for the glyph
*/
if (size > bufSize)
{
if (bufBitmap != bufLocal)
free (bufBitmap);
bufBitmap = (unsigned char *) malloc (size);
if (!bufBitmap)
continue;
bufSize = size;
}
memset (bufBitmap, 0, size);
/*
* Rasterize into the local buffer
*/
switch (glyphslot->format) {
case ft_glyph_format_outline:
ftbit.width = width * hmul;
ftbit.rows = height * vmul;
ftbit.pitch = pitch;
if (font->antialias)
ftbit.pixel_mode = ft_pixel_mode_grays;
else
ftbit.pixel_mode = ft_pixel_mode_mono;
ftbit.buffer = bufBitmap;
if (subpixel)
FT_Outline_Transform (&glyphslot->outline, &matrix);
FT_Outline_Translate ( &glyphslot->outline, -left*hmul, -bottom*vmul );
FT_Outline_Get_Bitmap( _XftFTlibrary, &glyphslot->outline, &ftbit );
break;
case ft_glyph_format_bitmap:
if (font->antialias)
{
unsigned char *srcLine, *dstLine;
int height;
int x;
int h, v;
srcLine = glyphslot->bitmap.buffer;
dstLine = bufBitmap;
height = glyphslot->bitmap.rows;
while (height--)
{
for (x = 0; x < glyphslot->bitmap.width; x++)
{
/* always MSB bitmaps */
unsigned char a = ((srcLine[x >> 3] & (0x80 >> (x & 7))) ?
0xff : 0x00);
if (subpixel)
{
for (v = 0; v < vmul; v++)
for (h = 0; h < hmul; h++)
dstLine[v * pitch + x*hmul + h] = a;
}
else
dstLine[x] = a;
}
dstLine += pitch * vmul;
}
}
else
{
unsigned char *srcLine, *dstLine;
int h, bytes;
srcLine = glyphslot->bitmap.buffer;
dstLine = bufBitmap;
h = glyphslot->bitmap.rows;
bytes = (glyphslot->bitmap.width + 7) >> 3;
while (h--)
{
memcpy (dstLine, srcLine, bytes);
dstLine += pitch;
srcLine += glyphslot->bitmap.pitch;
}
}
break;
default:
if (XftDebug() & XFT_DBG_GLYPH)
printf ("glyph %d is not in a usable format\n",
(int) glyphindex);
continue;
}
if (XftDebug() & XFT_DBG_GLYPH)
{
printf ("glyph %d:\n", (int) glyphindex);
printf (" xywh (%d %d %d %d), trans (%d %d %d %d) wh (%d %d)\n",
(int) glyphslot->metrics.horiBearingX,
(int) glyphslot->metrics.horiBearingY,
(int) glyphslot->metrics.width,
(int) glyphslot->metrics.height,
left, right, top, bottom,
width, height);
if (XftDebug() & XFT_DBG_GLYPHV)
{
int x, y;
unsigned char *line;
line = bufBitmap;
for (y = 0; y < height * vmul; y++)
{
if (font->antialias)
{
static char den[] = { " .:;=+*#" };
for (x = 0; x < pitch; x++)
printf ("%c", den[line[x] >> 5]);
}
else
{
for (x = 0; x < pitch * 8; x++)
{
printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
}
}
printf ("|\n");
line += pitch;
}
printf ("\n");
}
}
/*
* Use the glyph index as the wire encoding; it
* might be more efficient for some locales to map
* these by first usage to smaller values, but that
* would require persistently storing the map when
* glyphs were freed.
*/
glyph = (Glyph) glyphindex;
if (subpixel)
{
int x, y;
unsigned char *in_line, *out_line, *in;
unsigned int *out;
unsigned int red, green, blue;
int rf, gf, bf;
int s;
int o, os;
/*
* Filter the glyph to soften the color fringes
*/
widthrgba = width;
pitchrgba = (widthrgba * 4 + 3) & ~3;
sizergba = pitchrgba * height;
os = 1;
switch (font->rgba) {
case FC_RGBA_VRGB:
os = pitch;
case FC_RGBA_RGB:
default:
rf = 0;
gf = 1;
bf = 2;
break;
case FC_RGBA_VBGR:
os = pitch;
case FC_RGBA_BGR:
bf = 0;
gf = 1;
rf = 2;
break;
}
if (sizergba > bufSizeRgba)
{
if (bufBitmapRgba != bufLocalRgba)
free (bufBitmapRgba);
bufBitmapRgba = (unsigned char *) malloc (sizergba);
if (!bufBitmapRgba)
continue;
bufSizeRgba = sizergba;
}
memset (bufBitmapRgba, 0, sizergba);
in_line = bufBitmap;
out_line = bufBitmapRgba;
for (y = 0; y < height; y++)
{
in = in_line;
out = (unsigned int *) out_line;
in_line += pitch * vmul;
out_line += pitchrgba;
for (x = 0; x < width * hmul; x += hmul)
{
red = green = blue = 0;
o = 0;
for (s = 0; s < 3; s++)
{
red += filters[rf][s]*in[x+o];
green += filters[gf][s]*in[x+o];
blue += filters[bf][s]*in[x+o];
o += os;
}
red = red / 65536;
green = green / 65536;
blue = blue / 65536;
*out++ = (green << 24) | (red << 16) | (green << 8) | blue;
}
}
xftg->glyph_memory = sizergba + sizeof (XftGlyph);
if (font->format)
{
if (!font->glyphset)
font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
if (ImageByteOrder (dpy) != XftNativeByteOrder ())
XftSwapCARD32 ((CARD32 *) bufBitmapRgba, sizergba >> 2);
XRenderAddGlyphs (dpy, font->glyphset, &glyph,
&xftg->metrics, 1,
(char *) bufBitmapRgba, sizergba);
}
else
{
xftg->bitmap = malloc (sizergba);
if (xftg->bitmap)
memcpy (xftg->bitmap, bufBitmapRgba, sizergba);
}
}
else
{
xftg->glyph_memory = size + sizeof (XftGlyph);
if (font->format)
{
/*
* swap bit order around; FreeType is always MSBFirst
*/
if (!font->antialias)
{
if (BitmapBitOrder (dpy) != MSBFirst)
{
unsigned char *line;
unsigned char c;
int i;
line = (unsigned char *) bufBitmap;
i = size;
while (i--)
{
c = *line;
c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
*line++ = c;
}
}
}
if (!font->glyphset)
font->glyphset = XRenderCreateGlyphSet (dpy, font->format);
XRenderAddGlyphs (dpy, font->glyphset, &glyph,
&xftg->metrics, 1,
(char *) bufBitmap, size);
}
else
{
xftg->bitmap = malloc (size);
if (xftg->bitmap)
memcpy (xftg->bitmap, bufBitmap, size);
}
}
font->glyph_memory += xftg->glyph_memory;
info->glyph_memory += xftg->glyph_memory;
if (XftDebug() & XFT_DBG_CACHEV)
printf ("Caching glyph 0x%x size %ld\n", glyphindex,
xftg->glyph_memory);
}
if (bufBitmap != bufLocal)
free (bufBitmap);
if (bufBitmapRgba != bufLocalRgba)
free (bufBitmapRgba);
XftUnlockFace (&font->public);
}
void
XftFontUnloadGlyphs (Display *dpy,
XftFont *public,
FT_UInt *glyphs,
int nglyph)
{
XftDisplayInfo *info = _XftDisplayInfoGet (dpy);
XftFontInt *font = (XftFontInt *) public;
XftGlyph *xftg;
FT_UInt glyphindex;
Glyph glyphBuf[1024];
int nused;
nused = 0;
while (nglyph--)
{
glyphindex = *glyphs++;
xftg = font->glyphs[glyphindex];
if (!xftg)
continue;
if (xftg->glyph_memory)
{
if (font->format)
{
if (font->glyphset)
{
glyphBuf[nused++] = (Glyph) glyphindex;
if (nused == sizeof (glyphBuf) / sizeof (glyphBuf[0]))
{
XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
nused = 0;
}
}
}
else
{
if (xftg->bitmap)
free (xftg->bitmap);
}
font->glyph_memory -= xftg->glyph_memory;
if (info)
info->glyph_memory -= xftg->glyph_memory;
}
free (xftg);
XftMemFree (XFT_MEM_GLYPH, sizeof (XftGlyph));
font->glyphs[glyphindex] = 0;
}
if (font->glyphset && nused)
XRenderFreeGlyphs (dpy, font->glyphset, glyphBuf, nused);
}
FcBool
XftFontCheckGlyph (Display *dpy,
XftFont *public,
FcBool need_bitmaps,
FT_UInt glyph,
FT_UInt *missing,
int *nmissing)
{
XftFontInt *font = (XftFontInt *) public;
XftGlyph *xftg;
int n;
if (glyph >= font->num_glyphs)
return FcFalse;
xftg = font->glyphs[glyph];
if (!xftg || (need_bitmaps && !xftg->glyph_memory))
{
if (!xftg)
{
xftg = (XftGlyph *) malloc (sizeof (XftGlyph));
if (!xftg)
return FcFalse;
XftMemAlloc (XFT_MEM_GLYPH, sizeof (XftGlyph));
xftg->bitmap = 0;
xftg->glyph_memory = 0;
font->glyphs[glyph] = xftg;
}
n = *nmissing;
missing[n++] = glyph;
if (n == XFT_NMISSING)
{
XftFontLoadGlyphs (dpy, public, need_bitmaps, missing, n);
n = 0;
}
*nmissing = n;
return FcTrue;
}
else
return FcFalse;
}
FcBool
XftCharExists (Display *dpy,
XftFont *public,
FcChar32 ucs4)
{
if (public->charset)
return FcCharSetHasChar (public->charset, ucs4);
return FcFalse;
}
#define Missing ((FT_UInt) ~0)
FT_UInt
XftCharIndex (Display *dpy,
XftFont *public,
FcChar32 ucs4)
{
XftFontInt *font = (XftFontInt *) public;
FcChar32 ent, offset;
FT_Face face;
ent = ucs4 % font->hash_value;
offset = 0;
while (font->hash_table[ent].ucs4 != ucs4)
{
if (font->hash_table[ent].ucs4 == (FcChar32) ~0)
{
if (!XftCharExists (dpy, public, ucs4))
return 0;
face = XftLockFace (public);
if (!face)
return 0;
font->hash_table[ent].ucs4 = ucs4;
font->hash_table[ent].glyph = FcFreeTypeCharIndex (face, ucs4);
XftUnlockFace (public);
break;
}
if (!offset)
{
offset = ucs4 % font->rehash_value;
if (!offset)
offset = 1;
}
ent = ent + offset;
if (ent > font->hash_value)
ent -= font->hash_value;
}
return font->hash_table[ent].glyph;
}
/*
* Pick a random glyph from the font and remove it from the cache
*/
void
_XftFontUncacheGlyph (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
unsigned long glyph_memory;
FT_UInt glyphindex;
XftGlyph *xftg;
if (!font->glyph_memory)
return;
if (font->use_free_glyphs)
{
glyph_memory = rand() % font->glyph_memory;
}
else
{
if (font->glyphset)
{
XRenderFreeGlyphSet (dpy, font->glyphset);
font->glyphset = 0;
}
glyph_memory = 0;
}
for (glyphindex = 0; glyphindex < font->num_glyphs; glyphindex++)
{
xftg = font->glyphs[glyphindex];
if (xftg)
{
if (xftg->glyph_memory > glyph_memory)
{
if (XftDebug() & XFT_DBG_CACHEV)
printf ("Uncaching glyph 0x%x size %ld\n",
glyphindex, xftg->glyph_memory);
XftFontUnloadGlyphs (dpy, public, &glyphindex, 1);
if (!font->use_free_glyphs)
continue;
break;
}
glyph_memory -= xftg->glyph_memory;
}
}
}
void
_XftFontManageMemory (Display *dpy, XftFont *public)
{
XftFontInt *font = (XftFontInt *) public;
if (font->max_glyph_memory)
{
if (XftDebug() & XFT_DBG_CACHE)
{
if (font->glyph_memory > font->max_glyph_memory)
printf ("Reduce memory for font 0x%lx from %ld to %ld\n",
font->glyphset ? font->glyphset : (unsigned long) font,
font->glyph_memory, font->max_glyph_memory);
}
while (font->glyph_memory > font->max_glyph_memory)
_XftFontUncacheGlyph (dpy, public);
}
_XftDisplayManageMemory (dpy);
}

View File

@@ -1,112 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftinit.c,v 1.3 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include "xftint.h"
#include <X11/Xlibint.h>
Bool _XftConfigInitialized;
Bool
XftInit (char *config)
{
if (_XftConfigInitialized)
return True;
_XftConfigInitialized = True;
if (!FcInit ())
return False;
_XftNameInit ();
return True;
}
static struct {
char *name;
int alloc_count;
int alloc_mem;
int free_count;
int free_mem;
} XftInUse[XFT_MEM_NUM] = {
{ "XftDraw", 0, 0 },
{ "XftFont", 0 ,0 },
{ "XftFtFile", 0, 0 },
{ "XftGlyph", 0, 0 },
};
static int XftAllocCount, XftAllocMem;
static int XftFreeCount, XftFreeMem;
static int XftMemNotice = 1*1024*1024;
static int XftAllocNotify, XftFreeNotify;
void
XftMemReport (void)
{
int i;
printf ("Xft Memory Usage:\n");
printf ("\t Which Alloc Free\n");
printf ("\t count bytes count bytes\n");
for (i = 0; i < XFT_MEM_NUM; i++)
printf ("\t%8.8s%8d%8d%8d%8d\n",
XftInUse[i].name,
XftInUse[i].alloc_count, XftInUse[i].alloc_mem,
XftInUse[i].free_count, XftInUse[i].free_mem);
printf ("\t%8.8s%8d%8d%8d%8d\n",
"Total",
XftAllocCount, XftAllocMem,
XftFreeCount, XftFreeMem);
XftAllocNotify = 0;
XftFreeNotify = 0;
}
void
XftMemAlloc (int kind, int size)
{
if (XftDebug() & XFT_DBG_MEMORY)
{
XftInUse[kind].alloc_count++;
XftInUse[kind].alloc_mem += size;
XftAllocCount++;
XftAllocMem += size;
XftAllocNotify += size;
if (XftAllocNotify > XftMemNotice)
XftMemReport ();
}
}
void
XftMemFree (int kind, int size)
{
if (XftDebug() & XFT_DBG_MEMORY)
{
XftInUse[kind].free_count++;
XftInUse[kind].free_mem += size;
XftFreeCount++;
XftFreeMem += size;
XftFreeNotify += size;
if (XftFreeNotify > XftMemNotice)
XftMemReport ();
}
}

View File

@@ -1,380 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftint.h,v 1.29 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* These definitions are solely for use by the implementation of Xft
* and constitute no kind of standard. If you need any of these functions,
* please drop me a note. Either the library needs new functionality,
* or there's a way to do what you need using the existing published
* interfaces. keithp@xfree86.org
*/
#ifndef _XFTINT_H_
#define _XFTINT_H_
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#define _XFT_NO_COMPAT_
#include "Xft.h"
#include <fontconfig/fcprivate.h>
typedef struct _XftMatcher {
char *object;
double (*compare) (char *object, FcValue value1, FcValue value2);
} XftMatcher;
typedef struct _XftSymbolic {
const char *name;
int value;
} XftSymbolic;
/*
* Glyphs are stored in this structure
*/
typedef struct _XftGlyph {
XGlyphInfo metrics;
void *bitmap;
unsigned long glyph_memory;
} XftGlyph;
/*
* A hash table translates Unicode values into glyph indicies
*/
typedef struct _XftUcsHash {
FcChar32 ucs4;
FT_UInt glyph;
} XftUcsHash;
/*
* Many fonts can share the same underlying face data; this
* structure references that. Note that many faces may in fact
* live in the same font file; that is irrelevant to this structure
* which is concerned only with the individual faces themselves
*/
typedef struct _XftFtFile {
struct _XftFtFile *next;
int ref; /* number of fonts using this file */
char *file; /* file name */
int id; /* font index within that file */
FT_F26Dot6 size; /* current size setting */
FT_Matrix matrix; /* current matrix setting */
int lock; /* lock count; can't unload unless 0 */
FT_Face face; /* pointer to face; only valid when lock */
} XftFtFile;
/*
* Internal version of the font with private data
*/
typedef struct _XftFontInt {
XftFont public; /* public fields */
XftFont *next; /* list of fonts for this display */
XftFtFile *file; /* Associated free type file */
int ref; /* reference count */
/*
* Per-glyph information, indexed by glyph ID
* This array follows the font in memory
*/
XftGlyph **glyphs;
int num_glyphs; /* size of glyphs/bitmaps arrays */
/*
* Hash table to get from Unicode value to glyph ID
* This array follows the glyphs in memory
*/
XftUcsHash *hash_table;
int hash_value;
int rehash_value;
/*
* X specific fields
*/
GlyphSet glyphset; /* Render glyphset */
XRenderPictFormat *format; /* Render format for glyphs */
/*
* Rendering options
*/
FT_F26Dot6 size;
FcBool antialias; /* doing antialiasing */
int rgba; /* subpixel order */
FcBool transform; /* non-identity matrix */
FT_Matrix matrix; /* glyph transformation matrix */
FT_Int load_flags; /* glyph load flags */
/*
* Internal fields
*/
FcBool minspace;
int char_width;
int spacing;
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
} XftFontInt;
struct _XftDraw {
Display *dpy;
int screen;
unsigned int bits_per_pixel;
unsigned int depth;
Drawable drawable;
Visual *visual; /* NULL for bitmaps */
Colormap colormap;
Region clip;
struct {
Picture pict;
} render;
struct {
GC gc;
int use_pixmap;
} core;
};
/*
* Instead of taking two round trips for each blending request,
* assume that if a particular drawable fails GetImage that it will
* fail for a "while"; use temporary pixmaps to avoid the errors
*/
#define XFT_ASSUME_PIXMAP 20
typedef struct _XftSolidColor {
XRenderColor color;
int screen;
Picture pict;
} XftSolidColor;
#define XFT_NUM_SOLID_COLOR 16
typedef struct _XftDisplayInfo {
struct _XftDisplayInfo *next;
Display *display;
XExtCodes *codes;
FcPattern *defaults;
FcBool hasRender;
XftFont *fonts;
XRenderPictFormat *solidFormat;
XftSolidColor colors[XFT_NUM_SOLID_COLOR];
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs;
} XftDisplayInfo;
/*
* By default, use no more than 4 meg of server memory total, and no
* more than 1 meg for any one font
*/
#define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
#define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
extern XftDisplayInfo *_XftDisplayInfo;
#define XFT_DBG_OPEN 1
#define XFT_DBG_OPENV 2
#define XFT_DBG_RENDER 4
#define XFT_DBG_DRAW 8
#define XFT_DBG_REF 16
#define XFT_DBG_GLYPH 32
#define XFT_DBG_GLYPHV 64
#define XFT_DBG_CACHE 128
#define XFT_DBG_CACHEV 256
#define XFT_DBG_MEMORY 512
#define XFT_MEM_DRAW 0
#define XFT_MEM_FONT 1
#define XFT_MEM_FILE 2
#define XFT_MEM_GLYPH 3
#define XFT_MEM_NUM 4
/* xftcompat.c */
void XftFontSetDestroy (FcFontSet *s);
FcBool XftMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
void XftMatrixRotate (FcMatrix *m, double c, double s);
void XftMatrixScale (FcMatrix *m, double sx, double sy);
void XftMatrixShear (FcMatrix *m, double sh, double sv);
FcPattern *XftPatternCreate (void);
void XftValueDestroy (FcValue v);
void XftPatternDestroy (FcPattern *p);
FcBool XftPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
FcBool XftPatternDel (FcPattern *p, const char *object);
FcBool XftPatternAddInteger (FcPattern *p, const char *object, int i);
FcBool XftPatternAddDouble (FcPattern *p, const char *object, double i);
FcBool XftPatternAddMatrix (FcPattern *p, const char *object, FcMatrix *i);
FcBool XftPatternAddString (FcPattern *p, const char *object, char *i);
FcBool XftPatternAddBool (FcPattern *p, const char *object, FcBool i);
FcResult XftPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
FcResult XftPatternGetInteger (FcPattern *p, const char *object, int id, int *i);
FcResult XftPatternGetDouble (FcPattern *p, const char *object, int id, double *i);
FcResult XftPatternGetString (FcPattern *p, const char *object, int id, char **i);
FcResult XftPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **i);
FcResult XftPatternGetBool (FcPattern *p, const char *object, int id, FcBool *i);
FcPattern *XftPatternDuplicate (FcPattern *orig);
FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
FcPattern *XftPatternBuild (FcPattern *orig, ...);
FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
FcObjectSet *XftObjectSetCreate (void);
Bool XftObjectSetAdd (FcObjectSet *os, const char *object);
void XftObjectSetDestroy (FcObjectSet *os);
FcObjectSet *XftObjectSetVaBuild (const char *first, va_list va);
FcObjectSet *XftObjectSetBuild (const char *first, ...);
FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
/* xftcore.c */
void
XftRectCore (XftDraw *draw,
XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
void
XftGlyphCore (XftDraw *draw,
XftColor *color,
XftFont *public,
int x,
int y,
FT_UInt *glyphs,
int nglyphs);
void
XftGlyphSpecCore (XftDraw *draw,
XftColor *color,
XftFont *public,
XftGlyphSpec *glyphs,
int nglyphs);
void
XftGlyphFontSpecCore (XftDraw *draw,
XftColor *color,
XftGlyphFontSpec *glyphs,
int nglyphs);
/* xftdbg.c */
int
XftDebug (void);
/* xftdpy.c */
XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy);
void
_XftDisplayManageMemory (Display *dpy);
int
XftDefaultParseBool (char *v);
FcBool
XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
int
XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
double
XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
FcFontSet *
XftDisplayGetFontSet (Display *dpy);
/* xftdraw.c */
unsigned int
XftDrawDepth (XftDraw *draw);
unsigned int
XftDrawBitsPerPixel (XftDraw *draw);
FcBool
XftDrawRenderPrepare (XftDraw *draw);
/* xftextent.c */
/* xftfont.c */
/* xftfreetype.c */
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 size, FT_Matrix *matrix);
/* xftglyph.c */
void
_XftFontUncacheGlyph (Display *dpy, XftFont *public);
void
_XftFontManageMemory (Display *dpy, XftFont *public);
/* xftinit.c */
int
XftNativeByteOrder (void);
void
XftMemReport (void);
void
XftMemAlloc (int kind, int size);
void
XftMemFree (int kind, int size);
/* xftlist.c */
FcFontSet *
XftListFontsPatternObjects (Display *dpy,
int screen,
FcPattern *pattern,
FcObjectSet *os);
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...);
/* xftname.c */
void
_XftNameInit (void);
/* xftrender.c */
/* xftstr.c */
int
_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
/* xftswap.c */
int
XftNativeByteOrder (void);
void
XftSwapCARD32 (CARD32 *data, int n);
void
XftSwapCARD24 (CARD8 *data, int width, int height);
void
XftSwapCARD16 (CARD16 *data, int n);
void
XftSwapImage (XImage *image);
/* xftxlfd.c */
#endif /* _XFT_INT_H_ */

View File

@@ -1,61 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftlist.c,v 1.3 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include "xftint.h"
FcFontSet *
XftListFontsPatternObjects (Display *dpy,
int screen,
FcPattern *pattern,
FcObjectSet *os)
{
return FcFontList (0, pattern, os);
}
FcFontSet *
XftListFonts (Display *dpy,
int screen,
...)
{
va_list va;
FcFontSet *fs;
FcObjectSet *os;
FcPattern *pattern;
const char *first;
va_start (va, screen);
FcPatternVapBuild (pattern, 0, va);
first = va_arg (va, const char *);
FcObjectSetVapBuild (os, first, va);
va_end (va);
fs = XftListFontsPatternObjects (dpy, screen, pattern, os);
FcPatternDestroy (pattern);
FcObjectSetDestroy (os);
return fs;
}

View File

@@ -1,50 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftname.c,v 1.11 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "xftint.h"
static const FcObjectType _XftObjectTypes[] = {
{ XFT_CORE, FcTypeBool, },
{ XFT_XLFD, FcTypeString, },
{ XFT_RENDER, FcTypeBool, },
};
#define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
Bool _XftNameInitialized;
void
_XftNameInit (void)
{
if (_XftNameInitialized)
return;
FcNameRegisterObjectTypes (_XftObjectTypes, NUM_OBJECT_TYPES);
}
FcPattern
*XftNameParse (const char *name)
{
_XftNameInit ();
return FcNameParse ((FcChar8 *) name);
}

View File

@@ -1,293 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftpat.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "xftint.h"
FcPattern *
XftPatternCreate (void)
{
FcPattern *p;
p = (FcPattern *) malloc (sizeof (FcPattern));
if (!p)
return 0;
p->num = 0;
p->size = 0;
p->elts = 0;
return p;
}
void
XftValueDestroy (FcValue v)
{ FcValueDestroy (v); }
void
XftValueListDestroy (XftValueList *l)
{ FcValueListDestroy (l); }
void
XftPatternDestroy (FcPattern *p)
{ FcPatternDestroy (p); }
XftPatternElt *
XftPatternFind (FcPattern *p, const char *object, Bool insert)
{ return FcPatternFind (p, object, insert); }
Bool
XftPatternAdd (FcPattern *p, const char *object, FcValue value, Bool append)
{ return FcPatternAdd (p, object, value, append); }
Bool
XftPatternDel (FcPattern *p, const char *object)
{
XftPatternElt *e;
int i;
e = XftPatternFind (p, object, False);
if (!e)
return False;
i = e - p->elts;
/* destroy value */
XftValueListDestroy (e->values);
/* shuffle existing ones down */
memmove (e, e+1, (p->elts + p->num - (e + 1)) * sizeof (XftPatternElt));
p->num--;
p->elts[p->num].object = 0;
p->elts[p->num].values = 0;
return True;
}
Bool
XftPatternAddInteger (FcPattern *p, const char *object, int i)
{
FcValue v;
v.type = FcTypeInteger;
v.u.i = i;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddDouble (FcPattern *p, const char *object, double d)
{
FcValue v;
v.type = FcTypeDouble;
v.u.d = d;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddString (FcPattern *p, const char *object, const char *s)
{
FcValue v;
v.type = FcTypeString;
v.u.s = (char *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddMatrix (FcPattern *p, const char *object, const XftMatrix *s)
{
FcValue v;
v.type = FcTypeMatrix;
v.u.m = (XftMatrix *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddBool (FcPattern *p, const char *object, Bool b)
{
FcValue v;
v.type = FcTypeBool;
v.u.b = b;
return XftPatternAdd (p, object, v, True);
}
XftResult
XftPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
{
XftPatternElt *e;
XftValueList *l;
e = XftPatternFind (p, object, False);
if (!e)
return XftResultNoMatch;
for (l = e->values; l; l = l->next)
{
if (!id)
{
*v = l->value;
return XftResultMatch;
}
id--;
}
return XftResultNoId;
}
XftResult
XftPatternGetInteger (FcPattern *p, const char *object, int id, int *i)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*i = (int) v.u.d;
break;
case FcTypeInteger:
*i = v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetDouble (FcPattern *p, const char *object, int id, double *d)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case FcTypeDouble:
*d = v.u.d;
break;
case FcTypeInteger:
*d = (double) v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetString (FcPattern *p, const char *object, int id, char **s)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeString)
return XftResultTypeMismatch;
*s = v.u.s;
return XftResultMatch;
}
XftResult
XftPatternGetMatrix (FcPattern *p, const char *object, int id, XftMatrix **m)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeMatrix)
return XftResultTypeMismatch;
*m = v.u.m;
return XftResultMatch;
}
XftResult
XftPatternGetBool (FcPattern *p, const char *object, int id, Bool *b)
{
FcValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != FcTypeBool)
return XftResultTypeMismatch;
*b = v.u.b;
return XftResultMatch;
}
FcPattern *
XftPatternDuplicate (FcPattern *orig)
{
FcPattern *new;
int i;
XftValueList *l;
new = XftPatternCreate ();
if (!new)
goto bail0;
for (i = 0; i < orig->num; i++)
{
for (l = orig->elts[i].values; l; l = l->next)
if (!XftPatternAdd (new, orig->elts[i].object, l->value, True))
goto bail1;
}
return new;
bail1:
XftPatternDestroy (new);
bail0:
return 0;
}
FcPattern *
XftPatternVaBuild (FcPattern *orig, va_list va)
{
FcPattern *ret;
_XftPatternVapBuild (ret, orig, va);
return ret;
}
FcPattern *
XftPatternBuild (FcPattern *orig, ...)
{
va_list va;
va_start (va, orig);
_XftPatternVapBuild (orig, orig, va);
va_end (va);
return orig;
}

View File

@@ -1,930 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftrender.c,v 1.10 2002/02/19 07:51:20 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include "xftint.h"
#define NUM_LOCAL 1024
#define NUM_ELT_LOCAL 128
/*
* Use the Render extension to draw the glyphs
*/
void
XftGlyphRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FT_UInt *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
int i;
FT_UInt missing[XFT_NMISSING];
int nmissing;
FT_UInt g, max;
int size, width;
Glyph wire;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
FcBool glyphs_loaded;
if (!font->format)
return;
/*
* Load missing glyphs
*/
nmissing = 0;
max = 0;
glyphs_loaded = FcFalse;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i];
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
}
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->glyphset)
goto bail1;
if (max < 0x100)
{
width = 1;
size = sizeof (char);
}
else if (max < 0x10000)
{
width = 2;
size = sizeof (unsigned short);
}
else
{
width = 4;
size = sizeof (unsigned int);
}
chars = char_local;
if (nglyphs * size > sizeof (char_local))
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
for (i = 0; i < nglyphs; i++)
{
wire = (Glyph) glyphs[i];
if (wire > font->num_glyphs || !font->glyphs[wire])
wire = 0;
switch (width) {
case 1: char8[i] = (char) wire; break;
case 2: char16[i] = (unsigned short) wire; break;
case 4: char32[i] = (unsigned long) wire; break;
}
}
switch (width) {
case 1:
default:
XRenderCompositeString8 (dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char8, nglyphs);
break;
case 2:
XRenderCompositeString16(dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char16, nglyphs);
break;
case 4:
XRenderCompositeString32(dpy, op,
src, dst, font->format, font->glyphset,
srcx, srcy, x, y, char32, nglyphs);
break;
}
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
void
XftGlyphSpecRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
XftGlyphSpec *glyphs,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) public;
int i, j;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt g;
XftGlyph *glyph;
FT_UInt max;
int size, width;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
XGlyphElt8 *elts;
XGlyphElt8 elts_local[NUM_ELT_LOCAL];
FcBool glyphs_loaded;
int nelt;
int x, y;
if (!font->format)
return;
if (!nglyphs)
return;
/*
* Load missing glyphs
*/
max = 0;
nmissing = 0;
glyphs_loaded = FcFalse;
g = glyphs[0].glyph;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
}
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->glyphset)
goto bail1;
/*
* See what encoding size is needed
*/
if (max < 0x100)
{
size = sizeof (char);
width = 1;
}
else if (max < 0x10000)
{
size = sizeof (unsigned short);
width = 2;
}
else
{
size = sizeof (unsigned int);
width = 4;
}
chars = char_local;
if (nglyphs * size > NUM_LOCAL)
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
/*
* Compute the number of glyph elts needed
*/
nelt = 1;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if (font->glyphs[g])
break;
}
if (i == nglyphs)
goto bail2;
glyph = font->glyphs[g];
x = glyphs[i].x + glyph->metrics.xOff;
y = glyphs[i].y + glyph->metrics.yOff;
while (++i < nglyphs)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
/*
* check to see if the glyph is placed where it would
* fall using the normal spacing
*/
if ((glyph = font->glyphs[g]))
{
if (x != glyphs[i].x || y != glyphs[i].y)
{
x = glyphs[i].x;
y = glyphs[i].y;
++nelt;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
}
}
elts = elts_local;
if (nelt > NUM_ELT_LOCAL)
{
elts = malloc (nelt * sizeof (XGlyphElt8));
if (!elts)
goto bail2;
}
/*
* Generate the list of glyph elts
*/
nelt = 0;
x = y = 0;
n = 0;
j = 0;
for (i = 0; i < nglyphs; i++)
{
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if ((glyph = font->glyphs[g]))
{
if (!i || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
elts[nelt].glyphset = font->glyphset;
elts[nelt].chars = char8 + size * j;
elts[nelt].xOff = glyphs[i].x - x;
elts[nelt].yOff = glyphs[i].y - y;
x = glyphs[i].x;
y = glyphs[i].y;
n = 0;
}
switch (width) {
case 1: char8[j] = (char) g; break;
case 2: char16[j] = (unsigned short) g; break;
case 4: char32[j] = (unsigned int) g; break;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
j++;
n++;
}
}
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
switch (width) {
case 1:
XRenderCompositeText8 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
elts, nelt);
break;
case 2:
XRenderCompositeText16 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt16 *) elts, nelt);
break;
case 4:
XRenderCompositeText32 (dpy, op, src, dst, font->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt32 *) elts, nelt);
break;
}
if (elts != elts_local)
free (elts);
bail2:
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
_XftFontManageMemory (dpy, public);
}
void
XftCharSpecRender (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
XftCharSpec *chars,
int len)
{
XftGlyphSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].glyph = XftCharIndex(dpy, public, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftGlyphSpecRender (dpy, op, src, public, dst, srcx, srcy, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftGlyphFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftGlyphFontSpec *glyphs,
int nglyphs)
{
int i, j;
XftFont *prevPublic;
XftFontInt *firstFont;
FT_UInt missing[XFT_NMISSING];
int nmissing;
int n;
FT_UInt g;
XftGlyph *glyph;
FT_UInt max;
int size, width;
char *char8;
unsigned short *char16;
unsigned int *char32;
unsigned int char_local[NUM_LOCAL];
unsigned int *chars;
XGlyphElt8 *elts;
XGlyphElt8 elts_local[NUM_ELT_LOCAL];
FcBool glyphs_loaded;
int nelt;
int x, y;
if (!nglyphs)
return;
/*
* Load missing glyphs
*/
max = 0;
nmissing = 0;
glyphs_loaded = FcFalse;
g = glyphs[0].glyph;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
if (g > max)
max = g;
if (XftFontCheckGlyph (dpy, public, FcTrue, g, missing, &nmissing))
glyphs_loaded = FcTrue;
if (nmissing)
XftFontLoadGlyphs (dpy, public, FcTrue, missing, nmissing);
if (!font->format)
goto bail1;
if (!font->glyphset)
goto bail1;
}
/*
* See what encoding size is needed
*/
if (max < 0x100)
{
size = sizeof (char);
width = 1;
}
else if (max < 0x10000)
{
size = sizeof (unsigned short);
width = 2;
}
else
{
size = sizeof (unsigned int);
width = 4;
}
chars = char_local;
if (nglyphs * size > NUM_LOCAL)
{
chars = malloc (nglyphs * size);
if (!chars)
goto bail1;
}
char8 = (char *) chars;
char16 = (unsigned short *) chars;
char32 = (unsigned int *) chars;
/*
* Compute the number of glyph elts needed
*/
nelt = 1;
firstFont = 0;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if (font->glyphs[g])
{
firstFont = font;
break;
}
}
if (i == nglyphs)
goto bail2;
glyph = firstFont->glyphs[g];
x = glyphs[i].x + glyph->metrics.xOff;
y = glyphs[i].y + glyph->metrics.yOff;
prevPublic = 0;
while (++i < nglyphs)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
/*
* check to see if the glyph is placed where it would
* fall using the normal spacing
*/
if ((glyph = font->glyphs[g]))
{
if (public != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
prevPublic = public;
x = glyphs[i].x;
y = glyphs[i].y;
++nelt;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
}
}
elts = elts_local;
if (nelt > NUM_ELT_LOCAL)
{
elts = malloc (nelt * sizeof (XGlyphElt8));
if (!elts)
goto bail2;
}
/*
* Generate the list of glyph elts
*/
nelt = 0;
x = y = 0;
n = 0;
j = 0;
prevPublic = 0;
for (i = 0; i < nglyphs; i++)
{
XftFont *public = glyphs[i].font;
XftFontInt *font = (XftFontInt *) public;
g = glyphs[i].glyph;
/* Substitute default for non-existant glyphs */
if (g > font->num_glyphs || !font->glyphs[g])
g = 0;
if ((glyph = font->glyphs[g]))
{
if (!i || public != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
elts[nelt].glyphset = font->glyphset;
elts[nelt].chars = char8 + size * j;
elts[nelt].xOff = glyphs[i].x - x;
elts[nelt].yOff = glyphs[i].y - y;
prevPublic = public;
x = glyphs[i].x;
y = glyphs[i].y;
n = 0;
}
switch (width) {
case 1: char8[j] = (char) g; break;
case 2: char16[j] = (unsigned short) g; break;
case 4: char32[j] = (unsigned int) g; break;
}
x += glyph->metrics.xOff;
y += glyph->metrics.yOff;
j++;
n++;
}
}
if (n)
{
elts[nelt].nchars = n;
nelt++;
}
switch (width) {
case 1:
XRenderCompositeText8 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
elts, nelt);
break;
case 2:
XRenderCompositeText16 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt16 *) elts, nelt);
break;
case 4:
XRenderCompositeText32 (dpy, op, src, dst, firstFont->format,
srcx, srcy, glyphs[0].x, glyphs[0].y,
(XGlyphElt32 *) elts, nelt);
break;
}
if (elts != elts_local)
free (elts);
bail2:
if (chars != char_local)
free (chars);
bail1:
if (glyphs_loaded)
for (i = 0; i < nglyphs; i++)
_XftFontManageMemory (dpy, glyphs[i].font);
}
void
XftCharFontSpecRender (Display *dpy,
int op,
Picture src,
Picture dst,
int srcx,
int srcy,
XftCharFontSpec *chars,
int len)
{
XftGlyphFontSpec *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (XftGlyphFontSpec));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
{
glyphs[i].font = chars[i].font;
glyphs[i].glyph = XftCharIndex(dpy, glyphs[i].font, chars[i].ucs4);
glyphs[i].x = chars[i].x;
glyphs[i].y = chars[i].y;
}
XftGlyphFontSpecRender (dpy, op, src, dst, srcx, srcy, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender8 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar16 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16BE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*2]<<8) | string[i*2+1]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender16LE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
string[i*2] | (string[i*2+1]<<8));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar32 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public, string[i]);
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32BE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*4] << 24) |
(string[i*4+1] << 16) |
(string[i*4+2] << 8) |
(string[i*4+3]));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRender32LE (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, glyphs_local[NUM_LOCAL];
int i;
if (len <= NUM_LOCAL)
glyphs = glyphs_local;
else
{
glyphs = malloc (len * sizeof (FT_UInt));
if (!glyphs)
return;
}
for (i = 0; i < len; i++)
glyphs[i] = XftCharIndex (dpy, public,
(string[i*4]) |
(string[i*4+1] << 8) |
(string[i*4+2] << 16) |
(string[i*4+3] << 24));
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}
void
XftTextRenderUtf8 (Display *dpy,
int op,
Picture src,
XftFont *public,
Picture dst,
int srcx,
int srcy,
int x,
int y,
FcChar8 *string,
int len)
{
FT_UInt *glyphs, *glyphs_new, glyphs_local[NUM_LOCAL];
FcChar32 ucs4;
int i;
int l;
int size;
i = 0;
glyphs = glyphs_local;
size = NUM_LOCAL;
while (len && (l = FcUtf8ToUcs4 (string, &ucs4, len)) > 0)
{
if (i == size)
{
glyphs_new = malloc (size * 2 * sizeof (FT_UInt));
if (!glyphs_new)
{
if (glyphs != glyphs_local)
free (glyphs);
return;
}
memcpy (glyphs_new, glyphs, size * sizeof (FT_UInt));
size *= 2;
if (glyphs != glyphs_local)
free (glyphs);
glyphs = glyphs_new;
}
glyphs[i++] = XftCharIndex (dpy, public, ucs4);
string += l;
len -= l;
}
XftGlyphRender (dpy, PictOpOver, src, public, dst,
srcx, srcy, x, y, glyphs, len);
if (glyphs != glyphs_local)
free (glyphs);
}

View File

@@ -1,40 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftstr.c,v 1.7 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "xftint.h"
int
_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
{
while (n--)
{
if (!FcStrCmpIgnoreCase ((FcChar8 *) s->name, (FcChar8 *) name))
return s->value;
s++;
}
return def;
}

View File

@@ -1,122 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftswap.c,v 1.1 2002/02/15 07:37:35 keithp Exp $
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <X11/Xlib.h>
#include "xftint.h"
int
XftNativeByteOrder (void)
{
int whichbyte = 1;
if (*((char *) &whichbyte))
return LSBFirst;
return MSBFirst;
}
/* byte swap a 32-bit value */
#define swapl(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[3];\
((char *) (x))[3] = n;\
n = ((char *) (x))[1];\
((char *) (x))[1] = ((char *) (x))[2];\
((char *) (x))[2] = n; }
/* byte swap a short */
#define swaps(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[1];\
((char *) (x))[1] = n; }
/* byte swap a three-byte unit */
#define swapt(x, n) { \
n = ((char *) (x))[0];\
((char *) (x))[0] = ((char *) (x))[2];\
((char *) (x))[2] = n; }
void
XftSwapCARD32 (CARD32 *data, int u)
{
char n;
while (u--)
{
swapl (data, n);
data++;
}
}
void
XftSwapCARD24 (CARD8 *data, int width, int height)
{
int units, u;
char n;
CARD8 *d;
units = width / 3;
while (height--)
{
d = data;
data += width;
u = units;
while (u--)
{
swapt (d, n);
d += 3;
}
}
}
void
XftSwapCARD16 (CARD16 *data, int u)
{
char n;
while (u--)
{
swaps (data, n);
data++;
}
}
void
XftSwapImage (XImage *image)
{
switch (image->bits_per_pixel) {
case 32:
XftSwapCARD32 ((CARD32 *) image->data,
image->height * image->bytes_per_line >> 2);
break;
case 24:
XftSwapCARD24 ((CARD8 *) image->data,
image->bytes_per_line,
image->height);
break;
case 16:
XftSwapCARD16 ((CARD16 *) image->data,
image->height * image->bytes_per_line >> 1);
break;
default:
break;
}
}

View File

@@ -1,187 +0,0 @@
/*
* $XFree86: xc/lib/Xft/xftxlfd.c,v 1.8 2002/02/15 07:36:11 keithp Exp $
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "xftint.h"
static XftSymbolic XftXlfdWeights[] = {
{ "light", FC_WEIGHT_LIGHT },
{ "medium", FC_WEIGHT_MEDIUM },
{ "regular", FC_WEIGHT_MEDIUM },
{ "demibold", FC_WEIGHT_DEMIBOLD },
{ "bold", FC_WEIGHT_BOLD },
{ "black", FC_WEIGHT_BLACK },
};
#define NUM_XLFD_WEIGHTS (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
static XftSymbolic XftXlfdSlants[] = {
{ "r", FC_SLANT_ROMAN },
{ "i", FC_SLANT_ITALIC },
{ "o", FC_SLANT_OBLIQUE },
};
#define NUM_XLFD_SLANTS (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
/*
* Cut out one XLFD field, placing it in 'save' and return
* the start of 'save'
*/
static char *
XftSplitStr (const char *field, char *save)
{
char *s = save;
char c;
while (*field)
{
if (*field == '-')
break;
c = *field++;
*save++ = c;
}
*save = 0;
return s;
}
/*
* convert one XLFD numeric field. Return -1 if the field is '*'
*/
static const char *
XftGetInt(const char *ptr, int *val)
{
if (*ptr == '*') {
*val = -1;
ptr++;
} else
for (*val = 0; *ptr >= '0' && *ptr <= '9';)
*val = *val * 10 + *ptr++ - '0';
if (*ptr == '-')
return ptr;
return (char *) 0;
}
FcPattern *
XftXlfdParse (const char *xlfd_orig, FcBool ignore_scalable, FcBool complete)
{
FcPattern *pat;
const char *xlfd = xlfd_orig;
const char *foundry;
const char *family;
const char *weight_name;
const char *slant;
const char *registry;
const char *encoding;
char *save;
int pixel;
int point;
int resx;
int resy;
int slant_value, weight_value;
double dpixel;
if (*xlfd != '-')
return 0;
if (!(xlfd = strchr (foundry = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (family = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (weight_name = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (slant = ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (/* setwidth_name = */ ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (/* add_style_name = */ ++xlfd, '-'))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &pixel))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &point))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &resx))) return 0;
if (!(xlfd = XftGetInt (++xlfd, &resy))) return 0;
if (!(xlfd = strchr (/* spacing = */ ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (/* average_width = */ ++xlfd, '-'))) return 0;
if (!(xlfd = strchr (registry = ++xlfd, '-'))) return 0;
/* make sure no fields follow this one */
if ((xlfd = strchr (encoding = ++xlfd, '-'))) return 0;
if (!pixel)
return 0;
pat = FcPatternCreate ();
if (!pat)
return 0;
save = (char *) malloc (strlen (foundry) + 1);
if (!save)
return 0;
if (!FcPatternAddString (pat, XFT_XLFD, (FcChar8 *) xlfd_orig)) goto bail;
XftSplitStr (foundry, save);
if (save[0] && strcmp (save, "*") != 0)
if (!FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) save)) goto bail;
XftSplitStr (family, save);
if (save[0] && strcmp (save, "*") != 0)
if (!FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) save)) goto bail;
weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
XftSplitStr (weight_name, save),
FC_WEIGHT_MEDIUM);
if (!FcPatternAddInteger (pat, FC_WEIGHT, weight_value))
goto bail;
slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
XftSplitStr (slant, save),
FC_SLANT_ROMAN);
if (!FcPatternAddInteger (pat, FC_SLANT, slant_value))
goto bail;
dpixel = (double) pixel;
if (point > 0)
{
if (!FcPatternAddDouble (pat, FC_SIZE, ((double) point) / 10.0)) goto bail;
if (pixel <= 0 && resy > 0)
{
dpixel = (double) point * (double) resy / 720.0;
}
}
if (dpixel > 0)
if (!FcPatternAddDouble (pat, FC_PIXEL_SIZE, dpixel)) goto bail;
strcpy ((char *) registry, save);
if (registry[0] && !strchr (registry, '*'))
{
;
/* XXX map registry to charset */
}
free (save);
return pat;
bail:
free (save);
FcPatternDestroy (pat);
return 0;
}

View File

@@ -1,65 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Composite.c,v 1.2 2000/08/28 02:43:13 tsi Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
void
XRenderComposite (Display *dpy,
int op,
Picture src,
Picture mask,
Picture dst,
int src_x,
int src_y,
int mask_x,
int mask_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderComposite, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderComposite;
req->op = (CARD8) op;
req->src = src;
req->mask = mask;
req->dst = dst;
req->xSrc = src_x;
req->ySrc = src_y;
req->xMask = mask_x;
req->yMask = mask_y;
req->xDst = dst_x;
req->yDst = dst_y;
req->width = width;
req->height = height;
UnlockDisplay(dpy);
SyncHandle();
}

View File

@@ -1,104 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/FillRect.c,v 1.2 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
/* precompute the maximum size of batching request allowed */
#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
void
XRenderFillRectangle (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRectangle *rect;
xRenderFillRectanglesReq *req;
#ifdef MUSTCOPY
xRectangle rectdata;
long len = SIZEOF(xRectangle);
rect = &rectdata;
#endif /* MUSTCOPY */
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
req = (xRenderFillRectanglesReq *) dpy->last_req;
/* if same as previous request, with same drawable, batch requests */
if (req->reqType == info->codes->major_opcode &&
req->renderReqType == X_RenderFillRectangles &&
req->op == op &&
req->dst == dst &&
req->color.red == color->red &&
req->color.green == color->green &&
req->color.blue == color->blue &&
req->color.alpha == color->alpha &&
dpy->bufptr + SIZEOF(xRectangle) <= dpy->bufmax &&
(char *)dpy->bufptr - (char *)req < size)
{
req->length += SIZEOF(xRectangle) >> 2;
#ifndef MUSTCOPY
rect = (xRectangle *) dpy->bufptr;
dpy->bufptr += SIZEOF(xRectangle);
#endif /* not MUSTCOPY */
}
else
{
GetReqExtra(RenderFillRectangles, SIZEOF(xRectangle), req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFillRectangles;
req->op = op;
req->dst = dst;
req->color.red = color->red;
req->color.green = color->green;
req->color.blue = color->blue;
req->color.alpha = color->alpha;
#ifdef MUSTCOPY
dpy->bufptr -= SIZEOF(xRectangle);
#else
rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq);
#endif /* MUSTCOPY */
}
rect->x = x;
rect->y = y;
rect->width = width;
rect->height = height;
#ifdef MUSTCOPY
Data (dpy, (char *) rect, len);
#endif /* MUSTCOPY */
UnlockDisplay(dpy);
SyncHandle();
}

View File

@@ -1,77 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/FillRects.c,v 1.2 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
/* precompute the maximum size of batching request allowed */
#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
void
XRenderFillRectangles (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
_Xconst XRectangle *rectangles,
int n_rects)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFillRectanglesReq *req;
long len;
int n;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
while (n_rects)
{
GetReq(RenderFillRectangles, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFillRectangles;
req->op = op;
req->dst = dst;
req->color.red = color->red;
req->color.green = color->green;
req->color.blue = color->blue;
req->color.alpha = color->alpha;
n = n_rects;
len = ((long)n) << 1;
if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length))
{
n = (dpy->max_request_size - req->length) >> 1;
len = ((long)n) << 1;
}
SetReqLen(req, len, len);
len <<= 2; /* watch out for macros... */
Data16 (dpy, (short *) rectangles, len);
n_rects -= n;
rectangles += n;
}
UnlockDisplay(dpy);
SyncHandle();
}

View File

@@ -1,678 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Glyph.c,v 1.8 2002/02/12 07:17:37 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderCreateGlyphSetReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderCreateGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCreateGlyphSet;
req->gsid = gsid = XAllocID(dpy);
req->format = format->id;
UnlockDisplay(dpy);
SyncHandle();
return gsid;
}
GlyphSet
XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderReferenceGlyphSetReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderReferenceGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderReferenceGlyphSet;
req->gsid = gsid = XAllocID(dpy);
req->existing = existing;
UnlockDisplay(dpy);
SyncHandle();
return gsid;
}
void
XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphSetReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreeGlyphSet, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreeGlyphSet;
req->glyphset = glyphset;
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderAddGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
_Xconst XGlyphInfo *glyphs,
int nglyphs,
_Xconst char *images,
int nbyte_images)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderAddGlyphsReq *req;
long len;
if (nbyte_images & 3)
nbyte_images += 4 - (nbyte_images & 3);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderAddGlyphs, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderAddGlyphs;
req->glyphset = glyphset;
req->nglyphs = nglyphs;
len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
SetReqLen(req, len, len);
Data32 (dpy, (long *) gids, nglyphs * 4);
Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
Data (dpy, images, nbyte_images);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderFreeGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
int nglyphs)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphsReq *req;
long len;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreeGlyphs, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreeGlyphs;
req->glyphset = glyphset;
len = nglyphs;
SetReqLen(req, len, len);
len <<= 2;
Data32 (dpy, (long *) gids, len);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst char *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs8, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs8;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 252 glyphs in each
* bucket
*/
#define MAX_8 252
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_8)
{
nbytes = MAX_8 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_8;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), string, MAX_8);
nchar = nchar - MAX_8;
string += MAX_8;
}
if (nchar)
{
nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), string, nchar);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned short *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs16, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs16;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
#define MAX_16 254
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 2;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_16)
{
nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_16;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
nchar = nchar - MAX_16;
string += MAX_16;
}
if (nchar)
{
nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeString32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned int *string,
int nchar)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
int nbytes;
if (!nchar)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs32, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs32;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
#define MAX_32 254
len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 4;
req->length += (len + 3)>>2; /* convert to number of 32-bit words */
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + len > dpy->bufmax)
_XFlush (dpy);
while(nchar > MAX_32)
{
nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = MAX_32;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
nchar = nchar - MAX_32;
string += MAX_32;
}
if (nchar)
{
nbytes = nchar * 4 + SIZEOF(xGlyphElt);
BufAlloc (xGlyphElt *, elt, nbytes);
elt->len = nchar;
elt->deltax = xDst;
elt->deltay = yDst;
memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt8 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst char *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs8, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs8;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 252 glyphs in each
* bucket
*/
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_8 ? MAX_8 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data (dpy, chars, elt->len);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt16 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs16Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst unsigned short *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs16, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs16;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
/*
* xGlyphElt must be aligned on a 32-bit boundary; this is
* easily done by filling no more than 254 glyphs in each
* bucket
*/
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_16 ? MAX_16 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data16 (dpy, chars, elt->len * 2);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderCompositeText32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt32 *elts,
int nelt)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs32Req *req;
long len;
long elen;
xGlyphElt *elt;
int i;
_Xconst unsigned int *chars;
int nchars;
if (!nelt)
return;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderCompositeGlyphs32, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCompositeGlyphs32;
req->op = op;
req->src = src;
req->dst = dst;
req->maskFormat = maskFormat ? maskFormat->id : None;
req->glyphset = elts[0].glyphset;
req->xSrc = xSrc;
req->ySrc = ySrc;
/*
* Compute the space necessary
*/
len = 0;
for (i = 0; i < nelt; i++)
{
if (elts[i].glyphset != req->glyphset)
len += (SIZEOF (xGlyphElt) + 4) >> 2;
nchars = elts[i].nchars;
elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4;
len += (elen + 3) >> 2;
}
req->length += len;
/*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first.
*/
if (dpy->bufptr + (len << 2) > dpy->bufmax)
_XFlush (dpy);
for (i = 0; i < nelt; i++)
{
/*
* Switch glyphsets
*/
if (elts[i].glyphset != req->glyphset)
{
BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt));
elt->len = 0xff;
elt->deltax = 0;
elt->deltay = 0;
Data32(dpy, &elts[i].glyphset, 4);
}
nchars = elts[i].nchars;
xDst = elts[i].xOff;
yDst = elts[i].yOff;
chars = elts[i].chars;
while (nchars)
{
BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt))
elt->len = nchars > MAX_32 ? MAX_32 : nchars;
elt->deltax = xDst;
elt->deltay = yDst;
xDst = 0;
yDst = 0;
Data32 (dpy, chars, elt->len * 4);
nchars -= elt->len;
chars += elt->len;
}
}
UnlockDisplay(dpy);
SyncHandle();
}

View File

@@ -1,27 +0,0 @@
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = Xrender/X11/extensions
LIBRARY_NAME = Xrender
EXPORTS = Xrender.h
CSRCS = \
Composite.c \
FillRect.c \
FillRects.c \
Glyph.c \
Picture.c \
Xrender.c
# make it a static lib only
FORCE_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk
CFLAGS = $(MOZ_XFT_CFLAGS) -I$(srcdir)/extensions

View File

@@ -1,213 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Picture.c,v 1.8 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
#include "region.h"
static void
_XRenderProcessPictureAttributes (Display *dpy,
xRenderChangePictureReq *req,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
unsigned long values[32];
register unsigned long *value = values;
unsigned int nvalues;
if (valuemask & CPRepeat)
*value++ = attributes->repeat;
if (valuemask & CPAlphaMap)
*value++ = attributes->alpha_map;
if (valuemask & CPAlphaXOrigin)
*value++ = attributes->alpha_x_origin;
if (valuemask & CPAlphaYOrigin)
*value++ = attributes->alpha_y_origin;
if (valuemask & CPClipXOrigin)
*value++ = attributes->clip_x_origin;
if (valuemask & CPClipYOrigin)
*value++ = attributes->clip_y_origin;
if (valuemask & CPClipMask)
*value++ = attributes->clip_mask;
if (valuemask & CPGraphicsExposure)
*value++ = attributes->graphics_exposures;
if (valuemask & CPSubwindowMode)
*value++ = attributes->subwindow_mode;
if (valuemask & CPPolyEdge)
*value++ = attributes->poly_edge;
if (valuemask & CPPolyMode)
*value++ = attributes->poly_mode;
if (valuemask & CPDither)
*value++ = attributes->dither;
if (valuemask & CPComponentAlpha)
*value++ = attributes->component_alpha;
req->length += (nvalues = value - values);
nvalues <<= 2; /* watch out for macros... */
Data32 (dpy, (long *) values, (long)nvalues);
}
Picture
XRenderCreatePicture (Display *dpy,
Drawable drawable,
_Xconst XRenderPictFormat *format,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
Picture pid;
xRenderCreatePictureReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay(dpy);
GetReq(RenderCreatePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderCreatePicture;
req->pid = pid = XAllocID(dpy);
req->drawable = drawable;
req->format = format->id;
if ((req->mask = valuemask))
_XRenderProcessPictureAttributes (dpy,
(xRenderChangePictureReq *) req,
valuemask,
attributes);
UnlockDisplay(dpy);
SyncHandle();
return pid;
}
void
XRenderChangePicture (Display *dpy,
Picture picture,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderChangePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderChangePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderChangePicture;
req->picture = picture;
req->mask = valuemask;
_XRenderProcessPictureAttributes (dpy,
req,
valuemask,
attributes);
UnlockDisplay(dpy);
SyncHandle();
}
static void
_XRenderSetPictureClipRectangles (Display *dpy,
XExtDisplayInfo *info,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n)
{
xRenderSetPictureClipRectanglesReq *req;
long len;
GetReq (RenderSetPictureClipRectangles, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderSetPictureClipRectangles;
req->picture = picture;
req->xOrigin = xOrigin;
req->yOrigin = yOrigin;
len = ((long) n) << 1;
SetReqLen (req, len, 1);
len <<= 2;
Data16 (dpy, (short *) rects, len);
}
void
XRenderSetPictureClipRectangles (Display *dpy,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
_XRenderSetPictureClipRectangles (dpy, info, picture,
xOrigin, yOrigin, rects, n);
UnlockDisplay (dpy);
SyncHandle ();
}
void
XRenderSetPictureClipRegion (Display *dpy,
Picture picture,
Region r)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int i;
XRectangle *xr, *pr;
BOX *pb;
unsigned long total;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
total = r->numRects * sizeof (XRectangle);
if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
pr->x = pb->x1;
pr->y = pb->y1;
pr->width = pb->x2 - pb->x1;
pr->height = pb->y2 - pb->y1;
}
}
if (xr || !r->numRects)
_XRenderSetPictureClipRectangles (dpy, info, picture, 0, 0,
xr, r->numRects);
if (xr)
_XFreeTemp(dpy, (char *)xr, total);
UnlockDisplay(dpy);
SyncHandle();
}
void
XRenderFreePicture (Display *dpy,
Picture picture)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq(RenderFreePicture, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderFreePicture;
req->picture = picture;
UnlockDisplay(dpy);
SyncHandle();
}

View File

@@ -1,29 +0,0 @@
LIBRARY Xrender
VERSION LIBRARY_VERSION
EXPORTS
XRenderComposite
XRenderFillRectangle
XRenderFillRectangles
XRenderAddGlyphs
XRenderCompositeString16
XRenderCompositeString32
XRenderCompositeString8
XRenderCreateGlyphSet
XRenderFreeGlyphSet
XRenderFreeGlyphs
XRenderReferenceGlyphSet
XRenderChangePicture
XRenderCreatePicture
XRenderFreePicture
; _XRenderProcessPictureAttributes
XRenderFindDisplay
XRenderFindFormat
XRenderFindVisualFormat
XRenderQueryExtension
XRenderQueryFormats
XRenderQueryVersion
; _XRenderFindFormat
; _XRenderFindVisual
XRenderSetPictureClipRegion
/* $XFree86: xc/lib/Xrender/Xrender-def.cpp,v 1.3 2001/02/13 19:19:12 dawes Exp $ */

View File

@@ -1,327 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrender.c,v 1.8 2001/12/16 18:27:55 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#include "Xrenderint.h"
XExtensionInfo XRenderExtensionInfo;
char XRenderExtensionName[] = RENDER_NAME;
static int XRenderCloseDisplay(Display *dpy, XExtCodes *codes);
static /* const */ XExtensionHooks render_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
XRenderCloseDisplay, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
XExtDisplayInfo *
XRenderFindDisplay (Display *dpy)
{
XExtDisplayInfo *dpyinfo;
dpyinfo = XextFindDisplay (&XRenderExtensionInfo, dpy);
if (!dpyinfo)
dpyinfo = XextAddDisplay (&XRenderExtensionInfo, dpy,
XRenderExtensionName,
&render_extension_hooks,
0, 0);
return dpyinfo;
}
static int
XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
if (info->data) XFree (info->data);
return XextRemoveDisplay (&XRenderExtensionInfo, dpy);
}
/****************************************************************************
* *
* Render public interfaces *
* *
****************************************************************************/
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
return True;
} else {
return False;
}
}
Status XRenderQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderQueryVersionReply rep;
xRenderQueryVersionReq *req;
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
GetReq (RenderQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderQueryVersion;
req->majorVersion = RENDER_MAJOR;
req->minorVersion = RENDER_MINOR;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
*major_versionp = rep.majorVersion;
*minor_versionp = rep.minorVersion;
UnlockDisplay (dpy);
SyncHandle ();
return 1;
}
static XRenderPictFormat *
_XRenderFindFormat (XRenderInfo *xri, PictFormat format)
{
int nf;
for (nf = 0; nf < xri->nformat; nf++)
if (xri->format[nf].id == format)
return &xri->format[nf];
return 0;
}
static Visual *
_XRenderFindVisual (Display *dpy, VisualID vid)
{
return _XVIDtoVisual (dpy, vid);
}
Status
XRenderQueryFormats (Display *dpy)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderQueryPictFormatsReply rep;
xRenderQueryPictFormatsReq *req;
XRenderInfo *xri;
XRenderPictFormat *format;
XRenderScreen *screen;
XRenderDepth *depth;
XRenderVisual *visual;
xPictFormInfo *xFormat;
xPictScreen *xScreen;
xPictDepth *xDepth;
xPictVisual *xVisual;
void *xData;
int nf, ns, nd, nv;
int rlength;
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
if (info->data)
{
UnlockDisplay (dpy);
return 1;
}
GetReq (RenderQueryPictFormats, req);
req->reqType = info->codes->major_opcode;
req->renderReqType = X_RenderQueryPictFormats;
if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
xri = (XRenderInfo *) Xmalloc (sizeof (XRenderInfo) +
rep.numFormats * sizeof (XRenderPictFormat) +
rep.numScreens * sizeof (XRenderScreen) +
rep.numDepths * sizeof (XRenderDepth) +
rep.numVisuals * sizeof (XRenderVisual));
xri->format = (XRenderPictFormat *) (xri + 1);
xri->nformat = rep.numFormats;
xri->screen = (XRenderScreen *) (xri->format + rep.numFormats);
xri->nscreen = rep.numScreens;
xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens);
xri->ndepth = rep.numDepths;
xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths);
xri->nvisual = rep.numVisuals;
rlength = (rep.numFormats * sizeof (xPictFormInfo) +
rep.numScreens * sizeof (xPictScreen) +
rep.numDepths * sizeof (xPictDepth) +
rep.numVisuals * sizeof (xPictVisual));
xData = (void *) Xmalloc (rlength);
if (!xri || !xData)
{
if (xri) Xfree (xri);
if (xData) Xfree (xData);
_XEatData (dpy, rlength);
UnlockDisplay (dpy);
SyncHandle ();
return 0;
}
_XRead (dpy, (char *) xData, rlength);
format = xri->format;
xFormat = (xPictFormInfo *) xData;
for (nf = 0; nf < rep.numFormats; nf++)
{
format->id = xFormat->id;
format->type = xFormat->type;
format->depth = xFormat->depth;
format->direct.red = xFormat->direct.red;
format->direct.redMask = xFormat->direct.redMask;
format->direct.green = xFormat->direct.green;
format->direct.greenMask = xFormat->direct.greenMask;
format->direct.blue = xFormat->direct.blue;
format->direct.blueMask = xFormat->direct.blueMask;
format->direct.alpha = xFormat->direct.alpha;
format->direct.alphaMask = xFormat->direct.alphaMask;
format->colormap = xFormat->colormap;
format++;
xFormat++;
}
xScreen = (xPictScreen *) xFormat;
screen = xri->screen;
depth = xri->depth;
visual = xri->visual;
for (ns = 0; ns < xri->nscreen; ns++)
{
screen->depths = depth;
screen->ndepths = xScreen->nDepth;
screen->fallback = _XRenderFindFormat (xri, xScreen->fallback);
xDepth = (xPictDepth *) (xScreen + 1);
for (nd = 0; nd < screen->ndepths; nd++)
{
depth->depth = xDepth->depth;
depth->nvisuals = xDepth->nPictVisuals;
depth->visuals = visual;
xVisual = (xPictVisual *) (xDepth + 1);
for (nv = 0; nv < depth->nvisuals; nv++)
{
visual->visual = _XRenderFindVisual (dpy, xVisual->visual);
visual->format = _XRenderFindFormat (xri, xVisual->format);
visual++;
xVisual++;
}
depth++;
xDepth = (xPictDepth *) xVisual;
}
xScreen = (xPictScreen *) xDepth;
}
info->data = (XPointer) xri;
UnlockDisplay (dpy);
SyncHandle ();
Xfree (xData);
return 1;
}
XRenderPictFormat *
XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nv;
XRenderInfo *xri;
XRenderVisual *xrv;
RenderCheckExtension (dpy, info, 0);
if (!XRenderQueryFormats (dpy))
return 0;
xri = (XRenderInfo *) info->data;
for (nv = 0, xrv = xri->visual; nv < xri->nvisual; nv++, xrv++)
if (xrv->visual == visual)
return xrv->format;
return 0;
}
XRenderPictFormat *
XRenderFindFormat (Display *dpy,
unsigned long mask,
_Xconst XRenderPictFormat *template,
int count)
{
XExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nf;
XRenderInfo *xri;
RenderCheckExtension (dpy, info, 0);
if (!XRenderQueryFormats (dpy))
return 0;
xri = (XRenderInfo *) info->data;
for (nf = 0; nf < xri->nformat; nf++)
{
if (mask & PictFormatID)
if (template->id != xri->format[nf].id)
continue;
if (mask & PictFormatType)
if (template->type != xri->format[nf].type)
continue;
if (mask & PictFormatDepth)
if (template->depth != xri->format[nf].depth)
continue;
if (mask & PictFormatRed)
if (template->direct.red != xri->format[nf].direct.red)
continue;
if (mask & PictFormatRedMask)
if (template->direct.redMask != xri->format[nf].direct.redMask)
continue;
if (mask & PictFormatGreen)
if (template->direct.green != xri->format[nf].direct.green)
continue;
if (mask & PictFormatGreenMask)
if (template->direct.greenMask != xri->format[nf].direct.greenMask)
continue;
if (mask & PictFormatBlue)
if (template->direct.blue != xri->format[nf].direct.blue)
continue;
if (mask & PictFormatBlueMask)
if (template->direct.blueMask != xri->format[nf].direct.blueMask)
continue;
if (mask & PictFormatAlpha)
if (template->direct.alpha != xri->format[nf].direct.alpha)
continue;
if (mask & PictFormatAlphaMask)
if (template->direct.alphaMask != xri->format[nf].direct.alphaMask)
continue;
if (mask & PictFormatColormap)
if (template->colormap != xri->format[nf].colormap)
continue;
if (count-- == 0)
return &xri->format[nf];
}
return 0;
}

View File

@@ -1,340 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrender.h,v 1.10 2001/12/27 01:16:00 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifndef _XRENDER_H_
#define _XRENDER_H_
#include <X11/extensions/render.h>
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
#include <X11/Xutil.h>
typedef struct {
short red;
short redMask;
short green;
short greenMask;
short blue;
short blueMask;
short alpha;
short alphaMask;
} XRenderDirectFormat;
typedef struct {
PictFormat id;
int type;
int depth;
XRenderDirectFormat direct;
Colormap colormap;
} XRenderPictFormat;
#define PictFormatID (1 << 0)
#define PictFormatType (1 << 1)
#define PictFormatDepth (1 << 2)
#define PictFormatRed (1 << 3)
#define PictFormatRedMask (1 << 4)
#define PictFormatGreen (1 << 5)
#define PictFormatGreenMask (1 << 6)
#define PictFormatBlue (1 << 7)
#define PictFormatBlueMask (1 << 8)
#define PictFormatAlpha (1 << 9)
#define PictFormatAlphaMask (1 << 10)
#define PictFormatColormap (1 << 11)
typedef struct {
Visual *visual;
XRenderPictFormat *format;
} XRenderVisual;
typedef struct {
int depth;
int nvisuals;
XRenderVisual *visuals;
} XRenderDepth;
typedef struct {
XRenderDepth *depths;
int ndepths;
XRenderPictFormat *fallback;
} XRenderScreen;
typedef struct _XRenderInfo {
XRenderPictFormat *format;
int nformat;
XRenderScreen *screen;
int nscreen;
XRenderDepth *depth;
int ndepth;
XRenderVisual *visual;
int nvisual;
} XRenderInfo;
typedef struct _XRenderPictureAttributes {
Bool repeat;
Picture alpha_map;
int alpha_x_origin;
int alpha_y_origin;
int clip_x_origin;
int clip_y_origin;
Pixmap clip_mask;
Bool graphics_exposures;
int subwindow_mode;
int poly_edge;
int poly_mode;
Atom dither;
Bool component_alpha;
} XRenderPictureAttributes;
typedef struct {
unsigned short red;
unsigned short green;
unsigned short blue;
unsigned short alpha;
} XRenderColor;
typedef struct _XGlyphInfo {
unsigned short width;
unsigned short height;
short x;
short y;
short xOff;
short yOff;
} XGlyphInfo;
typedef struct _XGlyphElt8 {
GlyphSet glyphset;
_Xconst char *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt8;
typedef struct _XGlyphElt16 {
GlyphSet glyphset;
_Xconst unsigned short *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt16;
typedef struct _XGlyphElt32 {
GlyphSet glyphset;
_Xconst unsigned int *chars;
int nchars;
int xOff;
int yOff;
} XGlyphElt32;
_XFUNCPROTOBEGIN
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
Status XRenderQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp);
Status XRenderQueryFormats (Display *dpy);
XRenderPictFormat *
XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual);
XRenderPictFormat *
XRenderFindFormat (Display *dpy,
unsigned long mask,
_Xconst XRenderPictFormat *templ,
int count);
Picture
XRenderCreatePicture (Display *dpy,
Drawable drawable,
_Xconst XRenderPictFormat *format,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes);
void
XRenderChangePicture (Display *dpy,
Picture picture,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes);
void
XRenderSetPictureClipRectangles (Display *dpy,
Picture picture,
int xOrigin,
int yOrigin,
_Xconst XRectangle *rects,
int n);
void
XRenderSetPictureClipRegion (Display *dpy,
Picture picture,
Region r);
void
XRenderFreePicture (Display *dpy,
Picture picture);
void
XRenderComposite (Display *dpy,
int op,
Picture src,
Picture mask,
Picture dst,
int src_x,
int src_y,
int mask_x,
int mask_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height);
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format);
GlyphSet
XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
void
XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
void
XRenderAddGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
_Xconst XGlyphInfo *glyphs,
int nglyphs,
_Xconst char *images,
int nbyte_images);
void
XRenderFreeGlyphs (Display *dpy,
GlyphSet glyphset,
_Xconst Glyph *gids,
int nglyphs);
void
XRenderCompositeString8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst char *string,
int nchar);
void
XRenderCompositeString16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned short *string,
int nchar);
void
XRenderCompositeString32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
GlyphSet glyphset,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst unsigned int *string,
int nchar);
void
XRenderCompositeText8 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt8 *elts,
int nelt);
void
XRenderCompositeText16 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt16 *elts,
int nelt);
void
XRenderCompositeText32 (Display *dpy,
int op,
Picture src,
Picture dst,
_Xconst XRenderPictFormat *maskFormat,
int xSrc,
int ySrc,
int xDst,
int yDst,
_Xconst XGlyphElt32 *elts,
int nelt);
void
XRenderFillRectangle (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
void
XRenderFillRectangles (Display *dpy,
int op,
Picture dst,
_Xconst XRenderColor *color,
_Xconst XRectangle *rectangles,
int n_rects);
_XFUNCPROTOEND
#endif /* _XRENDER_H_ */

View File

@@ -1,50 +0,0 @@
/*
* $XFree86: xc/lib/Xrender/Xrenderint.h,v 1.2 2000/08/28 02:43:13 tsi Exp $
*
* Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifndef _XRENDERINT_H_
#define _XRENDERINT_H_
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include "Xext.h" /* in ../include */
#include "extutil.h" /* in ../include */
#include "Xrender.h"
#include "renderproto.h"
extern XExtensionInfo XRenderExtensionInfo;
extern char XRenderExtensionName[];
#define RenderCheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, XRenderExtensionName, val)
#define RenderSimpleCheckExtension(dpy,i) \
XextSimpleCheckExtension (dpy, i, XRenderExtensionName)
XExtDisplayInfo *
XRenderFindDisplay (Display *dpy);
#endif /* _XRENDERINT_H_ */

View File

@@ -1,224 +0,0 @@
/*
* $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $
*
Copyright 1989, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Jim Fulton, MIT The Open Group
*
* Xlib Extension-Writing Utilities
*
* This package contains utilities for writing the client API for various
* protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
* ARE SUBJECT TO CHANGE!
*/
/* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */
#ifndef _EXTUTIL_H_
#define _EXTUTIL_H_
#include <X11/extensions/Xext.h>
/*
* We need to keep a list of open displays since the Xlib display list isn't
* public. We also have to per-display info in a separate block since it isn't
* stored directly in the Display structure.
*/
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next; /* keep a linked list */
Display *display; /* which display this is */
XExtCodes *codes; /* the extension protocol codes */
XPointer data; /* extra data for extension to use */
} XExtDisplayInfo;
typedef struct _XExtensionInfo {
XExtDisplayInfo *head; /* start of list */
XExtDisplayInfo *cur; /* most recently used */
int ndisplays; /* number of displays */
} XExtensionInfo;
typedef struct _XExtensionHooks {
int (*create_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*copy_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*flush_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*free_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*create_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*free_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*close_display)(
#if NeedNestedPrototypes
Display* /* display */,
XExtCodes* /* codes */
#endif
);
Bool (*wire_to_event)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
Status (*event_to_wire)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
int (*error)(
#if NeedNestedPrototypes
Display* /* display */,
xError* /* err */,
XExtCodes* /* codes */,
int* /* ret_code */
#endif
);
char *(*error_string)(
#if NeedNestedPrototypes
Display* /* display */,
int /* code */,
XExtCodes* /* codes */,
char* /* buffer */,
int /* nbytes */
#endif
);
} XExtensionHooks;
extern XExtensionInfo *XextCreateExtension(
#if NeedFunctionPrototypes
void
#endif
);
extern void XextDestroyExtension(
#if NeedFunctionPrototypes
XExtensionInfo* /* info */
#endif
);
extern XExtDisplayInfo *XextAddDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */,
char* /* ext_name */,
XExtensionHooks* /* hooks */,
int /* nevents */,
XPointer /* data */
#endif
);
extern int XextRemoveDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
extern XExtDisplayInfo *XextFindDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
#define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
/*
* helper macros to generate code that is common to all extensions; caller
* should prefix it with static if extension source is in one file; this
* could be a utility function, but have to stack 6 unused arguments for
* something that is called many, many times would be bad.
*/
#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
#define XEXT_FIND_DISPLAY_PROTO(proc) \
XExtDisplayInfo *proc(Display *dpy)
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
int proc(Display *dpy, XExtCodes *codes)
#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
{ \
code -= codes->first_error; \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \
} \
return (char *)0; \
}
#define XEXT_ERROR_STRING_PROTO(proc) \
char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
#endif

View File

@@ -1,190 +0,0 @@
/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
/************************************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#define TRUE 1
#define FALSE 0
#define MAXSHORT 32767
#define MINSHORT -MAXSHORT
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@@ -1 +0,0 @@
Keith Packard <keithp@keithp.com>

View File

@@ -1,22 +0,0 @@
$XFree86: xc/lib/fontconfig/COPYING,v 1.1.1.1 2002/02/14 23:34:11 keithp Exp $
Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of Keith Packard not be used in
advertising or publicity pertaining to distribution of the software without
specific, written prior permission. Keith Packard makes no
representations about the suitability of this software for any purpose. It
is provided "as is" without express or implied warranty.
KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View File

@@ -1,3 +0,0 @@
The configuration files (fonts.conf, fonts.dtd) go in a new directory
/etc/fonts, the install step doesn't current create this directory or copy
the config files.

Some files were not shown because too many files have changed in this diff Show More