Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android

This commit is contained in:
Gerhard Stein
2017-07-01 13:09:38 +02:00
313 changed files with 1449 additions and 105170 deletions

View File

@@ -27,6 +27,18 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <!-- Android TV requires this -->
<category android:name="tv.ouya.intent.category.GAME" /> <!-- For that one user who still got an OUYA in his living room and won't throw it away just because someone else decides that it's dead -->
</intent-filter>
<intent-filter>
<!-- ==OPENFILE== --> <action android:name="android.intent.action.VIEW" />
<!-- ==OPENFILE== --> <category android:name="android.intent.category.DEFAULT" />
<!-- ==OPENFILE== --> <category android:name="android.intent.category.BROWSABLE" />
<!-- ==OPENFILE== --> <data android:scheme="file" />
<!-- ==OPENFILE== --> <data android:mimeType="*/*" />
<!-- ==OPENFILE== --> <data android:host="*" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\..*\\.==OPENFILE-EXT==" />
</intent-filter>
</activity>
<!-- ==ADMOB== --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"/>
<!-- ==ADMOB== --> <meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- Change this value to the actual Google Play SDK version -->

View File

@@ -85,6 +85,7 @@ class Globals
public static boolean HorizontalOrientation = true;
public static boolean AutoDetectOrientation = false;
public static boolean ImmersiveMode = true;
public static boolean HideSystemMousePointer = false;
public static boolean DownloadToSdcard = true;
public static boolean PhoneHasArrowKeys = false;
public static boolean UseAccelerometerAsArrowKeys = false;

View File

@@ -446,7 +446,10 @@ public class MainActivity extends Activity
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
if (Globals.HideSystemMousePointer && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
{
mGLView.setPointerIcon(android.view.PointerIcon.getSystemIcon(this, android.view.PointerIcon.TYPE_NULL));
}
if( _ad.getView() != null )
{

View File

@@ -710,9 +710,16 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
// Tweak video thread priority, if user selected big audio buffer
if( Globals.AudioBufferConfig >= 2 )
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
String commandline = Globals.CommandLine;
if( context.getIntent() != null && context.getIntent().getScheme() != null &&
context.getIntent().getScheme().compareTo(android.content.ContentResolver.SCHEME_FILE) == 0 &&
context.getIntent().getData() != null && context.getIntent().getData().getPath() != null )
{
commandline += " " + context.getIntent().getData().getPath();
}
nativeInit( Globals.DataDir,
Globals.CommandLine,
commandline,
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
0 );
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process

View File

@@ -1,13 +1,13 @@
# Makefile to build precompiled libraries, which cannot be built using standard NDK makefiles
# TODO: libboost, libffmpeg, libpython (used only in GemRB)
ARCHES32 := armeabi armeabi-v7a x86 mips
ARCHES32 := armeabi armeabi-v7a x86
ARCHES64 := arm64-v8a x86_64
ICONV := $(foreach ARCH, $(ARCHES32), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
ICONV := $(foreach ARCH, $(ARCHES32) $(ARCHES64), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
ICU_LIBS := data i18n io le lx test tu uc
ICU := $(foreach ARCH, $(ARCHES32), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/libicu$(NAME).a))
ICU_LIBS := icudata icui18n icuio icutest icutu icuuc iculx icu-le-hb harfbuzz
ICU := $(foreach ARCH, $(ARCHES32) $(ARCHES64), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/lib$(NAME).a))
OPENSSL := $(foreach ARCH, $(ARCHES32) $(ARCHES64), openssl/lib-$(ARCH)/libcrypto.so.sdl.1.so openssl/lib-$(ARCH)/libssl.so.sdl.1.so)
@@ -20,14 +20,15 @@ prebuilt-libraries: $(LIBS)
$(ICONV) $(ICU):
cd iconv/src && \
./build.sh && \
for ARCH in $(ARCHES32); do \
mkdir -p ../lib/$$ARCH ; \
for ARCH in $(ARCHES32) $(ARCHES64); do \
mkdir -p ../lib/$$ARCH ../include ; \
cp -f $$ARCH/libiconv.so $$ARCH/libcharset.so ../lib/$$ARCH/ ; \
cp -f $$ARCH/include/*.h ../include/ ; \
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/layout ../../icuuc/include/unicode ; \
cp -f $$ARCH/libicu*.a ../../icuuc/lib/$$ARCH/ ; \
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/unicode ../../icuuc/include/layout ; \
cp -f $$ARCH/libicu*.a $$ARCH/libharfbuzz.a ../../icuuc/lib/$$ARCH/ ; \
cp -f $$ARCH/include/unicode/*.h ../../icuuc/include/unicode/ ; \
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
cp -f $$ARCH/include/icu-le-hb/layout/*.h ../../icuuc/include/layout/ ; \
done
$(OPENSSL):

View File

@@ -1,6 +1,6 @@
# To filter out static libs from all libs in makefile
APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng android_support gl4es nanogl
APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc icu-le-hb harfbuzz sdl_savepng android_support gl4es nanogl
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg

View File

@@ -46,12 +46,16 @@ NeedDepthBuffer=n
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
NeedStencilBuffer=n
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
# Use GLES 2.x context
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles2=n
# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
UseGlshim=
# Use GLES 3.x context
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles3=n
# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
UseGl4es=
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
@@ -182,6 +186,9 @@ AccessInternet=
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
ImmersiveMode=y
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
HideSystemMousePointer=
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
@@ -240,6 +247,12 @@ AppMinimumRAM=0
# GCC version, or 'clang' for CLANG
NDK_TOOLCHAIN_VERSION=clang
# Android platform version.
# android-9 = Android 2.3, the earliest supported version.
# android-18 = Android 4.3, the first version supporting GLES3.
# android-21 = Android 5.1, the first version with SO_REUSEPORT defined.
APP_PLATFORM=
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a
MultiABI='armeabi-v7a x86 arm64-v8a'
@@ -271,7 +284,7 @@ AppSubdirsBuild=''
AppBuildExclude=''
# Application command line parameters, including app name as 0-th param
AppCmdline=''
AppCmdline='ballfield'
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
@@ -289,3 +302,6 @@ AdmobBannerSize=
# Google Play Game Services application ID, required for cloud saves to work
GooglePlayGameServicesId=
# The app will open files with following extension, file path will be added to commandline params
AppOpenFileExtension='png PNG jpg JPG jpeg JPEG gif GIF'

View File

@@ -488,7 +488,7 @@ int main(int argc, char* argv[])
/*
* Load background image
*/
temp_image = IMG_Load("sun.gif");
temp_image = IMG_Load(argc > 1 ? argv[1] : "sun.gif");
if(!temp_image)
{
fprintf(stderr, "Could not load background!\n");

View File

@@ -1 +0,0 @@
/*.so

View File

@@ -1 +0,0 @@
bochs/android/bochs/AndroidAppSettings.cfg

View File

@@ -1 +0,0 @@
bochs/android/bochs/AndroidBuild.sh

View File

@@ -1 +0,0 @@
bochs/android/bochs/AndroidData

View File

@@ -1 +0,0 @@
bochs/android/bochs/icon.png

View File

@@ -7,10 +7,10 @@ AppName="Ninslash"
AppFullName=ninslash.com
# Application version code (integer)
AppVersionCode=02321
AppVersionCode=02829
# Application user-visible version name (string)
AppVersionName="0.2.3.21"
AppVersionName="0.2.8.29"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
@@ -54,8 +54,8 @@ NeedGles2=y
# you need this option only if you're developing 3-d app (y) or (n)
NeedGles3=n
# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
UseGlshim=
# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
UseGl4es=
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
@@ -186,6 +186,9 @@ AccessInternet=y
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
ImmersiveMode=y
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
HideSystemMousePointer=y
# Application implements Android-specific routines to put to background, and will not draw anything to screen
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
@@ -263,13 +266,13 @@ CompiledLibraries="sdl_image freetype glu"
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags='-O2 -Werror=format -isystem jni/application/src/src/src/base/android' # -flto
AppCflags='-O2 -Werror=format -isystem jni/application/src/src/src/base/android'
# Aditional C++-specific compiler flags for application, added after AppCflags
AppCppflags='-std=c++11'
# Additional LDFLAGS for application
AppLdflags='-lEGL' # -flto
AppLdflags='-lEGL'
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=n

View File

@@ -7,10 +7,10 @@ AppName="OpenTTD"
AppFullName=org.openttd.sdl
# Application version code (integer)
AppVersionCode=17069
AppVersionCode=17170
# Application user-visible version name (string)
AppVersionName="1.7.0.69"
AppVersionName="1.7.1.70"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
@@ -18,7 +18,7 @@ AppVersionName="1.7.0.69"
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version, first associated with the file
AppDataDownloadUrl="!!Data files - 20 Mb|openttd-data-1.7.0-0.zip.xz^!!Config file|:.openttd/openttd.cfg:openttd-1.4.0.30.cfg^!!MIDI music support (18 Mb)|timidity.zip.xz|http://sourceforge.net/projects/libsdl-android/files/timidity.zip.xz^!!Internationalization files|icudt52l.zip.xz|http://sourceforge.net/projects/libsdl-android/files/icudt52l.zip.xz^HD graphics (optional) - 220 Mb download|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/abase-0.1.2-0.zip.xz/download|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/zBase-v5588.zip.xz/download"
AppDataDownloadUrl="!!Data files - 20 Mb|openttd-data-1.7.1-0.zip.xz^!!Config file|:.openttd/openttd.cfg:openttd-1.4.0.30.cfg^!!MIDI music support (18 Mb)|timidity.zip.xz|http://sourceforge.net/projects/libsdl-android/files/timidity.zip.xz^!!Internationalization files|icudt59l.zip.xz|http://sourceforge.net/projects/libsdl-android/files/icudt59l.zip.xz^HD graphics (optional) - 220 Mb download|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/abase-0.1.2-0.zip.xz/download|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/zBase-v5588.zip.xz/download"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
@@ -64,7 +64,7 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=n
InhibitSuspend=y
# Create Android service, so the app is less likely to be killed while in background
CreateService=
@@ -119,7 +119,7 @@ AppNeedsTwoButtonMouse=y
# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)
# If you disable it, swiping with two fingers will send mouse wheel events
RightMouseButtonLongPress=
RightMouseButtonLongPress=y
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
@@ -140,6 +140,8 @@ AppNeedsArrowKeys=n
# Joystick always follows finger, so moving mouse requires touching the screen with other finger
FloatingScreenJoystick=
HideSystemMousePointer=y
# Application needs text input (y) or (n), enables button for text input on screen
AppNeedsTextInput=n
@@ -166,7 +168,7 @@ AppUsesOrientationSensor=
MoveMouseWithGyroscope=
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
AppUsesMultitouch=n
AppUsesMultitouch=y
# Application records audio (it will use any available source, such a s microphone)
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
@@ -232,7 +234,7 @@ HiddenMenuOptions='SettingsMenuMouse.DisplaySizeConfig'
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
FirstStartMenuOptions='SettingsMenuMisc.OptionalDownloadConfig'
FirstStartMenuOptions='SettingsMenu.DummyMenu'
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0
@@ -242,12 +244,12 @@ NDK_TOOLCHAIN_VERSION=clang
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a x86_64
MultiABI='armeabi-v7a x86'
MultiABI='armeabi-v7a x86 arm64-v8a'
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="jpeg png freetype timidity expat fontconfig lzma lzo2 icui18n iculx icule icudata icuuc"
CompiledLibraries="jpeg png freetype timidity expat fontconfig lzma lzo2 icui18n iculx icu-le-hb harfbuzz icudata icuuc"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=y

View File

@@ -25,4 +25,4 @@ uname -s | grep -i "linux" > /dev/null && NCPU=`cat /proc/cpuinfo | grep -c -i p
LIBATOMIC=
echo $1 | grep 'arm' && LIBATOMIC=-latomic
env CLANG=1 LIBATOMIC=$LIBATOMIC ../setEnvironment-$1.sh sh -c "cd openttd-$VER-$1 && make -j$NCPU VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfontconfig -lfreetype -lexpat -licui18n -liculx -licule -licuuc -licudata -lgcc -lz -lc -lgnustl_static -lsupc++ $LIBATOMIC'" && cp -f openttd-$VER-$1/objs/release/openttd libapplication-$1.so || exit 1
env CLANG=1 LIBATOMIC=$LIBATOMIC ../setEnvironment-$1.sh sh -c "cd openttd-$VER-$1 && make -j$NCPU VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfontconfig -lfreetype -lexpat -licui18n -liculx -licu-le-hb -lharfbuzz -licuuc -licudata -lgcc -lz -lc -lgnustl_static -lsupc++ $LIBATOMIC'" && cp -f openttd-$VER-$1/objs/release/openttd libapplication-$1.so || exit 1

View File

@@ -18,7 +18,7 @@ cd bin
export LD_LIBRARY_PATH=/usr/local/lib
if [ -z "$1" ]; then
./openttd -d 2 -r 854x480 # -g opntitle.sav
./openttd -d 2 -r 854x480 -g opntitle.sav
else
#gdb -ex run --args \
valgrind --track-fds=yes --log-file=valgrind.log --leak-check=full \

View File

@@ -1,6 +1,6 @@
#!/bin/sh
VER=1.7.0-0
VER=1.7.1-0
cd data
rm -f ../AndroidData/openttd-data-*.zip.xz ../AndroidData/openttd-data-*.zip

View File

@@ -1,47 +0,0 @@
# The application settings for Android libSDL port
AppSettingVersion=17
LibSdlVersion=1.2
AppName="ScummVM"
AppFullName=org.scummvm.sdl
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="MIDI music support (30 Mb) - add soundfont in Options->MIDI|http://sourceforge.net/projects/libsdl-android/files/GeneralUser-GS-FluidSynth-v1.43.sf2.zip/download^Beneath a Steel Sky (CD version, 70 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Beneath%20a%20Steel%20Sky/bass-cd-1.2.zip/download^Beneath a Steel Sky (floppy version, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Beneath%20a%20Steel%20Sky/BASS-Floppy-1.3.zip/download^Flight of the Amazon Queen (23 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Floppy.zip/download^Flight of the Amazon Queen - voice addon (English, 35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Talkie-1.1.zip/download^Flight of the Amazon Queen - voice addon (German, 80 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Ger_talkie-1.0.zip/download^Flight of the Amazon Queen - voice addon (Hebrew, 70 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Heb_talkie.zip/download^Drascula: The Vampire Strikes Back (35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-1.0.zip/download^Drascula: The Vampire Strikes Back - translations addon (35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-int-1.1.zip/download^Drascula: The Vampire Strikes Back - audio addon (40 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-audio-2.0.zip/download^Soltys (English, 4Mb)|http://downloads.sourceforge.net/project/scummvm/extras/Soltys/soltys-en-v1.0.zip^Soltys (Polish, 4Mb)|http://downloads.sourceforge.net/project/scummvm/extras/Soltys/soltys-pl-v1.0.zip^Lure of the Temptress (English, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-1.1.zip/download^Lure of the Temptress (German, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-de-1.1.zip/download^Lure of the Temptress (French, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-fr-1.1.zip/download^Lure of the Temptress (Italian, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-it-1.1.zip/download^Lure of the Temptress (Spanish, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-es-1.1.zip/download^!ScummVM data|data1.zip^!ScummVM data|data2.zip"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
NeedGles2=n
SwVideoMode=y
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=n
CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
AppUsesMouse=y
AppNeedsTwoButtonMouse=y
ShowMouseCursor=n
ForceRelativeMouseMode=n
AppNeedsArrowKeys=n
AppNeedsTextInput=n
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="LALT RETURN ESCAPE F7 ESCAPE F5 F5 RETURN DELETE F7 F7"
AppTouchscreenKeyboardKeysAmount=0
AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="LALT RETURN ESCAPE F7"
StartupMenuButtonTimeout=3000
HiddenMenuOptions=''
FirstStartMenuOptions=''
MultiABI=n
AppVersionCode=14102
AppVersionName="1.4.1.02"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="mad tremor flac ogg jpeg png fluidsynth"
CustomBuildScript=y
AppCflags=''
AppLdflags='-ldl'
AppSubdirsBuild=''
AppCmdline=''
ReadmeText='^You may press "Home" now - the data will be downloaded in background'

View File

@@ -1,30 +0,0 @@
#!/bin/sh
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
# Hacks for broken configure scripts
#rm -rf $LOCAL_PATH/../../obj/local/armeabi/libSDL_*.so
#rm -rf $LOCAL_PATH/../../obj/local/armeabi/libsdl_main.so
# Uncomment if your configure expects SDL libraries in form "libSDL_name.so"
#if [ -e $LOCAL_PATH/../../obj/local/armeabi/libsdl_mixer.so ] ; then
# ln -sf libsdl_mixer.so $LOCAL_PATH/../../obj/local/armeabi/libSDL_Mixer.so
#fi
#for F in $LOCAL_PATH/../../obj/local/armeabi/libsdl_*.so; do
# LIBNAME=`echo $F | sed "s@$LOCAL_PATH/../../obj/local/armeabi/libsdl_\(.*\)[.]so@\1@"`
# ln -sf libsdl_$LIBNAME.so $LOCAL_PATH/../../obj/local/armeabi/libSDL_$LIBNAME.so
#done
ln -sf libtremor.a $LOCAL_PATH/../../../obj/local/armeabi/libvorbisidec.a
ln -sf libflac.a $LOCAL_PATH/../../../obj/local/armeabi/libFLAC.a
if [ \! -f scummvm/config.mk ] ; then
../setEnvironment.sh sh -c "cd scummvm && env LIBS='-lflac -ltremor -logg -lmad -lz -lgcc -lfluidsynth -lgnustl_static' ./configure --host=androidsdl --enable-zlib --enable-tremor --enable-mad --enable-flac --enable-vkeybd --enable-verbose-build --disable-hq-scalers --disable-readline --disable-nasm --disable-mt32emu --disable-taskbar --datadir=. --with-fluidsynth-prefix=$LOCAL_PATH/../../fluidsynth"
fi
rm -f scummvm/scummvm libapplication.so
../setEnvironment.sh nice make -C scummvm -j4
if [ -e scummvm/scummvm ]; then
cp -f scummvm/scummvm libapplication.so
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,8 +0,0 @@
To summarize: you have to download my GIT repo from https://github.com/pelya/commandergenius,
then install Android SDK 2.2, NDK r4b, and "ant" tool, then you should launch commands
rm project/jni/application/src
ln -s scummvm project/jni/application/src
cd project && android update project -p .
then download ScummVM 1.2 SVN into the dir project/jni/application/scummvm/scummvm
(or create a symlink to it if you already have downloaded it), then apply patch project/jni/application/scummvm/scummvm-1.2.0.diff
onto ScummVM, and launch build.sh. That should be it.

View File

@@ -1,82 +0,0 @@
Index: configure
===================================================================
--- configure (revision 54149)
+++ configure (working copy)
@@ -931,6 +931,11 @@
_host_cpu=arm
_host_alias=arm-oe-linux-androideabi
;;
+androidsdl)
+ _host_os=androidsdl
+ _host_cpu=arm
+ _host_alias=arm-eabi
+ ;;
arm-riscos)
_host_os=riscos
_host_cpu=arm
@@ -1205,9 +1210,9 @@
if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" 2> /dev/null && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" && cc_check_clean tmp_cxx_compiler.cpp
else
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
fi
}
@@ -1433,6 +1438,11 @@
_unix=yes
_seq_midi=no
;;
+ androidsdl)
+ CXXFLAGS="$CXXFLAGS -Os"
+ _unix=yes
+ _seq_midi=no
+ ;;
beos*)
DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
# Needs -lbind -lsocket for the timidity MIDI driver
@@ -1571,6 +1581,12 @@
_port_mk="backends/platform/android/android.mk"
_seq_midi=no
;;
+ androidsdl)
+ DEFINES="$DEFINES -DANDROID"
+ _unix=yes
+ _need_memalign=yes
+ _seq_midi=no
+ ;;
arm-linux|arm*-linux-gnueabi|arm-*-linux)
_unix=yes
_need_memalign=yes
@@ -2112,7 +2128,7 @@
LIBS += -ldl
'
;;
- linux*|android)
+ linux*|android|androidsdl)
_def_plugin='
#define PLUGIN_PREFIX "lib"
#define PLUGIN_SUFFIX ".so"
@@ -2778,7 +2794,7 @@
case $_host_os in
# newlib-based system include files suppress non-C89 function
# declarations under __STRICT_ANSI__
- amigaos* | android | ds | dreamcast | gamecube | mingw* | n64 | psp | wii | wince )
+ amigaos* | android | androidsdl | ds | dreamcast | gamecube | mingw* | n64 | psp | wii | wince )
CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter"
;;
*)
@@ -2799,7 +2815,7 @@
# Some platforms use certain GNU extensions in header files
case $_host_os in
-android | gamecube | psp | wii)
+android | androidsdl | gamecube | psp | wii )
;;
*)
CXXFLAGS="$CXXFLAGS -pedantic"
Index: backends/platform/sdl/events.cpp
===================================================================

View File

@@ -1,96 +0,0 @@
diff -u -r scummvm-1.3.1-old/configure scummvm-1.3.1/configure
--- scummvm-1.3.1-old/configure 2011-07-03 23:44:51.000000000 +0300
+++ scummvm-1.3.1/configure 2011-10-17 16:32:52.498962514 +0300
@@ -653,7 +653,7 @@
-h, --help display this help and exit
--backend=BACKEND backend to build (android, dc, dingux, ds, gp2x, gph,
iphone, linuxmoto, maemo, n64, null, openpandora, ps2,
- psp, samsungtv, sdl, symbian, webos, wii, wince) [sdl]
+ psp, samsungtv, sdl, symbian, webos, wii, wince, androidsdl) [sdl]
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
@@ -680,6 +680,7 @@
Special configuration feature:
--host=HOST cross-compile to target HOST (arm-linux, ...)
special targets: android for Android
+ androidsdl for Android with SDL backend
caanoo for Caanoo
dingux for Dingux
dreamcast for Sega Dreamcast
@@ -984,6 +985,11 @@
_host_cpu=arm
_host_alias=arm-linux-androideabi
;;
+androidsdl)
+ _host_os=androidsdl
+ _host_cpu=arm
+ _host_alias=arm-linux-androideabi
+ ;;
arm-riscos)
_host_os=riscos
_host_cpu=arm
@@ -1288,9 +1294,9 @@
if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" 2> /dev/null && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" && cc_check_clean tmp_cxx_compiler.cpp
else
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
fi
}
@@ -1559,6 +1565,11 @@
_unix=yes
_seq_midi=no
;;
+ androidsdl)
+ CXXFLAGS="$CXXFLAGS -Os"
+ _unix=yes
+ _seq_midi=no
+ ;;
beos*)
DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
# Needs -lbind -lsocket for the timidity MIDI driver
@@ -1729,6 +1740,12 @@
_mt32emu=no
_timidity=no
;;
+ androidsdl)
+ DEFINES="$DEFINES -DANDROID"
+ _unix=yes
+ _need_memalign=yes
+ _seq_midi=no
+ ;;
arm-linux|arm*-linux-gnueabi|arm-*-linux)
_unix=yes
_need_memalign=yes
@@ -2123,7 +2140,7 @@
# Enable 16bit support only for backends which support it
#
case $_backend in
- android | dingux | dreamcast | gph | openpandora | psp | samsungtv | sdl | webos | wii)
+ android | androidsdl | dingux | dreamcast | gph | openpandora | psp | samsungtv | sdl | webos | wii)
if test "$_16bit" = auto ; then
_16bit=yes
else
@@ -3180,7 +3197,7 @@
case $_host_os in
# newlib-based system include files suppress non-C89 function
# declarations under __STRICT_ANSI__
- amigaos* | android | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | wii | wince )
+ amigaos* | android | androidsdl | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | wii | wince )
CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter"
;;
*)
@@ -3203,7 +3220,7 @@
# Some platforms use certain GNU extensions in header files
case $_host_os in
-android | gamecube | psp | wii)
+android | androidsdl | gamecube | psp | wii )
;;
*)
# ICC does not support pedantic

View File

@@ -1,124 +0,0 @@
Common subdirectories: scummvm-1.4.1-old/audio and scummvm-1.4.1/audio
Common subdirectories: scummvm-1.4.1-old/backends and scummvm-1.4.1/backends
Common subdirectories: scummvm-1.4.1-old/base and scummvm-1.4.1/base
Common subdirectories: scummvm-1.4.1-old/common and scummvm-1.4.1/common
Only in scummvm-1.4.1: config.h
Only in scummvm-1.4.1: config.log
Only in scummvm-1.4.1: config.mk
diff -u scummvm-1.4.1-old/configure scummvm-1.4.1/configure
--- scummvm-1.4.1-old/configure 2012-01-15 11:08:27.000000000 +0200
+++ scummvm-1.4.1/configure 2012-02-16 16:39:00.184084722 +0200
@@ -718,7 +718,7 @@
-h, --help display this help and exit
--backend=BACKEND backend to build (android, bada, dc, dingux, ds, gp2x, gph,
iphone, linuxmoto, maemo, n64, null, openpandora, ps2,
- psp, samsungtv, sdl, webos, wii, wince) [sdl]
+ psp, samsungtv, sdl, webos, wii, wince, androidsdl) [sdl]
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
@@ -745,6 +745,7 @@
Special configuration feature:
--host=HOST cross-compile to target HOST (arm-linux, ...)
special targets: android for Android
+ androidsdl for Android with SDL backend
bada for Samsung BADA
caanoo for Caanoo
dingux for Dingux
@@ -1117,6 +1118,11 @@
_host_cpu=arm
_host_alias=arm-linux-androideabi
;;
+androidsdl)
+ _host_os=androidsdl
+ _host_cpu=arm
+ _host_alias=arm-linux-androideabi
+ ;;
arm-riscos)
_host_os=riscos
_host_cpu=arm
@@ -1445,9 +1451,9 @@
if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" 2> /dev/null && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" && cc_check_clean tmp_cxx_compiler.cpp
else
- eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
+ eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
fi
}
@@ -1592,7 +1598,7 @@
case $_host_os in
# newlib-based system include files suppress non-C89 function
# declarations under __STRICT_ANSI__
- amigaos* | android | bada | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | ps3 | wii | wince )
+ amigaos* | android | androidsdl | bada | dreamcast | ds | gamecube | mingw* | n64 | psp | ps2 | ps3 | wii | wince )
;;
*)
CXXFLAGS="$CXXFLAGS -ansi"
@@ -1870,6 +1876,11 @@
LDFLAGS="$LDFLAGS -L${CYGWIN_USR_LOCAL}/lib"
CXXFLAGS="$CXXFLAGS -I${CYGWIN_USR_LOCAL}/include"
;;
+ androidsdl)
+ CXXFLAGS="$CXXFLAGS -Os"
+ _unix=yes
+ _seq_midi=no
+ ;;
beos*)
DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
# Needs -lbind -lsocket for the timidity MIDI driver
@@ -2118,6 +2129,12 @@
_mt32emu=no
_timidity=no
;;
+ androidsdl)
+ DEFINES="$DEFINES -DANDROID"
+ _unix=yes
+ _need_memalign=yes
+ _seq_midi=no
+ ;;
arm-linux|arm*-linux-gnueabi|arm-*-linux)
;;
arm-riscos|linupy)
@@ -2496,6 +2513,9 @@
CXXFLAGS="$CXXFLAGS -Wa,--noexecstack"
LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
;;
+ androidsdl)
+ DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE"
+ ;;
bada)
# dirent.h not available. NONSTANDARD_PORT==ensure portdefs.h is included
DEFINES="$DEFINES -DBADA -DDISABLE_STDIO_FILESTREAM -DNONSTANDARD_PORT"
@@ -2667,7 +2687,7 @@
# Enable 16bit support only for backends which support it
#
case $_backend in
- android | bada | dingux | dreamcast | gph | maemo | openpandora | psp | samsungtv | sdl | webos | wii)
+ android | androidsdl | bada | dingux | dreamcast | gph | maemo | openpandora | psp | samsungtv | sdl | webos | wii)
if test "$_16bit" = auto ; then
_16bit=yes
else
@@ -2713,7 +2733,7 @@
amigaos* | cygwin* | dreamcast | ds | gamecube | mingw* | n64 | ps2 | ps3 | psp | wii | wince)
_posix=no
;;
- android | beos* | bsd* | darwin* | freebsd* | gph-linux | haiku* | hpux* | iphone | irix* | linux* | maemo | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos)
+ android | androidsdl | beos* | bsd* | darwin* | freebsd* | gph-linux | haiku* | hpux* | iphone | irix* | linux* | maemo | mint* | netbsd* | openbsd* | solaris* | sunos* | uclinux* | webos)
_posix=yes
;;
os2-emx*)
Common subdirectories: scummvm-1.4.1-old/devtools and scummvm-1.4.1/devtools
Common subdirectories: scummvm-1.4.1-old/dists and scummvm-1.4.1/dists
Common subdirectories: scummvm-1.4.1-old/doc and scummvm-1.4.1/doc
Common subdirectories: scummvm-1.4.1-old/engines and scummvm-1.4.1/engines
Common subdirectories: scummvm-1.4.1-old/graphics and scummvm-1.4.1/graphics
Common subdirectories: scummvm-1.4.1-old/gui and scummvm-1.4.1/gui
Common subdirectories: scummvm-1.4.1-old/icons and scummvm-1.4.1/icons
Common subdirectories: scummvm-1.4.1-old/po and scummvm-1.4.1/po
Only in scummvm-1.4.1: scummvm
Common subdirectories: scummvm-1.4.1-old/test and scummvm-1.4.1/test
Common subdirectories: scummvm-1.4.1-old/video and scummvm-1.4.1/video

View File

@@ -16,11 +16,13 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) -DBCMHOST
LOCAL_SRC_FILES := \
src/gl/array.c \
src/gl/blend.c \
src/gl/buffers.c \
src/gl/debug.c \
src/gl/decompress.c \
src/gl/directstate.c \
src/gl/eval.c \
src/gl/fog.c \
src/gl/framebuffers.c \
src/gl/getter.c \
src/gl/gl.c \
@@ -46,6 +48,7 @@ LOCAL_SRC_FILES := \
src/glx/hardext.c \
src/glx/glx.c \
src/glx/lookup.c \
src/glx/rpi.c \
src/glx/streaming.c \
LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DBCMHOST -fvisibility=hidden -include include/android_debug.h

View File

@@ -7,7 +7,7 @@ This is a fork a glshim (https://github.com/lunixbochs/glshim). Go check this li
The focus is on compatibility with a wide selection of game and software, as well as speed.
It has been tested successfully of a large selection of games and software, including: Mincraft, OpenMW, SeriousSam, RVGL, TSMC, TORCS, SpeedDreams, GL-117, Foobillard(plus), Blender 2.68 and many more.
It has been tested successfully of a large selection of games and software, including: Minecraft, OpenMW, SeriousSam (both First and Second Encounters), RVGL (ReVolt GL), TSMC (The Secret Maryo Chronicles), TORCS, SpeedDreams, GL-117, Foobillard(plus), Blender 2.68 to name just a few.
Most function of OpenGL up to 1.5 are supported, with some notable exceptions:
* Reading of Depth or Stencil buffer will not work
@@ -135,7 +135,7 @@ Experimental: enable Alpha test only when using texture that contains an alpha c
* 1 : Alpha Hack enabled
##### LIBGL_NODOWNSAMPLING
Texture downsampling control
Texture downsampling control (deprecated, use LIBGL_AVOID16BITS instead)
* 0 : Default, DXTc texture are downsampled to 16bits
* 1 : DXTc texture are left as 32bits RGBA
@@ -241,10 +241,26 @@ Merge of subsequent glBegin/glEnd blocks (will be non-effective if BATCH mode is
* 1 : Try to merge, even if there is a glColor / glNormal in between (default)
* 2 : Try hard to merge, even if there is a glColor / glNormal or Matrix operations in between
##### LIBGL_AVOID16BITS
Try to avoid 16bits textures
* 0 : Default, use 16bits texture if it can avoid a convertion or for DXTc textures
* 1 : Use 32bits texture unless specifically requested (using internalformat)
----
Version history
----
##### Current version
* Some fix with the PixMap glX context creation
##### 0.9.6
* Some fixes in GL_TEXTURE_RECTANGLE_ARB handling
* Some other fixes in texture handling (unpack and glList related)
* Some fix with the PBuffer glX context creation
* Tracking of glFog
* Exposed glBlendEquation if supported
* New LIBGL_AVOID16BITS parameter to prefer 32bits texture (usefull on ODroid)
* Some optimisations in texture conversion
##### 0.9.5
* Added some optimisations for sequencial glBegin/glEnd blocks, with a switch to control them

View File

@@ -29,5 +29,7 @@
#define GL_NOVAOCACHE_HINT_GL4ES 0xA10C
// same as using LIBGL_BEGINEND=x
#define GL_BEGINEND_HINT_GL4ES 0xA10D
// same as using LIBGL_AVOID16BITS=x
#define GL_AVOID16BITS_HINT_GL4ES 0xA10E
#endif

View File

@@ -0,0 +1,177 @@
glActiveTexture: [void, GLenum texture]
glAlphaFunc: [void, GLenum func, GLclampf ref]
glAlphaFuncx: [void, GLenum func, GLclampx ref]
glBindBuffer: [void, GLenum target, GLuint buffer]
glBindTexture: [void, GLenum target, GLuint texture]
glBlendFunc: [void, GLenum sfactor, GLenum dfactor]
glBufferData: [void, GLenum target, GLsizeiptr size, "const GLvoid *data", GLenum usage]
glBufferSubData: [void, GLenum target, GLintptr offset, GLsizeiptr size, "const GLvoid *data"]
glClear: [void, GLbitfield mask]
glClearColor: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glClearColorx: [void, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha]
glClearDepthf: [void, GLclampf depth]
glClearDepthx: [void, GLclampx depth]
glClearStencil: [void, GLint s]
glClientActiveTexture: [void, GLenum texture]
glClipPlanef: [void, GLenum plane, "const GLfloat *equation"]
glClipPlanex: [void, GLenum plane, "const GLfixed *equation"]
glColor4f: [void, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha]
glColor4ub: [void, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha]
glColor4x: [void, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha]
glColorMask: [void, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha]
glColorPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glCompressedTexImage2D: [void, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, "const GLvoid *data"]
glCompressedTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, "const GLvoid *data"]
glCopyTexImage2D: [void, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border]
glCopyTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height]
glCullFace: [void, GLenum mode]
glDeleteBuffers: [void, GLsizei n, "const GLuint *buffers"]
glDeleteTextures: [void, GLsizei n, "const GLuint *textures"]
glDepthFunc: [void, GLenum func]
glDepthMask: [void, GLboolean flag]
glDepthRangef: [void, GLclampf near, GLclampf far]
glDepthRangex: [void, GLclampx near, GLclampx far]
glDisable: [void, GLenum cap]
glDisableClientState: [void, GLenum array]
glDisableClientState: [void, GLenum array]
glDrawArrays: [void, GLenum mode, GLint first, GLsizei count]
glDrawElements: [void, GLenum mode, GLsizei count, GLenum type, "const GLvoid *indices"]
glEnable: [void, GLenum cap]
glEnableClientState: [void, GLenum array]
glEnableClientState: [void, GLenum array]
glFinish: [void, void]
glFlush: [void, void]
glFogf: [void, GLenum pname, GLfloat param]
glFogfv: [void, GLenum pname, "const GLfloat *params"]
glFogx: [void, GLenum pname, GLfixed param]
glFogxv: [void, GLenum pname, "const GLfixed *params"]
glFrontFace: [void, GLenum mode]
glFrustumf: [void, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far]
glFrustumx: [void, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed near, GLfixed far]
glGenBuffers: [void, GLsizei n, "GLuint *buffers"]
glGenTextures: [void, GLsizei n, "GLuint *textures"]
glGetBooleanv: [void, GLenum pname, "GLboolean *params"]
glGetBufferParameteriv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetClipPlanef: [void, GLenum plane, "GLfloat *equation"]
glGetClipPlanex: [void, GLenum plane, "GLfixed *equation"]
glGetError: [GLenum, void]
glGetFixedv: [void, GLenum pname, "GLfixed *params"]
glGetFloatv: [void, GLenum pname, "GLfloat *params"]
glGetIntegerv: [void, GLenum pname, "GLint *params"]
glGetLightfv: [void, GLenum light, GLenum pname, "GLfloat *params"]
glGetLightxv: [void, GLenum light, GLenum pname, "GLfixed *params"]
glGetMaterialfv: [void, GLenum face, GLenum pname, "GLfloat *params"]
glGetMaterialxv: [void, GLenum face, GLenum pname, "GLfixed *params"]
glGetPointerv: [void, GLenum pname, "GLvoid **params"]
glGetString: [const GLubyte *, GLenum name]
glGetTexEnvfv: [void, GLenum target, GLenum pname, "GLfloat *params"]
glGetTexEnviv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetTexEnvxv: [void, GLenum target, GLenum pname, "GLfixed *params"]
glGetTexParameterfv: [void, GLenum target, GLenum pname, "GLfloat *params"]
glGetTexParameteriv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetTexParameterxv: [void, GLenum target, GLenum pname, "GLfixed *params"]
glHint: [void, GLenum target, GLenum mode]
glIsBuffer: [GLboolean, GLuint buffer]
glIsEnabled: [GLboolean, GLenum cap]
glIsTexture: [GLboolean, GLuint texture]
glLightf: [void, GLenum light, GLenum pname, GLfloat param]
glLightfv: [void, GLenum light, GLenum pname, "const GLfloat *params"]
glLightModelf: [void, GLenum pname, GLfloat param]
glLightModelfv: [void, GLenum pname, "const GLfloat *params"]
glLightModelx: [void, GLenum pname, GLfixed param]
glLightModelxv: [void, GLenum pname, "const GLfixed *params"]
glLightx: [void, GLenum light, GLenum pname, GLfixed param]
glLightxv: [void, GLenum light, GLenum pname, "const GLfixed *params"]
glLineWidth: [void, GLfloat width]
glLineWidthx: [void, GLfixed width]
glLoadIdentity: [void, void]
glLoadMatrixf: [void, "const GLfloat *m"]
glLoadMatrixx: [void, "const GLfixed *m"]
glLogicOp: [void, GLenum opcode]
glMaterialf: [void, GLenum face, GLenum pname, GLfloat param]
glMaterialfv: [void, GLenum face, GLenum pname, "const GLfloat *params"]
glMaterialx: [void, GLenum face, GLenum pname, GLfixed param]
glMaterialxv: [void, GLenum face, GLenum pname, "const GLfixed *params"]
glMatrixMode: [void, GLenum mode]
glMultiTexCoord4f: [void, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q]
glMultiTexCoord4x: [void, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q]
glMultMatrixf: [void, "const GLfloat *m"]
glMultMatrixx: [void, "const GLfixed *m"]
glNormal3f: [void, GLfloat nx, GLfloat ny, GLfloat nz]
glNormal3x: [void, GLfixed nx, GLfixed ny, GLfixed nz]
glNormalPointer: [void, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glOrthof: [void, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far]
glOrthox: [void, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed near, GLfixed far]
glPixelStorei: [void, GLenum pname, GLint param]
glPointParameterf: [void, GLenum pname, GLfloat param]
glPointParameterfv: [void, GLenum pname, "const GLfloat *params"]
glPointParameterx: [void, GLenum pname, GLfixed param]
glPointParameterxv: [void, GLenum pname, "const GLfixed *params"]
glPointSize: [void, GLfloat size]
glPointSizePointerOES: [void, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glPointSizex: [void, GLfixed size]
glPolygonOffset: [void, GLfloat factor, GLfloat units]
glPolygonOffsetx: [void, GLfixed factor, GLfixed units]
glPopMatrix: [void, void]
glPushMatrix: [void, void]
glReadPixels: [void, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, "GLvoid *pixels"]
glRotatef: [void, GLfloat angle, GLfloat x, GLfloat y, GLfloat z]
glRotatex: [void, GLfixed angle, GLfixed x, GLfixed y, GLfixed z]
glSampleCoverage: [void, GLclampf value, GLboolean invert]
glSampleCoveragex: [void, GLclampx value, GLboolean invert]
glScalef: [void, GLfloat x, GLfloat y, GLfloat z]
glScalex: [void, GLfixed x, GLfixed y, GLfixed z]
glScissor: [void, GLint x, GLint y, GLsizei width, GLsizei height]
glShadeModel: [void, GLenum mode]
glStencilFunc: [void, GLenum func, GLint ref, GLuint mask]
glStencilMask: [void, GLuint mask]
glStencilOp: [void, GLenum fail, GLenum zfail, GLenum zpass]
glTexCoordPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glTexEnvf: [void, GLenum target, GLenum pname, GLfloat param]
glTexEnvfv: [void, GLenum target, GLenum pname, "const GLfloat *params"]
glTexEnvi: [void, GLenum target, GLenum pname, GLint param]
glTexEnviv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexEnvx: [void, GLenum target, GLenum pname, GLfixed param]
glTexEnvxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexImage2D: [void, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, "const GLvoid *data"]
glTexParameterf: [void, GLenum target, GLenum pname, GLfloat param]
glTexParameterfv: [void, GLenum target, GLenum pname, "const GLfloat *params"]
glTexParameteri: [void, GLenum target, GLenum pname, GLint param]
glTexParameteriv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexParameterx: [void, GLenum target, GLenum pname, GLfixed param]
glTexParameterxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, "const GLvoid *data"]
glTranslatef: [void, GLfloat x, GLfloat y, GLfloat z]
glTranslatex: [void, GLfixed x, GLfixed y, GLfixed z]
glVertexPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glViewport: [void, GLint x, GLint y, GLsizei width, GLsizei height]
glBlendColor_OES_: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glBlendEquation_OES_: [void, GLenum mode]
glBlendEquationSeparate_OES_: [void, GLenum modeRGB, GLenum modeA]
glBlendFuncSeparate_OES_: [void, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha]
# glTexGenfOES_OES_: [void, GLenum coord, GLenum pname, GLfloat param]
glTexGenfv_OES_: [void, GLenum coord, GLenum pname, "const GLfloat *params"]
glTexGeni_OES_: [void, GLenum coord, GLenum pname, GLint param]
# glTexGenivOES_OES_: [void, GLenum coord, GLenum pname, "const GLint *params"]
glGenFramebuffers_OES_: [void, GLsizei n, "GLuint *ids"]
glDeleteFramebuffers_OES_: [void, GLsizei n, "GLuint *framebuffers"]
glIsFramebuffer_OES_: [GLboolean, GLuint framebuffer]
glCheckFramebufferStatus_OES_: [GLenum, GLenum target]
glBindFramebuffer_OES_: [void, GLenum target, GLuint framebuffer]
glFramebufferTexture2D_OES_: [void, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level]
glGenRenderbuffers_OES_: [void, GLsizei n, "GLuint *renderbuffers"]
glFramebufferRenderbuffer_OES_: [void, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer]
glDeleteRenderbuffers_OES_: [void, GLsizei n, "GLuint *renderbuffers"]
glRenderbufferStorage_OES_: [void, GLenum target, GLenum internalformat, GLsizei width, GLsizei height]
glBindRenderbuffer_OES_: [void, GLenum target, GLuint renderbuffer]
glIsRenderbuffer_OES_: [GLboolean, GLuint renderbuffer]
glGenerateMipmap_OES_: [void, GLenum target]
glGetFramebufferAttachmentParameteriv_OES_: [void, GLenum target, GLenum attachment, GLenum pname, "GLint *params"]
glGetRenderbufferParameteriv_OES_: [void, GLenum target, GLenum pname, "GLint * params"]
glDrawTexi_OES_: [void, GLint x, GLint y, GLint z, GLint width, GLint height]
glDrawTexf_OES_: [void, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height]
glMultiDrawArrays_OES_: [void, GLenum mode, "const GLint *first", "const GLsizei *count", GLsizei primcount]
glMultiDrawElements_OES_: [void, GLenum mode, "GLsizei *count", GLenum type, "const void * const *indices", GLsizei primcount]

View File

@@ -133,14 +133,14 @@ glTexEnvi: [void, GLenum target, GLenum pname, GLint param]
glTexEnviv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexEnvx: [void, GLenum target, GLenum pname, GLfixed param]
glTexEnvxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexImage2D: [void, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, "const GLvoid *pixels"]
glTexImage2D: [void, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, "const GLvoid *data"]
glTexParameterf: [void, GLenum target, GLenum pname, GLfloat param]
glTexParameterfv: [void, GLenum target, GLenum pname, "const GLfloat *params"]
glTexParameteri: [void, GLenum target, GLenum pname, GLint param]
glTexParameteriv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexParameterx: [void, GLenum target, GLenum pname, GLfixed param]
glTexParameterxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, "const GLvoid *pixels"]
glTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, "const GLvoid *data"]
glTranslatef: [void, GLfloat x, GLfloat y, GLfloat z]
glTranslatex: [void, GLfixed x, GLfixed y, GLfixed z]
glVertexPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]

View File

@@ -3,11 +3,13 @@ include_directories(util)
#file(GLOB_RECURSE GL_SOURCES gl/*.c)
SET(GL_SRC
gl/array.c
gl/blend.c
gl/buffers.c
gl/debug.c
gl/decompress.c
gl/directstate.c
gl/eval.c
gl/fog.c
gl/framebuffers.c
gl/getter.c
gl/gl.c
@@ -35,12 +37,14 @@ SET(GL_SRC
SET(GL_H
../version.h
gl/array.h
gl/blend.h
gl/buffers.h
gl/const.h
gl/debug.h
gl/decompress.h
gl/defines.h
gl/directstate.h
gl/fog.h
gl/eval.h
gl/framebuffers.h
gl/gles.h
@@ -78,12 +82,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
glx/hardext.c
glx/glx.c
glx/lookup.c
glx/rpi.c
glx/streaming.c
glx/utils.c
)
list(APPEND GL_H
glx/glx.h
glx/hardext.h
glx/rpi.h
glx/streaming.h
glx/utils.h
)

View File

@@ -31,17 +31,17 @@
#define skip_glBlendColor
#define skip_glBlendFunc
#define skip_glBlendEquation
#define skip_glBlendEquationSeparate
#define skip_glBlendEquationSeparatei
#define skip_glBlendFuncSeparate
#define skip_glBlendFuncSeparatei
#define skip_glFogfv
#define skip_glPointParameterfv
#define skip_glPointParameterf
//#define skip_glBlendEquation
#define skip_glBlendEquationSeparate
#define skip_glBlendEquationSeparatei
#define skip_glBlendFuncSeparate
#define skip_glBlendFuncSeparatei
// getter.c
#define skip_glGetError
@@ -78,6 +78,8 @@
#define skip_glTexImage2D
#define skip_glTexParameteri
#define skip_glTexParameterf
#define skip_glTexParameterfv
#define skip_glTexParameteriv
#define skip_glTexSubImage2D
#define skip_glActiveTexture
#define skip_glClientActiveTexture

150
project/jni/gl4es/src/gl/blend.c Executable file
View File

@@ -0,0 +1,150 @@
#include "blend.h"
#include "debug.h"
#include "../glx/hardext.h"
#include "init.h"
void gl4es_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
PUSH_IF_COMPILING(glBlendColor);
LOAD_GLES_OR_OES(glBlendColor);
if (gles_glBlendColor)
gles_glBlendColor(red, green, blue, alpha);
else {
static int test = 1;
if (test) {
LOGD("stub glBlendColor(%f, %f, %f, %f)\n", red, green, blue, alpha);
test = 0;
}
}
}
void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void glBlendColorEXT(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void glBlendColorARB(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void gl4es_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
{
PUSH_IF_COMPILING(glBlendFuncSeparate);
LOAD_GLES_OES(glBlendFuncSeparate);
#ifndef PANDORA
if(gles_glBlendFuncSeparate==NULL) {
// some fallback function to have better rendering with SDL2, better then nothing...
if(sfactorRGB==GL_SRC_ALPHA && dfactorRGB==GL_ONE_MINUS_SRC_ALPHA && sfactorAlpha==GL_ONE && dfactorAlpha==GL_ONE_MINUS_SRC_ALPHA)
gl4es_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else if (sfactorRGB==GL_SRC_ALPHA && dfactorRGB==GL_ONE && sfactorAlpha==GL_ZERO && dfactorAlpha==GL_ONE)
gl4es_glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else if (sfactorRGB==GL_ZERO && dfactorRGB==GL_SRC_COLOR && sfactorAlpha==GL_ZERO && dfactorAlpha==GL_ONE)
gl4es_glBlendFunc(GL_ZERO, GL_SRC_COLOR);
else if (sfactorRGB==sfactorAlpha && dfactorRGB==dfactorAlpha)
gl4es_glBlendFunc(sfactorRGB, dfactorRGB);
} else
#endif
gles_glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
void glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) AliasExport("gl4es_glBlendFuncSeparate");
void glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) AliasExport("gl4es_glBlendFuncSeparate");
void gl4es_glBlendEquationSeparate(GLenum modeRGB, GLenum modeA) {
PUSH_IF_COMPILING(glBlendEquationSeparate);
LOAD_GLES_OES(glBlendEquationSeparate);
#ifndef PANDORA
if(gles_glBlendEquationSeparate)
#endif
gles_glBlendEquationSeparate(modeRGB, modeA);
}
void glBlendEquationSeparate(GLenum modeRGB, GLenum modeA) AliasExport("gl4es_glBlendEquationSeparate");
void glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) AliasExport("gl4es_glBlendEquationSeparate");
void gl4es_glBlendFunc(GLenum sfactor, GLenum dfactor) {
if (glstate->list.active)
if (!glstate->list.compiling && glstate->gl_batch) {
if ((glstate->statebatch.blendfunc_s == sfactor) && (glstate->statebatch.blendfunc_d == dfactor))
return; // nothing to do...
if (!glstate->statebatch.blendfunc_s) {
glstate->statebatch.blendfunc_s = sfactor;
glstate->statebatch.blendfunc_d = dfactor;
}
}
PUSH_IF_COMPILING(glBlendFunc)
LOAD_GLES(glBlendFunc);
LOAD_GLES_OES(glBlendFuncSeparate);
errorGL();
// There are some limitations in GLES1.1 Blend functions
switch(sfactor) {
#if 0
case GL_SRC_COLOR:
if (gles_glBlendFuncSeparate) {
gles_glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
return;
}
sfactor = GL_ONE; // approx...
break;
case GL_ONE_MINUS_SRC_COLOR:
if (gles_glBlendFuncSeparate) {
gles_glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
return;
}
sfactor = GL_ONE; // not sure it make sense...
break;
#endif
// here, we need support for glBlendColor...
case GL_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
if(hardext.blendcolor==0)
sfactor = GL_ONE;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_ALPHA:
if(hardext.blendcolor==0)
sfactor = GL_ZERO;
break;
default:
break;
}
switch(dfactor) {
#if 0
case GL_DST_COLOR:
sfactor = GL_ONE; // approx...
break;
case GL_ONE_MINUS_DST_COLOR:
sfactor = GL_ZERO; // not sure it make sense...
break;
#endif
// here, we need support for glBlendColor...
case GL_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
if(hardext.blendcolor==0)
sfactor = GL_ONE;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_ALPHA:
if(hardext.blendcolor==0)
sfactor = GL_ZERO;
break;
default:
break;
}
if ((globals4es.blendhack) && (sfactor==GL_SRC_ALPHA) && (dfactor==GL_ONE)) {
// special case, as seen in Xash3D, but it breaks torus_trooper, so behind a parameter
sfactor = GL_ONE;
}
#ifdef ODROID
if(gles_glBlendFunc)
#endif
gles_glBlendFunc(sfactor, dfactor);
}
void glBlendFunc(GLenum sfactor, GLenum dfactor) AliasExport("gl4es_glBlendFunc");
void gl4es_glBlendEquation(GLenum mode) {
PUSH_IF_COMPILING(glBlendEquation)
LOAD_GLES_OR_OES(glBlendEquation);
errorGL();
#ifdef ODROID
if(gles_glBlendEquation)
#endif
gles_glBlendEquation(mode);
}
void glBlendEquation(GLenum mode) AliasExport("gl4es_glBlendEquation");
void glBlendEquationEXT(GLenum mode) AliasExport("gl4es_glBlendEquation");

View File

@@ -0,0 +1,13 @@
#include "gl.h"
#ifndef GL_BLEND_H
#define GL_BLEND_H
void gl4es_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void gl4es_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
void gl4es_glBlendEquationSeparate(GLenum modeRGB, GLenum modeA);
void gl4es_glBlendFunc(GLenum sfactor, GLenum dfactor);
void gl4es_glBlendEquation(GLenum mode);
#endif //GL_BLEND_H

View File

@@ -61,7 +61,7 @@
#define GL_TEXTURE_LOD_BIAS 0x8501
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_GEN_STR 0x8D60
#define GL_CLAMP_TO_BORDER 0x812D
// GL_ARB_point_sprite
#define GL_POINT_SPRITE 0x8861
@@ -197,6 +197,11 @@
#define GL_LINEAR 0x2601
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
#define GL_FOG_COORDINATE_SOURCE 0x8450
#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
#define GL_FRAGMENT_DEPTH 0x8452
#define GL_FOG_COORDINATE 0x8451
#define GL_FOG_COORD GL_FOG_COORDINATE
// lighting
#define GL_LIGHTING 0x0B50

54
project/jni/gl4es/src/gl/fog.c Executable file
View File

@@ -0,0 +1,54 @@
#include "fog.h"
#include "../glx/hardext.h"
#include "matrix.h"
#include "matvec.h"
void gl4es_glFogfv(GLenum pname, const GLfloat* params) {
if (glstate->list.active)
if (glstate->list.compiling || glstate->gl_batch) {
NewStage(glstate->list.active, STAGE_FOG);
rlFogOp(glstate->list.active, pname, params);
return;
}
else flush();
noerrorShim();
#define GO(A,name, size) if(memcmp(A glstate->fog.name, params, size)==0) return; else memcpy(A glstate->fog.name, params, size);
switch (pname) {
case GL_FOG_MODE:
GO(&, mode, sizeof(GLfloat))
break;
case GL_FOG_DENSITY:
GO(&, density, sizeof(GLfloat))
break;
case GL_FOG_START:
GO(&, start, sizeof(GLfloat))
break;
case GL_FOG_END:
GO(&, end, sizeof(GLfloat))
break;
case GL_FOG_INDEX:
GO(&, index, sizeof(GLfloat))
return; // unsupported on GLES1.1
case GL_FOG_COLOR:
GO(, color, 4*sizeof(GLfloat))
break;
case GL_FOG_COORD_SRC:
GO(&, coord_src, sizeof(GLfloat))
return; // unsupported on GLES1.1
default:
errorShim(GL_INVALID_ENUM);
return;
}
#undef GO
LOAD_GLES(glFogfv);
gles_glFogfv(pname, params);
errorGL();
}
void glFogfv(GLenum pname, const GLfloat* params) AliasExport("gl4es_glFogfv");

18
project/jni/gl4es/src/gl/fog.h Executable file
View File

@@ -0,0 +1,18 @@
#include "gl.h"
#ifndef __FOG_H_
#define __FOG_H_
typedef struct {
GLenum mode;
GLfloat density;
GLfloat start;
GLfloat end;
GLfloat index;
GLfloat color[4];
GLenum coord_src;
} fog_t;
void gl4es_glFogfv(GLenum pname, const GLfloat* params);
#endif

View File

@@ -5,6 +5,14 @@
#ifndef ANDROID
#include <execinfo.h>
#endif
//#define DEBUG
#ifdef DEBUG
#define DBG(a) a
#else
#define DBG(a)
#endif
//extern void* eglGetProcAddress(const char* name);
khash_t(dsr) *depthstencil = NULL;
@@ -31,7 +39,7 @@ int cap_fbos = 0;
int npot(int n);
void readfboBegin() {
//printf("readfboBegin, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);
DBG(printf("readfboBegin, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);)
LOAD_GLES_OES(glBindFramebuffer);
if (!(fbo_read || fbo_draw))
return;
@@ -42,7 +50,7 @@ void readfboBegin() {
}
void readfboEnd() {
//printf("readfboEnd, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);
DBG(printf("readfboEnd, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);)
LOAD_GLES_OES(glBindFramebuffer);
if (!(fbo_read || fbo_draw))
return;
@@ -53,11 +61,11 @@ void readfboEnd() {
}
void gl4es_glGenFramebuffers(GLsizei n, GLuint *ids) {
DBG(printf("glGenFramebuffers(%i, %p)\n", n, ids);)
LOAD_GLES_OES(glGenFramebuffers);
//printf("glGenFramebuffers(%i, %p)\n", n, ids);
GLsizei m = 0;
while(globals4es.recyclefbo && (nbr_fbos>0) && (n-m>0)) {
//printf("Recycled 1 FBO\n");
DBG(printf("Recycled 1 FBO\n");)
ids[m++] = old_fbos[--nbr_fbos];
}
noerrorShim();
@@ -68,10 +76,10 @@ void gl4es_glGenFramebuffers(GLsizei n, GLuint *ids) {
}
void gl4es_glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) {
//printf("glDeleteFramebuffers(%i, %p), framebuffers[0]=%u\n", n, framebuffers, framebuffers[0]);
DBG(printf("glDeleteFramebuffers(%i, %p), framebuffers[0]=%u\n", n, framebuffers, framebuffers[0]);)
if (glstate->gl_batch) flush();
if (globals4es.recyclefbo) {
//printf("Recycling %i FBOs\n", n);
DBG(printf("Recycling %i FBOs\n", n);)
noerrorShim();
if(cap_fbos == 0) {
cap_fbos = 16;
@@ -91,7 +99,7 @@ void gl4es_glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) {
}
GLboolean gl4es_glIsFramebuffer(GLuint framebuffer) {
//printf("glIsFramebuffer(%u)\n", framebuffer);
DBG(printf("glIsFramebuffer(%u)\n", framebuffer);)
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glIsFramebuffer);
@@ -114,14 +122,14 @@ GLenum gl4es_glCheckFramebufferStatus(GLenum target) {
GLenum result = gles_glCheckFramebufferStatus(target);
#endif
#undef BEFORE
//printf("glCheckFramebufferStatus(0x%04X)=0x%04X\n", target, result);
DBG(printf("glCheckFramebufferStatus(0x%04X)=0x%04X\n", target, result);)
return result;
}
void gl4es_glBindFramebuffer(GLenum target, GLuint framebuffer) {
//printf("glBindFramebuffer(%s, %u), list=%s\n", PrintEnum(target), framebuffer, glstate->list.active?"active":"none");
//PUSH_IF_COMPILING(glBindFramebuffer);
DBG(printf("glBindFramebuffer(%s, %u), list=%s, current_fb=%d (draw=%d, read=%d)\n", PrintEnum(target), framebuffer, glstate->list.active?"active":"none", current_fb, fbo_draw, fbo_read);)
if (glstate->gl_batch) flush();
PUSH_IF_COMPILING(glBindFramebuffer);
LOAD_GLES_OES(glBindFramebuffer);
LOAD_GLES_OES(glCheckFramebufferStatus);
LOAD_GLES(glGetError);
@@ -162,8 +170,36 @@ void gl4es_glBindFramebuffer(GLenum target, GLuint framebuffer) {
fb_status = gles_glCheckFramebufferStatus(target);
}
GLenum ReadDraw_Push(GLenum target) {
if(target==GL_FRAMEBUFFER)
return GL_FRAMEBUFFER;
LOAD_GLES_OES(glBindFramebuffer);
if(target==GL_DRAW_FRAMEBUFFER) {
if(current_fb!=fbo_draw)
gles_glBindFramebuffer(GL_FRAMEBUFFER, fbo_draw);
return GL_FRAMEBUFFER;
}
if(target==GL_READ_FRAMEBUFFER) {
if(current_fb!=fbo_read)
gles_glBindFramebuffer(GL_FRAMEBUFFER, fbo_read);
return GL_FRAMEBUFFER;
}
return target;
}
void ReadDraw_Pop(GLenum target) {
if(target==GL_FRAMEBUFFER)
return;
LOAD_GLES_OES(glBindFramebuffer);
if(target==GL_DRAW_FRAMEBUFFER && current_fb!=fbo_draw) {
gles_glBindFramebuffer(GL_FRAMEBUFFER, (mainfbo_fbo && (current_fb==0))?mainfbo_fbo:current_fb);
}
if(target==GL_READ_FRAMEBUFFER && current_fb!=fbo_read) {
gles_glBindFramebuffer(GL_FRAMEBUFFER, (mainfbo_fbo && (current_fb==0))?mainfbo_fbo:current_fb);
}
}
void gl4es_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
DBG(printf("glFramebufferTexture2D(%s, %s, %s, %u, %i) current_fb=%d (draw=%d, read=%d)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(textarget), texture, level, current_fb, fbo_draw, fbo_read);)
static GLuint scrap_tex = 0;
static int scrap_width = 0;
static int scrap_height = 0;
@@ -172,7 +208,6 @@ void gl4es_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum texta
LOAD_GLES_OES(glFramebufferTexture2D);
LOAD_GLES(glTexImage2D);
LOAD_GLES(glBindTexture);
//printf("glFramebufferTexture2D(%s, %s, %s, %u, %i)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(textarget), texture, level);
// Ignore Color attachment 1 .. 9
if ((attachment>=GL_COLOR_ATTACHMENT0+1) && (attachment<=GL_COLOR_ATTACHMENT0+9)) {
@@ -227,10 +262,12 @@ void gl4es_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum texta
gles_glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->nwidth, tex->nheight, 0, tex->format, tex->type, NULL);
if (oldtex!=tex->glname) gles_glBindTexture(GL_TEXTURE_2D, oldtex);
}*/
//printf("found texture, glname=%u, size=%ix%i(%ix%i), format/type=0x%04X/0x%04X\n", texture, tex->width, tex->height, tex->nwidth, tex->nheight, tex->format, tex->type);
DBG(printf("found texture, glname=%u, size=%ix%i(%ix%i), format/type=0x%04X/0x%04X\n", texture, tex->width, tex->height, tex->nwidth, tex->nheight, tex->format, tex->type);)
}
}
GLenum ntarget = ReadDraw_Push(target);
if(attachment==GL_DEPTH_ATTACHMENT /*&& hardext.depthtex==0*/) {
noerrorShim();
if (level!=0) return;
@@ -241,7 +278,8 @@ void gl4es_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum texta
gl4es_glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, twidth, theight);
gl4es_glBindRenderbuffer(GL_RENDERBUFFER, 0);
errorGL();
gl4es_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, render_depth);
gl4es_glFramebufferRenderbuffer(ntarget, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, render_depth);
ReadDraw_Pop(target);
return;
}
@@ -265,7 +303,8 @@ void gl4es_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum texta
}
errorGL();
gles_glFramebufferTexture2D(target, attachment, textarget, texture, 0);
gles_glFramebufferTexture2D(ntarget, attachment, textarget, texture, 0);
ReadDraw_Pop(target);
}
void gl4es_glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
@@ -277,17 +316,17 @@ void gl4es_glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum texta
}
void gl4es_glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) {
DBG(printf("glGenRenderbuffers(%i, %p)\n", n, renderbuffers);)
LOAD_GLES_OES(glGenRenderbuffers);
//printf("glGenRenderbuffers(%i, %p)\n", n, renderbuffers);
errorGL();
gles_glGenRenderbuffers(n, renderbuffers);
}
void gl4es_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
DBG(printf("glFramebufferRenderbuffer(%s, %s, %s, %u)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(renderbuffertarget), renderbuffer);)
LOAD_GLES_OES(glFramebufferRenderbuffer);
LOAD_GLES_OES(glGetFramebufferAttachmentParameteriv);
//printf("glFramebufferRenderbuffer(%s, %s, %s, %u)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(renderbuffertarget), renderbuffer);
//TODO: handle target=READBUFFER or DRAWBUFFER...
if (depthstencil && (attachment==GL_STENCIL_ATTACHMENT)) {
@@ -304,21 +343,26 @@ void gl4es_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum re
noerrorShim();
return;
}
GLenum ntarget = ReadDraw_Push(target);
if ((current_fb!=0) && (renderbuffer!=0) && ((attachment==GL_DEPTH_ATTACHMENT) || (attachment==GL_STENCIL_ATTACHMENT))) {
GLuint tmp;
gles_glGetFramebufferAttachmentParameteriv(target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &tmp);
gles_glGetFramebufferAttachmentParameteriv(ntarget, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &tmp);
if (tmp==renderbuffer) {
noerrorShim();
ReadDraw_Pop(target);
return;
}
}
errorGL();
gles_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
gles_glFramebufferRenderbuffer(ntarget, attachment, renderbuffertarget, renderbuffer);
ReadDraw_Pop(target);
}
void gl4es_glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) {
DBG(printf("glDeleteRenderbuffer(%d, %p)\n", n, renderbuffers);)
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glDeleteRenderbuffers);
@@ -345,10 +389,10 @@ void gl4es_glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) {
}
void gl4es_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
DBG(printf("glRenderbufferStorage(%s, %s, %i, %i)\n", PrintEnum(target), PrintEnum(internalformat), width, height);)
LOAD_GLES_OES(glRenderbufferStorage);
LOAD_GLES_OES(glGenRenderbuffers);
LOAD_GLES_OES(glBindRenderbuffer);
//printf("glRenderbufferStorage(0x%04X, 0x%04X, %i, %i)\n", target, internalformat, width, height);
errorGL();
width = hardext.npot==2?width:npot(width);
@@ -401,9 +445,9 @@ void gl4es_glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLen
}
void gl4es_glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
DBG(printf("glBindRenderbuffer(%s, %u), binded Fbo=%u\n", PrintEnum(target), renderbuffer, current_fb);)
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glBindRenderbuffer);
//printf("glBindRenderbuffer(%s, %u), binded Fbo=%u\n", PrintEnum(target), renderbuffer, current_fb);
current_rb = renderbuffer;
@@ -412,7 +456,7 @@ void gl4es_glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
}
GLboolean gl4es_glIsRenderbuffer(GLuint renderbuffer) {
//printf("glIsRenderbuffer(%u)\n", renderbuffer);
DBG(printf("glIsRenderbuffer(%u)\n", renderbuffer);)
if (glstate->gl_batch) flush();
LOAD_GLES_OES(glIsRenderbuffer);
@@ -421,36 +465,40 @@ GLboolean gl4es_glIsRenderbuffer(GLuint renderbuffer) {
}
void gl4es_glGenerateMipmap(GLenum target) {
//printf("glGenerateMipmap(0x%04X)\n", target);
DBG(printf("glGenerateMipmap(%s)\n", PrintEnum(target));)
LOAD_GLES_OES(glGenerateMipmap);
errorGL();
return gles_glGenerateMipmap(target);
if(globals4es.automipmap != 3)
gles_glGenerateMipmap(target);
}
void gl4es_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) {
//printf("glGetFramebufferAttachmentParameteriv(%s, %s, %s, %p)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(pname), params);
DBG(printf("glGetFramebufferAttachmentParameteriv(%s, %s, %s, %p)\n", PrintEnum(target), PrintEnum(attachment), PrintEnum(pname), params);)
LOAD_GLES_OES(glGetFramebufferAttachmentParameteriv);
GLenum ntarget = ReadDraw_Push(target);
// hack to return DEPTH size
if(target==GL_FRAMEBUFFER && attachment==GL_DEPTH_ATTACHMENT && pname==GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE && hardext.depthtex==0) {
if(ntarget==GL_FRAMEBUFFER && attachment==GL_DEPTH_ATTACHMENT && pname==GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE && hardext.depthtex==0) {
noerrorShim();
gl4es_glGetFramebufferAttachmentParameteriv(target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, params);
gl4es_glGetFramebufferAttachmentParameteriv(ntarget, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, params);
if (params)
*params = 16; //Depth buffer is 16 on GLES. No check for 24 bits here...
ReadDraw_Pop(target);
return;
}
errorGL();
return gles_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
gles_glGetFramebufferAttachmentParameteriv(ntarget, attachment, pname, params);
ReadDraw_Pop(target);
}
void gl4es_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint * params) {
//printf("glGetRenderbufferParameteriv(%s, %s, %p)\n", PrintEnum(target), PrintEnum(pname), params);
DBG(printf("glGetRenderbufferParameteriv(%s, %s, %p)\n", PrintEnum(target), PrintEnum(pname), params);)
LOAD_GLES_OES(glGetRenderbufferParameteriv);
errorGL();
return gles_glGetRenderbufferParameteriv(target, pname, params);
gles_glGetRenderbufferParameteriv(target, pname, params);
}
void createMainFBO(int width, int height) {
@@ -737,8 +785,8 @@ void gl4es_glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
// glCopyPixel of read FBO
// set viewport / matrixs
// glDraw of write FBO
printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%04X, 0x%04X)\n",
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
DBG(printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%04X, 0x%04X)\n",
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);)
}
// direct wrapper

View File

@@ -179,6 +179,12 @@ void gl4es_glGetIntegerv(GLenum pname, GLint *params) {
case GL_MAX_DRAW_BUFFERS_ARB: // fake...
*params = 1;
break;
case GL_PACK_ALIGNMENT:
*params = glstate->texture.pack_align;
break;
case GL_UNPACK_ALIGNMENT:
*params = glstate->texture.unpack_align;
break;
case GL_UNPACK_ROW_LENGTH:
*params = glstate->texture.unpack_row_length;
break;
@@ -310,39 +316,64 @@ void gl4es_glGetIntegerv(GLenum pname, GLint *params) {
for (dummy=0; dummy<4; dummy++)
params[dummy]=glstate->light.ambient[dummy];
break;
case GL_FOG_MODE:
*params=glstate->fog.mode;
break;
case GL_FOG_DENSITY:
*params=glstate->fog.density;
break;
case GL_FOG_START:
*params=glstate->fog.start;
break;
case GL_FOG_END:
*params=glstate->fog.end;
break;
case GL_FOG_INDEX:
*params=glstate->fog.start;
break;
case GL_FOG_COLOR:
for (dummy=0; dummy<4; dummy++)
params[dummy]=glstate->fog.color[dummy];
break;
case GL_FOG_COORD_SRC:
*params=glstate->fog.coord_src;
break;
case GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB:
*params=hardext.maxsize;
break;
case GL_SHRINK_HINT_GL4ES:
*params=globals4es.texshrink;
break;
case GL_ALPHAHACK_HINT_GL4ES:
case GL_ALPHAHACK_HINT_GL4ES:
*params=globals4es.alphahack;
break;
case GL_RECYCLEFBO_HINT_GL4ES:
case GL_RECYCLEFBO_HINT_GL4ES:
*params=globals4es.recyclefbo;
break;
case GL_MIPMAP_HINT_GL4ES:
case GL_MIPMAP_HINT_GL4ES:
*params=globals4es.automipmap;
break;
case GL_TEXDUMP_HINT_GL4ES:
case GL_TEXDUMP_HINT_GL4ES:
*params=globals4es.texdump;
break;
case GL_COPY_HINT_GL4ES:
case GL_COPY_HINT_GL4ES:
*params=globals4es.copytex;
break;
case GL_NOLUMAPHA_HINT_GL4ES:
case GL_NOLUMAPHA_HINT_GL4ES:
*params=globals4es.nolumalpha;
break;
case GL_BLENDHACK_HINT_GL4ES:
case GL_BLENDHACK_HINT_GL4ES:
*params=globals4es.blendhack;
break;
case GL_BATCH_HINT_GL4ES:
case GL_BATCH_HINT_GL4ES:
*params=globals4es.batch;
break;
case GL_NOERROR_HINT_GL4ES:
case GL_NOERROR_HINT_GL4ES:
*params=globals4es.noerror;
break;
case GL_AVOID16BITS_HINT_GL4ES:
*params=globals4es.avoid16bits;
break;
default:
errorGL();
gles_glGetIntegerv(pname, params);
@@ -370,6 +401,12 @@ void gl4es_glGetFloatv(GLenum pname, GLfloat *params) {
case GL_AUX_BUFFERS:
*params = 0;
break;
case GL_PACK_ALIGNMENT:
*params = glstate->texture.pack_align;
break;
case GL_UNPACK_ALIGNMENT:
*params = glstate->texture.unpack_align;
break;
case GL_UNPACK_ROW_LENGTH:
*params = glstate->texture.unpack_row_length;
break;
@@ -489,6 +526,27 @@ void gl4es_glGetFloatv(GLenum pname, GLfloat *params) {
case GL_LIGHT_MODEL_AMBIENT:
memcpy(params, glstate->light.ambient, 4*sizeof(GLfloat));
break;
case GL_FOG_MODE:
*params=glstate->fog.mode;
break;
case GL_FOG_DENSITY:
*params=glstate->fog.density;
break;
case GL_FOG_START:
*params=glstate->fog.start;
break;
case GL_FOG_END:
*params=glstate->fog.end;
break;
case GL_FOG_INDEX:
*params=glstate->fog.start;
break;
case GL_FOG_COLOR:
memcpy(params, glstate->fog.color, 4*sizeof(GLfloat));
break;
case GL_FOG_COORD_SRC:
*params=glstate->fog.coord_src;
break;
case GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB:
*params=hardext.maxsize;
break;
@@ -531,6 +589,9 @@ void gl4es_glGetFloatv(GLenum pname, GLfloat *params) {
case GL_BEGINEND_HINT_GL4ES:
*params=globals4es.beginend;
break;
case GL_AVOID16BITS_HINT_GL4ES:
*params=globals4es.avoid16bits;
break;
default:
errorGL();
gles_glGetFloatv(pname, params);

View File

@@ -53,6 +53,14 @@ void* NewGLState(void* shared_glstate) {
glvao->array = 0;
glstate->defaultvao = glvao;
}
// initialize gllists
{
khint_t k;
int ret;
khash_t(gllisthead) *list = glstate->headlists = kh_init(gllisthead);
kh_put(gllisthead, list, 1, &ret);
kh_del(gllisthead, list, 1);
}
// Bind defaults...
glstate->vao = glstate->defaultvao;
@@ -64,6 +72,10 @@ void* NewGLState(void* shared_glstate) {
glstate->raster.raster_zoomx=1.0f;
glstate->raster.raster_zoomy=1.0f;
// pack & unpack alignment
glstate->texture.pack_align = 4;
glstate->texture.unpack_align = 4;
// init the matrix tracking
init_matrix(glstate);
@@ -95,7 +107,12 @@ void* NewGLState(void* shared_glstate) {
glstate->material.front.emission[3] = 1.0f;
glstate->material.front.colormat = GL_AMBIENT_AND_DIFFUSE;
memcpy(&glstate->material.back, &glstate->material.front, sizeof(material_t));
// Fog
glstate->fog.mode = GL_EXP;
glstate->fog.density = 1.0f;
glstate->fog.end = 1.0f;
glstate->fog.coord_src = GL_FRAGMENT_DEPTH;
// Raster
for(int i=0; i<4; i++)
glstate->raster.raster_scale[i] = 1.0f;
LOAD_GLES(glGetFloatv);
@@ -117,18 +134,19 @@ void DeleteGLState(void* oldstate) {
glstate = NULL;
#define free_hashmap(T, N, K) \
#define free_hashmap(T, N, K, F) \
{ \
T *m; \
kh_foreach_value(state->N, m, \
free(m); \
F(m); \
) \
kh_destroy(K, state->N); \
}
free_hashmap(glvao_t, vaos, glvao);
free_hashmap(glbuffer_t, buffers, buff);
free_hashmap(glquery_t, queries, queries);
free_hashmap(gltexture_t, texture.list, tex);
free_hashmap(glvao_t, vaos, glvao, free);
free_hashmap(glbuffer_t, buffers, buff, free);
free_hashmap(glquery_t, queries, queries, free);
free_hashmap(gltexture_t, texture.list, tex, free);
free_hashmap(renderlist_t, headlists, gllisthead, free_renderlist);
#undef free_hashmap
// free eval maps
#define freemap(dims, name) \
@@ -143,12 +161,7 @@ void DeleteGLState(void* oldstate) {
freemap(2, vertex3); freemap(2, vertex4); freemap(2, index); freemap(2, color4); freemap(2, normal);
freemap(2, texture1); freemap(2, texture2); freemap(2, texture3); freemap(2, texture4);
#undef freemap
// free lists
if(state->lists) {
for (int i=0; i<state->list.count; i++)
free_renderlist(state->lists[i]);
free(state->lists);
}
// free active list
if(state->list.active) free_renderlist(state->list.active);
// free matrix stack
@@ -192,22 +205,15 @@ void gl_init() {
#endif
static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) {
#define proxy_enable(constant, name) \
#define proxy_GO(constant, name) \
case constant: glstate->enable.name = enable; next(cap); break
#define enable(constant, name) \
#define GO(constant, name) \
case constant: glstate->enable.name = enable; break;
#define proxy_clientenable(constant, name) \
#define proxy_clientGO(constant, name) \
case constant: glstate->vao->name = enable; next(cap); break
#define clientenable(constant, name) \
#define clientGO(constant, name) \
case constant: glstate->vao->name = enable; break;
// TODO: maybe could be weird behavior if someone tried to:
// 1. enable GL_TEXTURE_1D
// 2. enable GL_TEXTURE_2D
// 3. disable GL_TEXTURE_1D
// 4. render. GL_TEXTURE_2D would be disabled.
// cap = map_tex_target(cap);
// Alpha Hack
if (globals4es.alphahack && (cap==GL_ALPHA_TEST) && enable) {
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEX2D])
@@ -223,8 +229,8 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) {
glstate->enable.texture[glstate->texture.active] &= ~(1<<ENABLED_TEX2D);
#endif
switch (cap) {
enable(GL_AUTO_NORMAL, auto_normal);
proxy_enable(GL_BLEND, blend);
GO(GL_AUTO_NORMAL, auto_normal);
proxy_GO(GL_BLEND, blend);
case GL_TEXTURE_2D:
if(enable)
glstate->enable.texture[glstate->texture.active] |= (1<<ENABLED_TEX2D);
@@ -233,24 +239,24 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) {
next(cap);
break;
enable(GL_TEXTURE_GEN_S, texgen_s[glstate->texture.active]);
enable(GL_TEXTURE_GEN_T, texgen_t[glstate->texture.active]);
enable(GL_TEXTURE_GEN_R, texgen_r[glstate->texture.active]);
enable(GL_TEXTURE_GEN_Q, texgen_q[glstate->texture.active]);
enable(GL_LINE_STIPPLE, line_stipple);
GO(GL_TEXTURE_GEN_S, texgen_s[glstate->texture.active]);
GO(GL_TEXTURE_GEN_T, texgen_t[glstate->texture.active]);
GO(GL_TEXTURE_GEN_R, texgen_r[glstate->texture.active]);
GO(GL_TEXTURE_GEN_Q, texgen_q[glstate->texture.active]);
GO(GL_LINE_STIPPLE, line_stipple);
// point sprite
proxy_enable(GL_POINT_SPRITE, pointsprite);
proxy_GO(GL_POINT_SPRITE, pointsprite);
// Secondary color
enable(GL_COLOR_SUM, color_sum);
clientenable(GL_SECONDARY_COLOR_ARRAY, secondary_array);
GO(GL_COLOR_SUM, color_sum);
clientGO(GL_SECONDARY_COLOR_ARRAY, secondary_array);
// for glDrawArrays
clientenable(GL_VERTEX_ARRAY, vertex_array);
clientenable(GL_NORMAL_ARRAY, normal_array);
clientenable(GL_COLOR_ARRAY, color_array);
clientenable(GL_TEXTURE_COORD_ARRAY, tex_coord_array[glstate->texture.client]);
clientGO(GL_VERTEX_ARRAY, vertex_array);
clientGO(GL_NORMAL_ARRAY, normal_array);
clientGO(GL_COLOR_ARRAY, color_array);
clientGO(GL_TEXTURE_COORD_ARRAY, tex_coord_array[glstate->texture.client]);
// Texture 1D and 3D
case GL_TEXTURE_1D:
@@ -282,10 +288,10 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) {
default: errorGL(); next(cap); break;
}
#undef proxy_enable
#undef enable
#undef proxy_clientenable
#undef clientenable
#undef proxy_GO
#undef GO
#undef proxy_clientGO
#undef clientGO
}
int Cap2BatchState(GLenum cap) {
@@ -318,6 +324,11 @@ void gl4es_glEnable(GLenum cap) {
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEX2D]->streamed)
cap = GL_TEXTURE_STREAM_IMG;
}
if (globals4es.texstream && (cap==GL_TEXTURE_RECTANGLE_ARB)) {
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEXTURE_RECTANGLE])
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEXTURE_RECTANGLE]->streamed)
cap = GL_TEXTURE_STREAM_IMG;
}
#endif
LOAD_GLES(glEnable);
proxy_glEnable(cap, true, gles_glEnable);
@@ -337,12 +348,18 @@ void gl4es_glDisable(GLenum cap) {
}
PUSH_IF_COMPILING(glDisable)
#ifdef TEXSTREAM
if (globals4es.texstream && (cap==GL_TEXTURE_2D)) {
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEX2D])
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEX2D]->streamed)
cap = GL_TEXTURE_STREAM_IMG;
}
if (globals4es.texstream && (cap==GL_TEXTURE_RECTANGLE_ARB)) {
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEXTURE_RECTANGLE])
if (glstate->texture.bound[glstate->texture.active][ENABLED_TEXTURE_RECTANGLE]->streamed)
cap = GL_TEXTURE_STREAM_IMG;
}
#endif
LOAD_GLES(glDisable);
proxy_glEnable(cap, false, gles_glDisable);
}
@@ -1051,20 +1068,25 @@ void gl4es_glEnd() {
for (int a=0; a<MAX_TEX; a++)
if (glstate->enable.texture[a] && ((glstate->list.active->tex[a]==0) && !(glstate->enable.texgen_s[a] || glstate->texture.pscoordreplace[a])))
rlMultiTexCoord4f(glstate->list.active, GL_TEXTURE0+a, glstate->texcoord[a][0], glstate->texcoord[a][1], glstate->texcoord[a][2], glstate->texcoord[a][3]);
int withColor = 0;
// render if we're not in a display list
if (!(glstate->list.compiling || glstate->gl_batch) && (!(globals4es.beginend) || (glstate->polygon_mode==GL_LINE))) {
renderlist_t *mylist = glstate->list.active;
withColor = (mylist->color!=NULL);
glstate->list.active = NULL;
mylist = end_renderlist(mylist);
draw_renderlist(mylist);
free_renderlist(mylist);
} else {
if(!(glstate->list.compiling || glstate->gl_batch)) {
withColor = (glstate->list.active->color!=NULL);
glstate->list.pending = 1;
NewStage(glstate->list.active, STAGE_POSTDRAW);
}
else glstate->list.active = extend_renderlist(glstate->list.active);
}
if(withColor)
gl4es_glColor4f(glstate->color[0], glstate->color[1], glstate->color[2], glstate->color[3]);
noerrorShim();
}
void glEnd() AliasExport("gl4es_glEnd");
@@ -1272,9 +1294,12 @@ void glUnlockArraysEXT() AliasExport("gl4es_glUnlockArrays");
// display lists
static renderlist_t *gl4es_glGetList(GLuint list) {
if (glIsList(list))
return glstate->lists[list - 1];
khint_t k;
int ret;
khash_t(gllisthead) *lists = glstate->headlists;
k = kh_get(gllisthead, lists, list);
if (k != kh_end(lists))
return kh_value(lists, k);
return NULL;
}
@@ -1284,18 +1309,18 @@ GLuint gl4es_glGenLists(GLsizei range) {
return 0;
}
noerrorShim();
khint_t k;
int ret;
khash_t(gllisthead) *lists = glstate->headlists;
int start = glstate->list.count;
if (glstate->lists == NULL) {
glstate->list.cap += range + 100;
glstate->lists = malloc(glstate->list.cap * sizeof(uintptr_t));
} else if (glstate->list.count + range > glstate->list.cap) {
glstate->list.cap += range + 100;
glstate->lists = realloc(glstate->lists, glstate->list.cap * sizeof(uintptr_t));
}
glstate->list.count += range;
for (int i = 0; i < range; i++) {
glstate->lists[start+i] = NULL;
k = kh_get(gllisthead, lists, start+i);
if (k == kh_end(lists)){
k = kh_put(gllisthead, lists, start+i, &ret);
kh_value(lists, k) = NULL; // create an empty gllist
}
}
return start + 1;
}
@@ -1306,8 +1331,16 @@ void gl4es_glNewList(GLuint list, GLenum mode) {
errorShim(GL_INVALID_VALUE);
if (list==0)
return;
if (! glIsList(list))
return;
{
khint_t k;
int ret;
khash_t(gllisthead) *lists = glstate->headlists;
k = kh_get(gllisthead, lists, list);
if (k == kh_end(lists)){
k = kh_put(gllisthead, lists, list, &ret);
kh_value(lists, k) = NULL;
}
}
noerrorShim();
if (glstate->gl_batch) {
glstate->gl_batch = 0;
@@ -1324,10 +1357,20 @@ void glNewList(GLuint list, GLenum mode) AliasExport("gl4es_glNewList");
void gl4es_glEndList() {
noerrorShim();
GLuint list = glstate->list.name;
khash_t(gllisthead) *lists = glstate->headlists;
khint_t k;
{
int ret;
k = kh_get(gllisthead, lists, list);
if (k == kh_end(lists)){
k = kh_put(gllisthead, lists, list, &ret);
kh_value(lists, k) = NULL;
}
}
if (glstate->list.compiling) {
// Free the previous list if it exist...
free_renderlist(glstate->lists[list - 1]);
glstate->lists[list - 1] = GetFirst(glstate->list.active);
free_renderlist(kh_value(lists, k));
kh_value(lists, k) = GetFirst(glstate->list.active);
glstate->list.compiling = false;
end_renderlist(glstate->list.active);
glstate->list.active = NULL;
@@ -1403,13 +1446,19 @@ void gl4es_glDeleteList(GLuint list) {
if(glstate->gl_batch) {
flush();
}
renderlist_t *l = gl4es_glGetList(list);
if (l) {
free_renderlist(l);
glstate->lists[list-1] = NULL;
renderlist_t *gllist = NULL;
{
khint_t k;
int ret;
khash_t(gllisthead) *lists = glstate->headlists;
k = kh_get(gllisthead, lists, list);
renderlist_t *gllist = NULL;
if (k != kh_end(lists)){
gllist = kh_value(lists, k);
free_renderlist(gllist);
kh_del(gllisthead, lists, k);
}
}
// lists just grow upwards, maybe use a better storage mechanism?
}
void gl4es_glDeleteLists(GLuint list, GLsizei range) {
@@ -1428,9 +1477,12 @@ void glListBase(GLuint base) AliasExport("gl4es_glListBase");
GLboolean gl4es_glIsList(GLuint list) {
noerrorShim();
if (list - 1 < glstate->list.count) {
khint_t k;
int ret;
khash_t(gllisthead) *lists = glstate->headlists;
k = kh_get(gllisthead, lists, list);
if (k != kh_end(lists))
return true;
}
return false;
}
GLboolean glIsList(GLuint list) AliasExport("gl4es_glIsList");
@@ -1463,122 +1515,6 @@ void gl4es_glPolygonMode(GLenum face, GLenum mode) {
}
void glPolygonMode(GLenum face, GLenum mode) AliasExport("gl4es_glPolygonMode");
void gl4es_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
PUSH_IF_COMPILING(glBlendColor);
LOAD_GLES_OES(glBlendColor);
if (gles_glBlendColor)
gles_glBlendColor(red, green, blue, alpha);
else {
static int test = 1;
if (test) {
LOGD("stub glBlendColor(%f, %f, %f, %f)\n", red, green, blue, alpha);
test = 0;
}
}
}
void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void glBlendColorEXT(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void glBlendColorARB(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) AliasExport("gl4es_glBlendColor");
void gl4es_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
{
PUSH_IF_COMPILING(glBlendFuncSeparate);
LOAD_GLES_OES(glBlendFuncSeparate);
#ifdef ODROID
if(gles_glBlendFuncSeparate)
#endif
gles_glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
void glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) AliasExport("gl4es_glBlendFuncSeparate");
void glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) AliasExport("gl4es_glBlendFuncSeparate");
void gl4es_glBlendEquationSeparate(GLenum modeRGB, GLenum modeA) {
PUSH_IF_COMPILING(glBlendEquationSeparate);
LOAD_GLES_OES(glBlendEquationSeparate);
#ifdef ODROID
if(gles_glBlendEquationSeparate)
#endif
gles_glBlendEquationSeparate(modeRGB, modeA);
}
void glBlendEquationSeparate(GLenum modeRGB, GLenum modeA) AliasExport("gl4es_glBlendEquationSeparate");
void glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) AliasExport("gl4es_glBlendEquationSeparate");
void gl4es_glBlendFunc(GLenum sfactor, GLenum dfactor) {
if (glstate->list.active)
if (!glstate->list.compiling && glstate->gl_batch) {
if ((glstate->statebatch.blendfunc_s == sfactor) && (glstate->statebatch.blendfunc_d == dfactor))
return; // nothing to do...
if (!glstate->statebatch.blendfunc_s) {
glstate->statebatch.blendfunc_s = sfactor;
glstate->statebatch.blendfunc_d = dfactor;
}
}
PUSH_IF_COMPILING(glBlendFunc)
LOAD_GLES(glBlendFunc);
LOAD_GLES_OES(glBlendFuncSeparate);
errorGL();
// There are some limitations in GLES1.1 Blend functions
switch(sfactor) {
case GL_SRC_COLOR:
if (gles_glBlendFuncSeparate) {
gles_glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
return;
}
sfactor = GL_ONE; // approx...
break;
case GL_ONE_MINUS_SRC_COLOR:
if (gles_glBlendFuncSeparate) {
gles_glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
return;
}
sfactor = GL_ONE; // not sure it make sense...
break;
// here, we need support for glBlendColor...
case GL_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
sfactor = GL_ONE;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_ALPHA:
sfactor = GL_ZERO;
break;
default:
break;
}
switch(dfactor) {
case GL_DST_COLOR:
sfactor = GL_ONE; // approx...
break;
case GL_ONE_MINUS_DST_COLOR:
sfactor = GL_ZERO; // not sure it make sense...
break;
// here, we need support for glBlendColor...
case GL_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
sfactor = GL_ONE;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_ALPHA:
sfactor = GL_ZERO;
break;
default:
break;
}
if ((globals4es.blendhack) && (sfactor==GL_SRC_ALPHA) && (dfactor==GL_ONE)) {
// special case, as seen in Xash3D, but it breaks torus_trooper, so behind a parameter
sfactor = GL_ONE;
}
#ifdef ODROID
if(gles_glBlendFunc)
#endif
gles_glBlendFunc(sfactor, dfactor);
}
void glBlendFunc(GLenum sfactor, GLenum dfactor) AliasExport("gl4es_glBlendFunc");
void gl4es_glStencilMaskSeparate(GLenum face, GLuint mask) {
// fake function..., call it only for front or front_and_back, just ignore back (crappy, I know)
@@ -1647,21 +1583,6 @@ void gl4es_glFinish() {
}
void glFinish() AliasExport("gl4es_glFinish");
void gl4es_glFogfv(GLenum pname, const GLfloat* params) {
if (glstate->list.active)
if (glstate->list.compiling || glstate->gl_batch) {
NewStage(glstate->list.active, STAGE_FOG);
rlFogOp(glstate->list.active, pname, params);
return;
}
else flush();
LOAD_GLES(glFogfv);
gles_glFogfv(pname, params);
}
void glFogfv(GLenum pname, const GLfloat* params) AliasExport("gl4es_glFogfv");
void gl4es_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer) {
static bool warning = false;
if(!warning) {

View File

@@ -369,6 +369,7 @@ static inline const GLboolean valid_vertex_type(GLenum type) {
#include "texture.h"
#include "array.h"
#include "framebuffers.h"
#include "blend.h"
const GLubyte *gl4es_glGetString(GLenum name);
void gl4es_glGetIntegerv(GLenum pname, GLint *params);
@@ -415,10 +416,6 @@ void gl4es_glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, cons
void gl4es_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer);
void gl4es_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer);
void gl4es_glGetPointerv(GLenum pname, GLvoid* *params);
void gl4es_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void gl4es_glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
void gl4es_glBlendEquationSeparate(GLenum modeRGB, GLenum modeA);
void gl4es_glBlendFunc(GLenum sfactor, GLenum dfactor);
void gl4es_glFlush();
void gl4es_glFinish();
void gl4es_glFogfv(GLenum pname, const GLfloat* params);

View File

@@ -89,6 +89,12 @@ void gl4es_glHint(GLenum pname, GLenum mode) {
globals4es.beginend = mode;
else
errorShim(GL_INVALID_ENUM);
case GL_AVOID16BITS_HINT_GL4ES:
if (mode<=1)
globals4es.avoid16bits = mode;
else
errorShim(GL_INVALID_ENUM);
break;
default:
errorGL();
gles_glHint(pname, mode);

View File

@@ -86,14 +86,14 @@ void initialize_gl4es() {
}
if (env_fb && strcmp(env_fb, "2") == 0) {
SHUT(LOGD("LIBGL: using framebuffer + fbo\n"));
globals4es.usefb = true;
globals4es.usefbo = true;
globals4es.usefb = 1;
globals4es.usefbo = 1;
}
#ifndef ANDROID
if (env_fb && strcmp(env_fb, "3") == 0) {
SHUT(LOGD("LIBGL: using pbuffer\n"));
globals4es.usefb = 1;
globals4es.usepbuffer = true;
globals4es.usepbuffer = 1;
}
#endif
env(LIBGL_FPS, globals4es.showfps, "fps counter enabled");
@@ -283,6 +283,7 @@ void initialize_gl4es() {
SHUT(LOGD("LIBGL: Try hard to merge subsequent glBegin/glEnd blocks, even if there is a glColor / glNormal or Matrix operations in between\n"));
}
}
env(LIBGL_AVOID16BITS, globals4es.avoid16bits, "Avoid 16bits textures");
char cwd[1024];
if (getcwd(cwd, sizeof(cwd))!= NULL)

View File

@@ -41,6 +41,7 @@ typedef struct _globals4es {
int texmat;
int novaocache;
int beginend;
int avoid16bits;
char version[50];
} globals4es_t;

View File

@@ -173,16 +173,23 @@ void gl4es_glLightf(GLenum light, GLenum pname, const GLfloat params) {
}
void gl4es_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) {
ERROR_IN_BEGIN // that not true, but don't know how to handle it
if(glstate->list.active)
if (glstate->list.compiling || glstate->gl_batch) {
//TODO: Materialfv can be done per vertex, how to handle that ?!
//NewStage(glstate->list.active, STAGE_MATERIAL);
rlMaterialfv(glstate->list.active, face, pname, params);
noerrorShim();
return;
} else flush();
if(glstate->list.begin) {
// if a glMaterialfv is called inside a glBegin/glEnd block
// then use rlMaterial to store in current list the material wanted
// as if the material was asked before the glBegin()
// It's not real behavour, but it's better then nothing
rlMaterialfv(glstate->list.active, face, pname, params);
noerrorShim();
return;
} else {
if (glstate->list.compiling || glstate->gl_batch) {
NewStage(glstate->list.active, STAGE_MATERIAL);
rlMaterialfv(glstate->list.active, face, pname, params);
noerrorShim();
return;
} else flush();
}
if(face!=GL_FRONT_AND_BACK && face!=GL_FRONT && face!=GL_BACK) {
errorShim(GL_INVALID_ENUM);
return;

View File

@@ -500,7 +500,7 @@ renderlist_t* append_calllist(renderlist_t *list, renderlist_t *a)
a->shared_indices = (int*)malloc(sizeof(int));
*a->shared_indices = 0;
}
if(a->calls.cap && !a->shared_calls) {
if(a->calls.len && !a->shared_calls) {
a->shared_calls = (int*)malloc(sizeof(int));
*a->shared_calls = 0;
}
@@ -523,7 +523,7 @@ renderlist_t* append_calllist(renderlist_t *list, renderlist_t *a)
}
}
}
if (list->calls.cap > 0) {
if (list->calls.len > 0) {
++(*list->shared_calls);
/*
list->calls.calls = (packed_call_t**)malloc(sizeof(packed_call_t*)*a->calls.cap);
@@ -548,7 +548,6 @@ renderlist_t* append_calllist(renderlist_t *list, renderlist_t *a)
if(list->len) {
++(*list->shared_arrays);
}
#undef PROCESS
if(list->ilen) {
++(*list->shared_indices);
}
@@ -603,7 +602,7 @@ void free_renderlist(renderlist_t *list) {
renderlist_t *next;
do {
if ((list->calls.cap > 0) && (!list->shared_calls || ((*list->shared_calls)--)==0)) {
if ((list->calls.len > 0) && (!list->shared_calls || ((*list->shared_calls)--)==0)) {
if(list->shared_calls) free(list->shared_calls);
for (int i = 0; i < list->calls.len; i++) {
free(list->calls.calls[i]);
@@ -971,11 +970,11 @@ void draw_renderlist(renderlist_t *list) {
static GLfloat *texgened[MAX_TEX] = {0};
static int texgenedsz[MAX_TEX] = {0};
int use_texgen[MAX_TEX] = {0};
#define TEXTURE(A) if (cur_tex!=A) {gl4es_glClientActiveTexture(A+GL_TEXTURE0); cur_tex=A;}
old_tex = glstate->texture.client;
GLuint cur_tex = old_tex;
#define RS(A, len) if(texgenedsz[A]<len) {free(texgened[A]); texgened[A]=malloc(4*sizeof(GLfloat)*len); texgenedsz[A]=len; } use_texgen[A]=1
GLint needclean[MAX_TEX] = {0};
#define TEXTURE(A) if (cur_tex!=A) {gl4es_glClientActiveTexture(A+GL_TEXTURE0); cur_tex=A;}
#define RS(A, len) if(texgenedsz[A]<len) {free(texgened[A]); texgened[A]=malloc(4*sizeof(GLfloat)*len); texgenedsz[A]=len; } use_texgen[A]=1
for (int a=0; a<hardext.maxtex; a++) {
if(glstate->enable.texture[a]) {
const GLint itarget = get_target(glstate->enable.texture[a]);
@@ -1003,9 +1002,6 @@ void draw_renderlist(renderlist_t *list) {
}
}
}
}
#undef RS
for (int a=0; a<hardext.maxtex; a++) {
if ((list->tex[a] || (use_texgen[a] && !needclean[a]))/* && glstate->enable.texture[a]*/) {
TEXTURE(a);
if(!glstate->clientstate.tex_coord_array[a]) {
@@ -1028,7 +1024,8 @@ void draw_renderlist(renderlist_t *list) {
}
}
if (glstate->texture.client != old_tex) TEXTURE(old_tex);
#undef TEXTURE
#undef RS
#undef TEXTURE
GLenum mode;
mode = list->mode;
if ((glstate->polygon_mode == GL_LINE) && (mode>=GL_TRIANGLES))

View File

@@ -7,7 +7,6 @@ typedef enum {
STAGE_NONE = 0,
STAGE_PUSH,
STAGE_POP,
STAGE_CALLLIST,
STAGE_GLCALL,
STAGE_RENDER,
STAGE_FOG,
@@ -33,7 +32,6 @@ static int StageExclusive[] = {
0, // STAGE_NONE
1, // STAGE_PUSH
1, // STAGE_POP
1, // STAGE_CALLLIST
0, // STAGE_GLCALL
1, // STAGE_RENDER
1, // STAGE_FOG
@@ -182,6 +180,8 @@ typedef struct _renderlist_t {
GLboolean open;
} renderlist_t;
KHASH_MAP_INIT_INT(gllisthead, renderlist_t*)
#define DEFAULT_CALL_LIST_CAPACITY 20
#define DEFAULT_RENDER_LIST_CAPACITY 64

View File

@@ -30,6 +30,17 @@ void *open_lib(const char **names, const char *override);
WARN_NULL(lib##_##name); \
} \
}
#define LOAD_RAW_SILENT(lib, name, ...) \
{ \
static bool first = true; \
if (first) { \
first = false; \
if (lib != NULL) { \
lib##_##name = (name##_PTR)__VA_ARGS__; \
} \
} \
}
#endif
#define LOAD_LIB(lib, name) DEFINE_RAW(lib, name); LOAD_RAW(lib, name, dlsym(lib, #name))
@@ -55,4 +66,11 @@ void *open_lib(const char **names, const char *override);
LOAD_RAW(gles, name, egl_eglGetProcAddress(#name"EXT")); \
}
#define LOAD_GLES_OR_OES(name) \
DEFINE_RAW(gles, name); \
{ \
LOAD_EGL(eglGetProcAddress); \
LOAD_RAW_SILENT(gles, name, (egl_eglGetProcAddress(#name"OES")!=NULL)?(void*)egl_eglGetProcAddress(#name"OES"):(void*)dlsym(gles, #name)); \
}
#endif

View File

@@ -656,12 +656,17 @@ bool quarter_pixel(const GLvoid *src[16],
bool pixel_convert(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
GLenum dst_format, GLenum dst_type, GLuint stride) {
GLenum dst_format, GLenum dst_type, GLuint stride, GLuint align) {
const colorlayout_t *src_color, *dst_color;
GLuint pixels = width * height;
GLuint dst_size = pixels * pixel_sizeof(dst_format, dst_type);
GLuint dst_width = ((stride?stride:width) - width) * pixel_sizeof(dst_format, dst_type);
GLuint src_width = width * pixel_sizeof(src_format, src_type);
if(src_type==GL_UNSIGNED_INT_8_8_8_8_REV) src_type=GL_UNSIGNED_BYTE;
if(dst_type==GL_UNSIGNED_INT_8_8_8_8_REV) dst_type=GL_UNSIGNED_BYTE;
GLuint dst_size = height * widthalign(width*pixel_sizeof(dst_format, dst_type), align);
GLuint dst_width2 = widthalign((stride?stride:width) * pixel_sizeof(dst_format, dst_type), align);
GLuint dst_width = dst_width2 - (width * pixel_sizeof(dst_format, dst_type));
GLuint src_width = widthalign(width * pixel_sizeof(src_format, src_type), align);
GLuint src_widthadj = src_width -(width * pixel_sizeof(src_format, src_type));
//printf("pixel conversion: %ix%i - %s, %s (%d) ==> %s, %s (%d), transform=%i\n", width, height, PrintEnum(src_format), PrintEnum(src_type),pixel_sizeof(src_format, src_type), PrintEnum(dst_format), PrintEnum(dst_type), pixel_sizeof(dst_format, dst_type), raster_need_transform());
src_color = get_color_map(src_format);
@@ -679,7 +684,7 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
*dst = malloc(dst_size);
if (stride) // for in-place conversion
for (int yy=0; yy<height; yy++)
memcpy((*dst)+yy*(dst_width+src_width), src+yy*src_width, src_width);
memcpy((*dst)+yy*dst_width2, src+yy*src_width, src_width);
else
memcpy(*dst, src, dst_size);
return true;
@@ -694,7 +699,7 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
// TODO: Rewrite that with some Macro, it's obviously doable to simplify the reading (and writting) of all this
// simple BGRA <-> RGBA / UNSIGNED_BYTE
if ((((src_format == GL_BGRA) && (dst_format == GL_RGBA)) || ((src_format == GL_RGBA) && (dst_format == GL_BGRA)))
&& (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
&& (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -703,8 +708,8 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
@@ -721,13 +726,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGBA -> LA
if ((src_format == GL_RGBA) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_RGBA) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -737,13 +742,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGRA -> LA
if ((src_format == GL_BGRA) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_BGRA) && (dst_format == GL_LUMINANCE_ALPHA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -753,13 +758,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGB(A) -> L
if (((src_format == GL_RGBA)||(src_format == GL_RGB)) && (dst_format == GL_LUMINANCE) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_RGBA)||(src_format == GL_RGB)) && (dst_format == GL_LUMINANCE) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -769,13 +774,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGR(A) -> L
if (((src_format == GL_BGRA)||(src_format == GL_BGR)) && (dst_format == GL_LUMINANCE) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_BGRA)||(src_format == GL_BGR)) && (dst_format == GL_LUMINANCE) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
@@ -785,13 +790,13 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGR(A) -> RGB
if (((src_format == GL_BGR)||(src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_BGR)||(src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
((char*)dst_pos)[0] = ((char*)src_pos)[2];
@@ -800,13 +805,29 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGR -> RGBA
if (((src_format == GL_BGR)) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
((char*)dst_pos)[0] = ((char*)src_pos)[2];
((char*)dst_pos)[1] = ((char*)src_pos)[1];
((char*)dst_pos)[2] = ((char*)src_pos)[0];
((char*)dst_pos)[3] = 255;
src_pos += src_stride;
dst_pos += dst_stride;
}
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGBA -> RGB
if ((src_format == GL_RGBA) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_RGBA) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
((char*)dst_pos)[0] = ((char*)src_pos)[0];
@@ -815,86 +836,86 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGB(A) -> RGB565
if (((src_format == GL_RGB)||(src_format == GL_RGBA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_RGB)||(src_format == GL_RGBA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[2]&0xf8)>>(3)) | ((GLushort)(((char*)src_pos)[1]&0xfc)<<(5-2)) | ((GLushort)(((char*)src_pos)[0]&0xf8)<<(11-3));
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGR(A) -> RGB565
if (((src_format == GL_BGR) || (src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if (((src_format == GL_BGR) || (src_format == GL_BGRA)) && (dst_format == GL_RGB) && (dst_type == GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[0]&0xf8)>>(3)) | ((GLushort)(((char*)src_pos)[1]&0xfc)<<(5-2)) | ((GLushort)(((char*)src_pos)[2]&0xf8)<<(11-3));
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGBA -> RGBA5551
if ((src_format == GL_RGBA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_5_5_5_1) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_RGBA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_5_5_5_1) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[2]&0xf8)>>(3-1)) | ((GLushort)(((char*)src_pos)[1]&0xf8)<<(5-2)) | ((GLushort)(((char*)src_pos)[0]&0xf8)<<(10-2)) | ((GLushort)(((char*)src_pos)[3])>>15);
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGRA -> RGBA5551
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_5_5_5_1) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_5_5_5_1) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[0]&0xf8)>>(3-1)) | ((GLushort)(((char*)src_pos)[1]&0xf8)<<(5-2)) | ((GLushort)(((char*)src_pos)[2]&0xf8)<<(10-2)) | ((GLushort)(((char*)src_pos)[3])>>15);
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// RGBA -> RGBA4444
if ((src_format == GL_RGBA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_4_4_4_4) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_RGBA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_4_4_4_4) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[3]&0xf0))>>(4) | ((GLushort)(((char*)src_pos)[2]&0xf0)) | ((GLushort)(((char*)src_pos)[1]&0xf0))<<(4) | ((GLushort)(((char*)src_pos)[0]&0xf0))<<(8);
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
// BGRA -> RGBA4444
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_4_4_4_4) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_SHORT_4_4_4_4) && ((src_type == GL_UNSIGNED_BYTE))) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
*(GLushort*)dst_pos = ((GLushort)(((char*)src_pos)[3]&0xf0)>>(4)) | ((GLushort)(((char*)src_pos)[0]&0xf0)) | ((GLushort)(((char*)src_pos)[1]&0xf0)<<(4)) | ((GLushort)(((char*)src_pos)[2]&0xf0)<<(8));
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
@@ -910,8 +931,8 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
@@ -927,8 +948,8 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
@@ -944,8 +965,8 @@ bool pixel_convert(const GLvoid *src, GLvoid **dst,
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width;
dst_pos += dst_width;
src_pos += src_widthadj;
}
return true;
}
@@ -1165,7 +1186,8 @@ bool pixel_doublescale(const GLvoid *old, GLvoid **new,
}
bool pixel_to_ppm(const GLvoid *pixels, GLuint width, GLuint height,
GLenum format, GLenum type, GLuint name) {
GLenum format, GLenum type, GLuint name, GLuint align) {
// this function should be redone, using write_png from STB for example
if (! pixels)
return false;
@@ -1175,7 +1197,7 @@ bool pixel_to_ppm(const GLvoid *pixels, GLuint width, GLuint height,
if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
src = (GLvoid*)pixels;
} else {
if (! pixel_convert(pixels, (GLvoid **)&src, width, height, format, type, GL_RGB, GL_UNSIGNED_BYTE, 0)) {
if (! pixel_convert(pixels, (GLvoid **)&src, width, height, format, type, GL_RGB, GL_UNSIGNED_BYTE, 0, align)) {
return false;
}
}

View File

@@ -12,10 +12,12 @@ typedef struct {
GLfloat r, g, b, a;
} pixel_t;
#define widthalign(width, align) ((width+(align-1))&(~(align-1)))
bool pixel_convert(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
GLenum dst_format, GLenum dst_type, GLuint stride);
GLenum dst_format, GLenum dst_type, GLuint stride, GLuint align);
bool pixel_transform(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
@@ -45,6 +47,6 @@ bool pixel_doublescale(const GLvoid *src, GLvoid **dst,
bool pixel_to_ppm(const GLvoid *pixels,
GLuint width, GLuint height,
GLenum format, GLenum type, GLuint name);
GLenum format, GLenum type, GLuint name, GLuint align);
#endif

View File

@@ -343,7 +343,7 @@ void gl4es_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
GLsizei bmp_width = (glstate->texture.unpack_row_length)?glstate->texture.unpack_row_length:width;
if (! pixel_convert(data, &dst, bmp_width, height,
format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0)) {
format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0, 1)) { // pack_align is forced to 1 when drawing
return;
}

View File

@@ -8,6 +8,7 @@
#include "buffers.h"
#include "queries.h"
#include "light.h"
#include "fog.h"
typedef struct _glstack_t glstack_t;
typedef struct _glclientstack_t glclientstack_t;
@@ -51,6 +52,8 @@ typedef struct {
pack_skip_pixels,
pack_skip_rows,
pack_image_height;
GLuint pack_align,
unpack_align;
GLboolean pack_lsb_first;
gltexture_t *bound[MAX_TEX][ENABLED_TEXTURE_LAST];
GLboolean pscoordreplace[MAX_TEX];
@@ -158,7 +161,7 @@ typedef struct {
enable_state_t enable;
map_state_t *map_grid;
map_states_t map1, map2;
renderlist_t **lists;
khash_t(gllisthead) *headlists;
texgen_state_t texgen[MAX_TEX];
texture_state_t texture;
GLfloat color[4];
@@ -193,6 +196,7 @@ typedef struct {
int emulatedWin;
int shared_cnt;
light_state_t light;
fog_t fog;
material_state_t material;
int immediateMV;
} glstate_t;

View File

@@ -167,12 +167,12 @@ void sphere_loop(const GLfloat *verts, const GLfloat *norm, GLfloat *out, GLint
matrix_vector(ModelviewMatrix, verts+k*4, eye);
vector4_normalize(eye);
vector3_matrix((norm)?(norm+k*3):glstate->normal, InvModelview, eye_norm);
vector4_normalize(eye_norm);
a=dot4(eye, eye_norm)*2.0f;
for (int j=0; j<4; j++)
vector_normalize(eye_norm);
a=dot(eye, eye_norm)*2.0f;
for (int j=0; j<3; j++)
reflect[j]=eye[j]-eye_norm[j]*a;
reflect[2]+=1.0f;
a = 0.5f / sqrtf(dot4(reflect, reflect));
a = 0.5f / sqrtf(dot(reflect, reflect));
out[k*4+0] = reflect[0]*a + 0.5f;
out[k*4+1] = reflect[1]*a + 0.5f;
out[k*4+2] = 0.0f;

View File

@@ -300,7 +300,7 @@ static void *swizzle_texture(GLsizei width, GLsizei height,
if (convert) {
GLvoid *pixels = (GLvoid *)data;
if (! pixel_convert(data, &pixels, width, height,
*format, *type, dest_format, dest_type, 0)) {
*format, *type, dest_format, dest_type, 0, glstate->texture.unpack_align)) {
printf("LIBGL: swizzle error: (%s, %s -> %s, %s)\n",
PrintEnum(*format), PrintEnum(*type), PrintEnum(dest_format), PrintEnum(dest_type));
return NULL;
@@ -311,7 +311,7 @@ static void *swizzle_texture(GLsizei width, GLsizei height,
GLvoid *pix2 = (GLvoid *)pixels;
internal2format_type(internalformat, &dest_format, &dest_type);
if (! pixel_convert(pixels, &pix2, width, height,
*format, *type, dest_format, dest_type, 0)) {
*format, *type, dest_format, dest_type, 0, glstate->texture.unpack_align)) {
printf("LIBGL: swizzle error: (%s, %s -> %s, %s)\n",
PrintEnum(dest_format), PrintEnum(dest_type), PrintEnum(internalformat), PrintEnum(dest_type));
return NULL;
@@ -346,7 +346,7 @@ static void *swizzle_texture(GLsizei width, GLsizei height,
return (void *)data;
}
GLenum swizzle_internalformat(GLenum *internalformat, GLenum format) {
GLenum swizzle_internalformat(GLenum *internalformat, GLenum format, GLenum type) {
GLenum ret = *internalformat;
GLenum sret;
switch(*internalformat) {
@@ -365,8 +365,12 @@ GLenum swizzle_internalformat(GLenum *internalformat, GLenum format) {
case GL_RGB5:
sret = GL_RGB5;
break;
case GL_RGB8:
case GL_RGB:
if(globals4es.avoid16bits==0 && format==GL_RGB && type==GL_UNSIGNED_SHORT_5_6_5) {
sret = ret = GL_RGB5;
break;
}
case GL_RGB8:
case GL_BGR:
case GL_RGB16:
case GL_RGB16F:
@@ -381,6 +385,14 @@ GLenum swizzle_internalformat(GLenum *internalformat, GLenum format) {
sret = GL_RGB5_A1;
break;
case GL_RGBA:
if(globals4es.avoid16bits==0 && format==GL_RGBA && type==GL_UNSIGNED_SHORT_5_5_5_1) {
sret = ret = GL_RGB5_A1;
break;
}
if(globals4es.avoid16bits==0 && format==GL_RGBA && type==GL_UNSIGNED_SHORT_4_4_4_4) {
sret = ret = GL_RGBA4;
break;
}
case GL_RGBA8:
case GL_RGBA16:
case GL_RGBA16F:
@@ -564,20 +576,21 @@ void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat,
if (globals4es.texshrink>=8 && max1>8192) max1=8192;
proxy_width = ((width<<level)>max1)?0:width;
proxy_height = ((height<<level)>max1)?0:height;
proxy_intformat = swizzle_internalformat(&internalformat, format);
proxy_intformat = swizzle_internalformat(&internalformat, format, type);
return;
}
//PUSH_IF_COMPILING(glTexImage2D);
GLuint old_glbatch = glstate->gl_batch;
if (glstate->gl_batch || glstate->list.pending) {
flush();
glstate->gl_batch = 0;
} else {
PUSH_IF_COMPILING(glTexImage2D);
}
GLvoid *datab = (GLvoid*)data;
if (glstate->vao->unpack)
datab += (uintptr_t)glstate->vao->pack->data;
datab += (uintptr_t)glstate->vao->unpack->data;
GLvoid *pixels = (GLvoid *)datab;
border = 0; //TODO: something?
@@ -594,7 +607,7 @@ void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat,
else
bound->mipmap_need = 1;
}
GLenum new_format = swizzle_internalformat(&internalformat, format);
GLenum new_format = swizzle_internalformat(&internalformat, format, type);
if (bound && (level==0)) {
bound->orig_internal = internalformat;
bound->internalformat = new_format;
@@ -675,7 +688,7 @@ void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat,
if (globals4es.texdump) {
if (bound) {
pixel_to_ppm(pixels, width, height, format, type, bound->texture);
pixel_to_ppm(pixels, width, height, format, type, bound->texture, glstate->texture.pack_align);
}
}
} else {
@@ -861,7 +874,7 @@ void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat,
else
bound->data = malloc(width*height*4);
if (datab) {
if (!pixel_convert(pixels, &bound->data, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0))
if (!pixel_convert(pixels, &bound->data, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0, glstate->texture.pack_align))
printf("LIBGL: Error on pixel_convert when TEXCOPY in glTexImage2D\n");
} else {
//memset(bound->data, 0, width*height*4);
@@ -877,16 +890,17 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
GLsizei width, GLsizei height, GLenum format, GLenum type,
const GLvoid *data) {
//PUSH_IF_COMPILING(glTexSubImage2D);
GLuint old_glbatch = glstate->gl_batch;
if (glstate->gl_batch || glstate->list.pending) {
flush();
glstate->gl_batch = 0;
} else {
PUSH_IF_COMPILING(glTexSubImage2D);
}
GLvoid *datab = (GLvoid*)data;
if (glstate->vao->unpack)
datab += (uintptr_t)glstate->vao->pack->data;
datab += (uintptr_t)glstate->vao->unpack->data;
GLvoid *pixels = (GLvoid*)datab;
const GLuint itarget = what_target(target);
@@ -944,7 +958,7 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
GLvoid *tmp = GetStreamingBuffer(bound->streamingID);
tmp += (yoffset*bound->width+xoffset)*2;
if (! pixel_convert(old, &tmp, width, height,
format, type, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, bound->width)) {
format, type, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, bound->width, glstate->texture.pack_align)) {
printf("LIBGL: swizzle error: (%#4x, %#4x -> GL_RGB, UNSIGNED_SHORT_5_6_5)\n",
format, type);
}
@@ -956,7 +970,7 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
//pixels = (GLvoid *)swizzle_texture(width, height, &format, &type, old);
GLenum dest_format, dest_type;
internal2format_type(orig_internal, &dest_format, &dest_type);
if (!pixel_convert(old, &pixels, width, height, format, type, dest_format, dest_type, 0)) {
if (!pixel_convert(old, &pixels, width, height, format, type, dest_format, dest_type, 0, glstate->texture.pack_align)) {
printf("LIBGL: Error in pixel_convert while glTexSubImage2D\n");
} else {
format = dest_format;
@@ -964,7 +978,7 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
if(orig_internal!=internalformat) {
GLvoid* pix2 = pixels;
internal2format_type(internalformat, &dest_format, &dest_type);
if (!pixel_convert(pixels, &pix2, width, height, format, type, dest_format, dest_type, 0)) {
if (!pixel_convert(pixels, &pix2, width, height, format, type, dest_format, dest_type, 0, glstate->texture.pack_align)) {
printf("LIBGL: Error in pixel_convert while glTexSubImage2D\n");
}
if (pixels != pix2 && pixels != old)
@@ -1009,7 +1023,7 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
if (globals4es.texdump) {
if (bound) {
pixel_to_ppm(pixels, width, height, format, type, bound->texture);
pixel_to_ppm(pixels, width, height, format, type, bound->texture, glstate->texture.pack_align);
}
}
@@ -1082,7 +1096,7 @@ void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff
//printf("*texcopy* glTexSubImage2D, xy=%i,%i, size=%i,%i=>%i,%i, format=%s, type=%s, tex=%u\n", xoffset, yoffset, width, height, bound->width, bound->height, PrintEnum(format), PrintEnum(type), bound->glname);
GLvoid * tmp = bound->data;
tmp += (yoffset*bound->width + xoffset)*4;
if (!pixel_convert(pixels, &tmp, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE, bound->width))
if (!pixel_convert(pixels, &tmp, width, height, format, type, GL_RGBA, GL_UNSIGNED_BYTE, bound->width, glstate->texture.pack_align))
printf("LIBGL: Error on pixel_convert while TEXCOPY in glTexSubImage2D\n");
}
@@ -1152,45 +1166,62 @@ void gl4es_glPixelStorei(GLenum pname, GLint param) {
switch (pname) {
case GL_UNPACK_ROW_LENGTH:
glstate->texture.unpack_row_length = param;
break;
return;
case GL_UNPACK_SKIP_PIXELS:
glstate->texture.unpack_skip_pixels = param;
break;
return;
case GL_UNPACK_SKIP_ROWS:
glstate->texture.unpack_skip_rows = param;
break;
return;
case GL_UNPACK_LSB_FIRST:
glstate->texture.unpack_lsb_first = param;
break;
return;
case GL_UNPACK_IMAGE_HEIGHT:
glstate->texture.unpack_image_height = param;
break;
return;
case GL_UNPACK_SWAP_BYTES:
case GL_PACK_SWAP_BYTES:
// Fake... TODO?
//glstate->texture.unpack_lsb_first = param;
break;
return;
case GL_PACK_ROW_LENGTH:
glstate->texture.pack_row_length = param;
break;
return;
case GL_PACK_SKIP_PIXELS:
glstate->texture.pack_skip_pixels = param;
break;
return;
case GL_PACK_SKIP_ROWS:
glstate->texture.pack_skip_rows = param;
break;
return;
case GL_PACK_LSB_FIRST:
glstate->texture.pack_lsb_first = param;
break;
return;
case GL_PACK_IMAGE_HEIGHT:
glstate->texture.pack_image_height = param;
return;
case GL_PACK_ALIGNMENT:
if(glstate->texture.pack_align==param)
return;
if (param!=1 && param!=2 && param!=4 && param!=8) {
errorShim(GL_INVALID_VALUE);
return;
}
glstate->texture.pack_align=param;
break;
default:
errorGL();
gles_glPixelStorei(pname, param);
case GL_UNPACK_ALIGNMENT:
if(glstate->texture.unpack_align==param)
return;
if (param!=1 && param!=2 && param!=4 && param!=8) {
errorShim(GL_INVALID_VALUE);
return;
}
glstate->texture.unpack_align=param;
break;
}
errorGL();
gles_glPixelStorei(pname, param);
}
GLboolean gl4es_glIsTexture(GLuint texture) {
noerrorShim();
if (!texture) {
@@ -1256,7 +1287,7 @@ gltexture_t* gl4es_getTexture(GLenum target, GLuint texture) {
#define batch_activetex (glstate->statebatch.active_tex_changed?(glstate->statebatch.active_tex-GL_TEXTURE0):glstate->texture.active)
void gl4es_glBindTexture(GLenum target, GLuint texture) {
noerrorShim();
//printf("glBindTexture(%s, %u), active=%i, client=%i\n", PrintEnum(target), texture, glstate->texture.active, glstate->texture.client);
//printf("glBindTexture(%s, %u), active=%i, client=%i, list.active=%p (compiling=%d, pending=%d)\n", PrintEnum(target), texture, glstate->texture.active, glstate->texture.client, glstate->list.active, glstate->list.compiling, glstate->list.pending);
if(glstate->list.pending) flush();
if ((target!=GL_PROXY_TEXTURE_2D) && (glstate->list.active && (glstate->gl_batch && !glstate->list.compiling))) {
if ((glstate->statebatch.bound_targ[batch_activetex] == target) && (glstate->statebatch.bound_tex[batch_activetex] == texture))
@@ -1363,6 +1394,7 @@ void gl4es_glTexParameteri(GLenum target, GLenum pname, GLint param) {
case GL_TEXTURE_WRAP_T:
switch (param) {
case GL_CLAMP:
case GL_CLAMP_TO_BORDER:
param = GL_CLAMP_TO_EDGE;
break;
}
@@ -1402,6 +1434,61 @@ void gl4es_glTexParameterf(GLenum target, GLenum pname, GLfloat param) {
gl4es_glTexParameteri(target, pname, param);
}
void gl4es_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params) {
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
case GL_TEXTURE_WRAP_R:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
case GL_TEXTURE_LOD_BIAS:
case GL_GENERATE_MIPMAP:
gl4es_glTexParameteri(target, pname, params[0]);
return;
case GL_TEXTURE_BORDER_COLOR:
// not supported on GLES,
noerrorShim();
return;
}
PUSH_IF_COMPILING(glTexParameterfv);
LOAD_GLES(glTexParameterfv);
errorGL();
const GLuint rtarget = map_tex_target(target);
gles_glTexParameterfv(rtarget, pname, params);
}
void gl4es_glTexParameteriv(GLenum target, GLenum pname, const GLint * params) {
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
case GL_TEXTURE_WRAP_R:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
case GL_TEXTURE_LOD_BIAS:
case GL_GENERATE_MIPMAP:
gl4es_glTexParameteri(target, pname, params[0]);
return;
case GL_TEXTURE_BORDER_COLOR:
// not supported on GLES,
noerrorShim();
return;
}
PUSH_IF_COMPILING(glTexParameteriv);
LOAD_GLES(glTexParameteriv);
errorGL();
const GLuint rtarget = map_tex_target(target);
gles_glTexParameteriv(rtarget, pname, params);
}
void gl4es_glDeleteTextures(GLsizei n, const GLuint *textures) {
if (glstate->gl_batch || glstate->list.pending) flush();
noerrorShim();
@@ -1662,7 +1749,7 @@ void gl4es_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
#ifdef TEXSTREAM
if (globals4es.texstream && bound->streamed) {
noerrorShim();
pixel_convert(GetStreamingBuffer(bound->streamingID), &dst, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format, type, 0);
pixel_convert(GetStreamingBuffer(bound->streamingID), &dst, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format, type, 0, glstate->texture.unpack_align);
readfboEnd();
if (old_glbatch)
glstate->gl_batch=old_glbatch;
@@ -1672,7 +1759,7 @@ void gl4es_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
if (globals4es.texcopydata && bound->data) {
//printf("texcopydata* glGetTexImage(0x%04X, %d, 0x%04x, 0x%04X, %p)\n", target, level, format, type, img);
noerrorShim();
if (!pixel_convert(bound->data, &dst, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0))
if (!pixel_convert(bound->data, &dst, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0, glstate->texture.unpack_align))
printf("LIBGL: Error on pixel_convert while glGetTexImage\n");
} else {
// Setup an FBO the same size of the texture
@@ -1891,7 +1978,7 @@ void gl4es_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
GLvoid *pixels = malloc(width*height*4);
gles_glReadPixels(x, y, width, height, use_bgra?GL_BGRA:GL_RGBA, GL_UNSIGNED_BYTE, pixels);
if (! pixel_convert(pixels, &dst, width, height,
use_bgra?GL_BGRA:GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0)) {
use_bgra?GL_BGRA:GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0,glstate->texture.unpack_align)) {
LOGE("LIBGL: ReadPixels error: (%s, UNSIGNED_BYTE -> %s, %s )\n",
PrintEnum(use_bgra?GL_BGRA:GL_RGBA), PrintEnum(format), PrintEnum(type));
}
@@ -2140,23 +2227,26 @@ void gl4es_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalfor
// automaticaly reduce the pixel size
half=pixels;
bound->alpha = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?false:true;
if(globals4es.nodownsampling==1) {
if(globals4es.nodownsampling==1) { // will be removed soon, avoid16bits is better
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
} else {
format = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_RGB:GL_RGBA;
#ifdef PANDORA
type = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_6_5:(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_5_5_1:GL_UNSIGNED_SHORT_4_4_4_4;
#else
type = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_6_5:GL_UNSIGNED_SHORT_4_4_4_4;
#endif
if (pixel_convert(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0))
fact = 0;
// if (pixel_thirdscale(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE))
// fact = 1;
else {
if(globals4es.avoid16bits) {
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
} else {
format = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_RGB:GL_RGBA;
#ifdef PANDORA
type = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_6_5:(internalformat==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_5_5_1:GL_UNSIGNED_SHORT_4_4_4_4;
#else
type = (internalformat==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)?GL_UNSIGNED_SHORT_5_6_5:GL_UNSIGNED_SHORT_4_4_4_4;
#endif
if (pixel_convert(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0, glstate->texture.pack_align))
fact = 0;
else {
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
}
}
}
bound->format = format; //internalformat;
@@ -2251,7 +2341,7 @@ void gl4es_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
#else
GLenum format = bound->format;
GLenum type = bound->type;
pixel_convert(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0);
pixel_convert(pixels, &half, width, height, GL_RGBA, GL_UNSIGNED_BYTE, format, type, 0, glstate->texture.pack_align);
gl4es_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, half);
#endif
if (half!=pixels)
@@ -2411,6 +2501,8 @@ void glGenTextures(GLsizei n, GLuint * textures) AliasExport("gl4es_glGenTexture
void glDeleteTextures(GLsizei n, const GLuint * textures) AliasExport("gl4es_glDeleteTextures");
void glTexParameteri(GLenum target, GLenum pname, GLint param) AliasExport("gl4es_glTexParameteri");
void glTexParameterf(GLenum target, GLenum pname, GLfloat param) AliasExport("gl4es_glTexParameterf");
void glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params) AliasExport("gl4es_glTexParameterfv");
void glTexParameteriv(GLenum target, GLenum pname, const GLint * params) AliasExport("gl4es_glTexParameteriv");
GLboolean glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences) AliasExport("gl4es_glAreTexturesResident");
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) AliasExport("gl4es_glGetTexLevelParameteriv");
void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * img) AliasExport("gl4es_glGetTexImage");

View File

@@ -55,7 +55,9 @@ void gl4es_glFogiv(GLenum pname, GLint *iparams) {
case GL_FOG_START:
case GL_FOG_END:
case GL_FOG_MODE:
case GL_FOG_INDEX: {
case GL_FOG_INDEX:
case GL_FOG_COORD_SRC:
{
gl4es_glFogf(pname, *iparams);
break;
}

View File

@@ -1580,14 +1580,14 @@ void gl4es_glTexGeni(GLenum coord, GLenum pname, GLint param) {
void glTexGeni(GLenum coord, GLenum pname, GLint param) __attribute__((alias("gl4es_glTexGeni"))) __attribute__((visibility("default")));
#endif
#ifndef skip_glTexImage2D
void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels) {
void gl4es_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data) {
LOAD_GLES(glTexImage2D);
#ifndef direct_glTexImage2D
PUSH_IF_COMPILING(glTexImage2D)
#endif
gles_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
gles_glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
}
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels) __attribute__((alias("gl4es_glTexImage2D"))) __attribute__((visibility("default")));
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data) __attribute__((alias("gl4es_glTexImage2D"))) __attribute__((visibility("default")));
#endif
#ifndef skip_glTexParameterf
void gl4es_glTexParameterf(GLenum target, GLenum pname, GLfloat param) {
@@ -1650,14 +1650,14 @@ void gl4es_glTexParameterxv(GLenum target, GLenum pname, const GLfixed * params)
void glTexParameterxv(GLenum target, GLenum pname, const GLfixed * params) __attribute__((alias("gl4es_glTexParameterxv"))) __attribute__((visibility("default")));
#endif
#ifndef skip_glTexSubImage2D
void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels) {
void gl4es_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data) {
LOAD_GLES(glTexSubImage2D);
#ifndef direct_glTexSubImage2D
PUSH_IF_COMPILING(glTexSubImage2D)
#endif
gles_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
gles_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
}
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels) __attribute__((alias("gl4es_glTexSubImage2D"))) __attribute__((visibility("default")));
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data) __attribute__((alias("gl4es_glTexSubImage2D"))) __attribute__((visibility("default")));
#endif
#ifndef skip_glTranslatef
void gl4es_glTranslatef(GLfloat x, GLfloat y, GLfloat z) {

20
project/jni/gl4es/src/gl/wrap/gles.h Normal file → Executable file
View File

@@ -1340,7 +1340,7 @@ typedef struct {
int func;
ARGS_void_GLenum_GLenum_const_GLint___GENPT__ args;
} INDEXED_void_GLenum_GLenum_const_GLint___GENPT__;
typedef void (*FUNC_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
typedef void (*FUNC_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data);
typedef struct {
GLenum a1;
GLint a2;
@@ -1361,7 +1361,7 @@ typedef struct {
int func;
ARGS_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__ args;
} INDEXED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__;
typedef void (*FUNC_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);
typedef void (*FUNC_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data);
typedef struct {
GLenum a1;
GLint a2;
@@ -2496,8 +2496,8 @@ packed_call_t* glCopyPackedCall(const packed_call_t *packed);
#define glTexGeni_FORMAT FORMAT_void_GLenum_GLenum_GLint
#define glTexImage2D_INDEX 159
#define glTexImage2D_RETURN void
#define glTexImage2D_ARG_NAMES target, level, internalformat, width, height, border, format, type, pixels
#define glTexImage2D_ARG_EXPAND GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels
#define glTexImage2D_ARG_NAMES target, level, internalformat, width, height, border, format, type, data
#define glTexImage2D_ARG_EXPAND GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * data
#define glTexImage2D_PACKED PACKED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__
#define glTexImage2D_INDEXED INDEXED_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__
#define glTexImage2D_FORMAT FORMAT_void_GLenum_GLint_GLint_GLsizei_GLsizei_GLint_GLenum_GLenum_const_GLvoid___GENPT__
@@ -2545,8 +2545,8 @@ packed_call_t* glCopyPackedCall(const packed_call_t *packed);
#define glTexParameterxv_FORMAT FORMAT_void_GLenum_GLenum_const_GLfixed___GENPT__
#define glTexSubImage2D_INDEX 166
#define glTexSubImage2D_RETURN void
#define glTexSubImage2D_ARG_NAMES target, level, xoffset, yoffset, width, height, format, type, pixels
#define glTexSubImage2D_ARG_EXPAND GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels
#define glTexSubImage2D_ARG_NAMES target, level, xoffset, yoffset, width, height, format, type, data
#define glTexSubImage2D_ARG_EXPAND GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * data
#define glTexSubImage2D_PACKED PACKED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__
#define glTexSubImage2D_INDEXED INDEXED_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__
#define glTexSubImage2D_FORMAT FORMAT_void_GLenum_GLint_GLint_GLint_GLsizei_GLsizei_GLenum_GLenum_const_GLvoid___GENPT__
@@ -4597,7 +4597,7 @@ typedef void (*glViewport_PTR)(glViewport_ARG_EXPAND);
}
#endif
#ifndef direct_glTexImage2D
#define push_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels) { \
#define push_glTexImage2D(target, level, internalformat, width, height, border, format, type, data) { \
glTexImage2D_PACKED *packed_data = malloc(sizeof(glTexImage2D_PACKED)); \
packed_data->format = glTexImage2D_FORMAT; \
packed_data->func = gl4es_glTexImage2D; \
@@ -4609,7 +4609,7 @@ typedef void (*glViewport_PTR)(glViewport_ARG_EXPAND);
packed_data->args.a6 = (GLint)border; \
packed_data->args.a7 = (GLenum)format; \
packed_data->args.a8 = (GLenum)type; \
packed_data->args.a9 = (GLvoid *)pixels; \
packed_data->args.a9 = (GLvoid *)data; \
glPushCall((void *)packed_data); \
}
#endif
@@ -4680,7 +4680,7 @@ typedef void (*glViewport_PTR)(glViewport_ARG_EXPAND);
}
#endif
#ifndef direct_glTexSubImage2D
#define push_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels) { \
#define push_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data) { \
glTexSubImage2D_PACKED *packed_data = malloc(sizeof(glTexSubImage2D_PACKED)); \
packed_data->format = glTexSubImage2D_FORMAT; \
packed_data->func = gl4es_glTexSubImage2D; \
@@ -4692,7 +4692,7 @@ typedef void (*glViewport_PTR)(glViewport_ARG_EXPAND);
packed_data->args.a6 = (GLsizei)height; \
packed_data->args.a7 = (GLenum)format; \
packed_data->args.a8 = (GLenum)type; \
packed_data->args.a9 = (GLvoid *)pixels; \
packed_data->args.a9 = (GLvoid *)data; \
glPushCall((void *)packed_data); \
}
#endif

View File

@@ -29,6 +29,7 @@
#endif
//#define DEBUG
#ifdef DEBUG
#define DBG(a) a
@@ -62,7 +63,6 @@ typedef struct {
Display *dpy;
int Type; GC gc;
XImage* frame;
GLXContext glxcontext;
} glx_buffSize;
//PBuffer should work under ANDROID
@@ -86,7 +86,7 @@ static GLXContext fbContext = NULL;
#endif //ANDROID
// hmm...
static EGLContext eglContext;
static EGLContext eglContext = EGL_NO_CONTEXT;
static int fbcontext_count = 0;
@@ -98,11 +98,24 @@ static int fbdev = -1;
#endif
static int g_width=0, g_height=0;
// RPI stuffs
// **** RPI stuffs ****
static bool g_bcmhost = false;
static bool g_bcm_active = false;
void (*bcm_host_init)();
void (*bcm_host_deinit)();
#ifndef ANDROID
#include "rpi.h"
#endif
// ***** end of RPI stuffs ****
// Generic create native window to use with "LIBGL_FB=1" (so with EGL_DEFAULT_DISPLAY and without X11)
static void* create_native_window(int w, int h) {
#ifndef ANDROID
if(bcm_host) return create_rpi_window(w, h);
#endif
return NULL;
}
#define SHUT(a) if(!globals4es.nobanner) a
@@ -219,7 +232,7 @@ static int get_config_default(Display *display, int attribute, int *value) {
*value = GLX_WINDOW_BIT;
break;
case GLX_BUFFER_SIZE:
*value = 0;
*value = 16;
break;
case GLX_X_VISUAL_TYPE:
case GLX_CONFIG_CAVEAT:
@@ -348,8 +361,10 @@ void glx_init() {
if (bcm_host) {
bcm_host_init = dlsym(bcm_host, "bcm_host_init");
bcm_host_deinit = dlsym(bcm_host, "bcm_host_deinit");
if (bcm_host_init && bcm_host_deinit)
if (bcm_host_init && bcm_host_deinit) {
g_bcmhost = true;
rpi_init();
}
}
if (globals4es.xrefresh || globals4es.stacktrace || g_bcmhost) {
// TODO: a bit gross. Maybe look at this: http://stackoverflow.com/a/13290134/293352
@@ -394,7 +409,7 @@ GLXContext gl4es_glXCreateContext(Display *display,
XVisualInfo *visual,
GLXContext shareList,
Bool isDirect) {
DBG(printf("glXCreateContext(%p, %p, %p, %i), latest_visual=%p\n", display, visual, shareList, isDirect, latest_visual);)
DBG(printf("glXCreateContext(%p, %p, %p, %i), latest_visual=%p, fbcontext_count=%d", display, visual, shareList, isDirect, latest_visual, fbcontext_count);)
static struct __GLXFBConfigRec default_glxfbconfig;
GLXFBConfig glxfbconfig;
@@ -411,6 +426,11 @@ GLXContext gl4es_glXCreateContext(Display *display,
default_glxfbconfig.depthBits = 16;
default_glxfbconfig.stencilBits = 8;
}
int depthBits = glxfbconfig->depthBits;
#ifdef PANDORA
if(depthBits==24 && glxfbconfig->stencilBits==8 && !(globals4es.usefbo || globals4es.usepbuffer))
depthBits = 16;
#endif
EGLint configAttribs[] = {
#ifdef PANDORA
@@ -429,7 +449,7 @@ GLXContext gl4es_glXCreateContext(Display *display,
#else
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
#endif
EGL_BUFFER_SIZE, glxfbconfig->depthBits,
EGL_BUFFER_SIZE, depthBits,
EGL_STENCIL_SIZE, glxfbconfig->stencilBits,
EGL_SAMPLE_BUFFERS, glxfbconfig->nMultiSampleBuffers,
@@ -438,10 +458,14 @@ GLXContext gl4es_glXCreateContext(Display *display,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
EGL_NONE
};
if (globals4es.usefb && fbcontext_count>0) {
if (globals4es.usefb && fbcontext_count++>0) {
// don't create a new context, one FB is enough...
fbcontext_count++;
return fbContext;
GLXContext fake = malloc(sizeof(struct __GLXContextRec));
memcpy(fake, fbContext, sizeof(struct __GLXContextRec));
fake->glstate = NewGLState(fbContext->glstate); // let's create a new shared glsate
DBG(printf(" => %p\n", fake);)
return fake;
}
#ifdef BCMHOST
@@ -463,13 +487,12 @@ GLXContext gl4es_glXCreateContext(Display *display,
GLXContext fake = malloc(sizeof(struct __GLXContextRec));
memset(fake, 0, sizeof(struct __GLXContextRec));
if(globals4es.usefb)
fbContext = fake;
// make an egl context here...
EGLBoolean result;
if (eglDisplay == NULL || eglDisplay == EGL_NO_DISPLAY) {
init_display(display);
if (eglDisplay == EGL_NO_DISPLAY) {
DBG(printf(" => %p\n", 0);)
LOGE("LIBGL: Unable to create EGL display.\n");
free(fake);
return 0;
@@ -481,6 +504,7 @@ GLXContext gl4es_glXCreateContext(Display *display,
egl_eglBindAPI(EGL_OPENGL_ES_API);
result = egl_eglInitialize(eglDisplay, NULL, NULL);
if (result != EGL_TRUE) {
DBG(printf(" => %p\n", 0);)
LOGE("LIBGL: Unable to initialize EGL display.\n");
free(fake);
return 0;
@@ -495,7 +519,8 @@ GLXContext gl4es_glXCreateContext(Display *display,
CheckEGLErrors();
if (result != EGL_TRUE || configsFound == 0) {
LOGE("LIBGL: No EGL configs found.\n");
DBG(printf(" => %p\n", 0);)
LOGE("LIBGL: No EGL configs found (depth=%d, stencil=%d).\n", depthBits, glxfbconfig->stencilBits);
free(fake);
return 0;
}
@@ -529,7 +554,11 @@ GLXContext gl4es_glXCreateContext(Display *display,
egl_eglMakeCurrent(eglDisplay, NULL, NULL, EGL_NO_CONTEXT);
}
*/
if(globals4es.usefb) {
fbContext = malloc(sizeof(struct __GLXContextRec));
memcpy(fbContext, fake, sizeof(struct __GLXContextRec));
}
DBG(printf(" => %p\n", fake);)
return fake;
}
@@ -719,7 +748,7 @@ GLXContext gl4es_glXCreateContextAttribsARB(Display *display, GLXFBConfig config
fake->display = (globals4es.usefb)?g_display:display;
fake->direct = true;
fake->xid = 1; //TODO: Proper handling of that id...
fake->contextType = 0; //Window
fake->contextType = (config->drawableType)==GLX_PIXMAP_BIT?2:0; //Pixmap:Window
egl_eglGetConfigAttrib(eglDisplay, fake->eglConfigs[0], EGL_RED_SIZE, &fake->rbits);
egl_eglGetConfigAttrib(eglDisplay, fake->eglConfigs[0], EGL_GREEN_SIZE, &fake->gbits);
@@ -735,14 +764,17 @@ GLXContext gl4es_glXCreateContextAttribsARB(Display *display, GLXFBConfig config
}
void gl4es_glXDestroyContext(Display *display, GLXContext ctx) {
DBG(printf("glXDestroyContext(%p, %p)\n", display, ctx);)
DBG(printf("glXDestroyContext(%p, %p), fbcontext_count=%d, ctx_type=%d\n", display, ctx, fbcontext_count, (ctx)?ctx->contextType:0);)
if (globals4es.usefb && ctx->contextType==0) {
if (fbcontext_count==0)
return; // Should not happens!
if (--fbcontext_count > 0)
return; // Nothing to do...
if (--fbcontext_count > 0) {
DeleteGLState(ctx->glstate);
free(ctx);
return; // Not much to do...
}
}
if ((!globals4es.usefb && ctx->eglContext) || (globals4es.usefb && eglContext)) {
if (ctx->eglContext) {
if (globals4es.usefbo && ctx->contextType==0) {
deleteMainFBO();
}
@@ -775,6 +807,7 @@ void gl4es_glXDestroyContext(Display *display, GLXContext ctx) {
if (globals4es.usefb)
fbContext = NULL;
free(ctx);
return;
}
@@ -827,7 +860,7 @@ not set to EGL_NO_CONTEXT.
Bool gl4es_glXMakeCurrent(Display *display,
GLXDrawable drawable,
GLXContext context) {
DBG(printf("glXMakeCurrent(%p, %p, %p) 'isPBuffer(drawable)=%d, context->drawable=%p, context->eglSurface=%p\n", display, drawable, context, isPBuffer(drawable), context?context->drawable:0, context?context->eglSurface:0);)
DBG(printf("glXMakeCurrent(%p, %p, %p), isPBuffer(drawable)=%d, context->drawable=%p, context->eglSurface=%p", display, drawable, context, isPBuffer(drawable), context?context->drawable:0, context?context->eglSurface:0);)
LOAD_EGL(eglMakeCurrent);
LOAD_EGL(eglDestroySurface);
LOAD_EGL(eglCreateWindowSurface);
@@ -842,6 +875,7 @@ Bool gl4es_glXMakeCurrent(Display *display,
EGLSurface eglSurf = 0;
EGLConfig eglConfig = 0;
if(context && glxContext==context && context->drawable==drawable) {
DBG(printf(" => True\n");)
//same context, all is done bye
DBG(printf("Same context and drawable, doing nothing\n");)
return true;
@@ -857,16 +891,24 @@ Bool gl4es_glXMakeCurrent(Display *display,
#ifndef ANDROID
eglSurf = context->eglSurface = pbuffersize[created-1].Surface; //(EGLSurface)drawable;
context->eglContext = eglContext = pbuffersize[created-1].Context; // this context is ok for the PBuffer
if (context->contextType != pbuffersize[created-1].Type) { // Context / buffer not aligned, create a new glstate tracker
DeleteGLState(context->glstate);
context->glstate = NewGLState(NULL);
}
#endif
} else {
unsigned int width = 0, height = 0, depth = 0;
#ifndef ANDROID
if(globals4es.usefb && (bcm_host || globals4es.usepbuffer)) {
// Get Window size and all...
unsigned int border;
Window root;
int x, y;
XGetGeometry(display, drawable, &root, &x, &y, &width, &height, &border, &depth);
DBG(printf("XGetGeometry gives %dx%d for drawable %p\n", width, height, drawable);)
}
if(globals4es.usefb) {
if(globals4es.usepbuffer) {
// Get Window size and all...
unsigned int width, height, border, depth;
Window root;
int x, y;
XGetGeometry(display, drawable, &root, &x, &y, &width, &height, &border, &depth);
//let's create a PBuffer attributes
EGLint egl_attribs[10]; // should be enough
int i = 0;
@@ -897,7 +939,7 @@ Bool gl4es_glXMakeCurrent(Display *display,
if(eglSurface)
eglSurf = context->eglSurface = eglSurface;
else
eglSurface = eglSurf = context->eglSurface = egl_eglCreateWindowSurface(eglDisplay, context->eglConfigs[0], 0, (globals4es.glx_surface_srgb)?sRGB:NULL);
eglSurface = eglSurf = context->eglSurface = egl_eglCreateWindowSurface(eglDisplay, context->eglConfigs[0], (EGLNativeWindowType)create_native_window(width,height), (globals4es.glx_surface_srgb)?sRGB:NULL);
} else {
if(context->eglSurface)
egl_eglDestroySurface(eglDisplay, context->eglSurface);
@@ -925,7 +967,6 @@ Bool gl4es_glXMakeCurrent(Display *display,
map->surface = eglSurf;
map->PBuffer = created;
if(created) pbuffersize[created-1].glxcontext = context;
}
if (context) {
@@ -933,7 +974,7 @@ Bool gl4es_glXMakeCurrent(Display *display,
ActivateGLState(context->glstate);
#ifdef PANDORA
if(created) pandora_set_gamma();
if(!created) pandora_set_gamma();
#endif
glstate->emulatedPixmap = 0;
glstate->emulatedWin = 0;
@@ -944,7 +985,7 @@ Bool gl4es_glXMakeCurrent(Display *display,
CheckEGLErrors();
if (result) {
if (globals4es.usefbo && created) {
if (globals4es.usefbo && !created) {
// get size of the surface...
egl_eglQuerySurface(eglDisplay,eglSurf,EGL_WIDTH,&g_width);
egl_eglQuerySurface(eglDisplay,eglSurf,EGL_HEIGHT,&g_height);
@@ -953,10 +994,13 @@ Bool gl4es_glXMakeCurrent(Display *display,
createMainFBO(g_width, g_height);
}
// finished
DBG(printf(" => True\n");)
return true;
}
DBG(printf(" => False\n");)
return false;
}
DBG(printf(" => True\n");)
return true;
}
@@ -1087,7 +1131,7 @@ const char *gl4es_glXQueryServerString(Display *display, int screen, int name) {
}
Bool gl4es_glXQueryExtension(Display *display, int *errorBase, int *eventBase) {
DBG(printf("glXQuesryExtension(%p, %p, %p)\n", display, errorBase, eventBase);)
DBG(printf("glXQueryExtension(%p, %p, %p)\n", display, errorBase, eventBase);)
if (errorBase)
*errorBase = 0;
@@ -1499,24 +1543,36 @@ void gl4es_glXReleaseBuffersMESA() {}
#ifndef ANDROID
/* TODO proper implementation */
int gl4es_glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value) {
DBG(printf("glXQueryDrawable(%p, %p, %d, %p)\n", dpy, draw, attribute, value);)
DBG(printf("glXQueryDrawable(%p, %p", dpy, draw);)
int pbuf=isPBuffer(draw);
*value = 0;
switch(attribute) {
case GLX_WIDTH:
*value = (pbuf)?pbuffersize[pbuf-1].Width:800;
DBG(printf("(%d), GLX_WIDTH, %p = %d)\n", pbuf, value, *value);)
return 1;
case GLX_HEIGHT:
*value = (pbuf)?pbuffersize[pbuf-1].Height:480;
DBG(printf("(%d), GLX_HEIGHT, %p = %d)\n", pbuf, value, *value);)
return 1;
case GLX_PRESERVED_CONTENTS:
return 0;
if(pbuf) *value = 1;
DBG(printf("(%d), GLX_PRESERVED_CONTENTS, %p = %d)\n", pbuf, value, *value);)
return 1;
case GLX_LARGEST_PBUFFER:
return 0;
if(pbuf) *value = 0;
DBG(printf("(%d), GLX_LARGEST_PBUFFER, %p = %d)\n", pbuf, value, *value);)
return 1;
case GLX_FBCONFIG_ID:
*value = 1;
DBG(printf("(%d), GLX_FBCONFIG_ID, %p = %d)\n", pbuf, value, *value);)
return 1;
case GLX_SWAP_INTERVAL_EXT:
*value = 0;
DBG(printf("(%d), GLX_SWAP_INTERVAL_EXT, %p = %d)\n", pbuf, value, *value);)
return 1;
}
DBG(printf("(%d), %04x, %p)\n", pbuf, attribute, value);)
return 0;
}
@@ -1551,12 +1607,14 @@ void gl4es_glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) {
DBG(printf("glxDestroyPBuffer(%p, %p)\n", dpy, pbuf);)
LOAD_EGL(eglDestroySurface);
int j=0;
while(j<pbufferlist_size || pbufferlist[j]==pbuf) j++;
if(j==pbufferlist_size)
while(j<pbufferlist_size && pbufferlist[j]!=pbuf) j++;
if(j==pbufferlist_size) {
DBG(printf("PBuff not found in pbufferlist\n");)
return;
}
// delete de Surface
EGLSurface surface = (EGLSurface)pbufferlist[j];
egl_eglDestroySurface(dpy, surface);
egl_eglDestroySurface(eglDisplay, surface);
delPBuffer(j);
}
@@ -1621,7 +1679,6 @@ int createPBuffer(Display * dpy, const EGLint * egl_attribs, EGLSurface* Surface
LOGD("LIBGL: Error creating PBuffer\n");
return 0;
}
(*Context) = egl_eglCreateContext(eglDisplay, pbufConfigs[0], EGL_NO_CONTEXT, egl_context_attrib);
return 1;
@@ -1837,12 +1894,12 @@ void gl4es_glXDestroyGLXPixmap(Display *display, void *pixmap) {
DBG(printf("glXDestroyGLXPixmap(%p, %p)\n", display, pixmap);)
LOAD_EGL(eglDestroySurface);
int j=0;
while(j<pbufferlist_size || pbufferlist[j]==(GLXPbuffer)pixmap) j++;
while(j<pbufferlist_size && pbufferlist[j]!=(GLXPbuffer)pixmap) j++;
if(j==pbufferlist_size)
return;
// delete de Surface
EGLSurface surface = pbuffersize[j].Surface;// (EGLSurface)pbufferlist[j];
egl_eglDestroySurface(display, surface);
egl_eglDestroySurface(eglDisplay, surface);
delPixBuffer(j);
}
@@ -1900,7 +1957,7 @@ void BlitEmulatedPixmap() {
dst_pos -= 2*stride;
}
} else
pixel_convert(tmp, (void**)&pix, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0);
pixel_convert(tmp, (void**)&pix, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0, glstate->texture.unpack_align);
free(tmp);
} else {
gles_glReadPixels(0, 0, Width, Height, GL_BGRA, GL_UNSIGNED_BYTE, (void*)pix);
@@ -1978,8 +2035,6 @@ void BlitEmulatedPixmap() {
EGLSurface Surface = egl_eglCreatePbufferSurface(eglDisplay, pbufConfigs[0], egl_attribs);
buff->glxcontext->eglSurface = Surface;
egl_eglMakeCurrent(eglDisplay, Surface, Surface, eglContext);
egl_eglDestroySurface(eglDisplay, buff->Surface);

View File

@@ -125,6 +125,7 @@
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
#define GLX_SWAP_INTERVAL_EXT 0x20F1
typedef int GLXDrawable;
#ifndef ANDROID

View File

@@ -110,6 +110,14 @@ void GetHardwareExtensions(int notest)
S("GL_OES_blend_equation_separate", blendeq, 1);
S("GL_EXT_blend_minmax", blendminmax, 1);
S("GL_EXT_blend_color", blendcolor, 1);
if(hardext.blendcolor==0) {
// try by just loading the function
LOAD_GLES_OR_OES(glBlendColor);
if(gles_glBlendColor != NULL) {
hardext.blendcolor = 1;
SHUT(LOGD("LIBGL: Extension glBlendColor found and used\n"));
}
}
S("GL_OES_point_sprite", pointsprite, 1);
S("GL_OES_point_size_array", pointsize, 0);
S("GL_OES_element_index_uint", elementuint, 0);
@@ -146,4 +154,4 @@ void GetHardwareExtensions(int notest)
egl_eglMakeCurrent(eglDisplay, 0, 0, EGL_NO_CONTEXT);
egl_eglDestroySurface(eglDisplay, eglSurface);
egl_eglDestroyContext(eglDisplay, eglContext);
}
}

View File

@@ -0,0 +1,84 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <dlfcn.h>
#include "rpi.h"
// Code specific to RPI
// everything is dynamicaly linked, so this can be saffely compiled everywhere
extern void* bcm_host;
extern void* vcos;
typedef uint32_t DISPMANX_DISPLAY_HANDLE_T;
typedef uint32_t DISPMANX_UPDATE_HANDLE_T;
typedef uint32_t DISPMANX_ELEMENT_HANDLE_T;
typedef uint32_t DISPMANX_RESOURCE_HANDLE_T;
typedef uint32_t DISPMANX_PROTECTION_T;
typedef struct tag_VC_RECT_T {
int32_t x;
int32_t y;
int32_t width;
int32_t height;
} VC_RECT_T;
typedef struct {
DISPMANX_ELEMENT_HANDLE_T element;
int width;
int height;
} EGL_DISPMANX_WINDOW_T;
int32_t (*graphics_get_display_size)(const uint16_t, uint32_t *, uint32_t*);
DISPMANX_DISPLAY_HANDLE_T (*vc_dispmanx_display_open)(uint32_t);
DISPMANX_UPDATE_HANDLE_T (*vc_dispmanx_update_start)(int32_t);
DISPMANX_ELEMENT_HANDLE_T (*vc_dispmanx_element_add)(
DISPMANX_UPDATE_HANDLE_T, DISPMANX_DISPLAY_HANDLE_T, int32_t,
VC_RECT_T *, DISPMANX_RESOURCE_HANDLE_T,
VC_RECT_T *, DISPMANX_PROTECTION_T,
/*VC_DISPMANX_ALPHA_T*/void*, /*DISPMANX_CLAMP_T*/void*,
/*DISPMANX_TRANSFORM_T*/ int32_t);
int (*vc_dispmanx_update_submit_sync)(DISPMANX_RESOURCE_HANDLE_T);
static DISPMANX_UPDATE_HANDLE_T dispman_update;
static DISPMANX_DISPLAY_HANDLE_T dispman_display;
static VC_RECT_T dst_rect;
static VC_RECT_T src_rect;
void rpi_init() {
#define GO(A) A=dlsym(bcm_host, #A); if(A==NULL) A=dlsym(vcos, #A); if(A==NULL) printf("LIBGL: Warning, " #A " is null")
GO(graphics_get_display_size);
GO(vc_dispmanx_display_open);
GO(vc_dispmanx_update_start);
GO(vc_dispmanx_element_add);
GO(vc_dispmanx_update_submit_sync);
#undef GO
}
void* create_rpi_window(int w, int h) {
static EGL_DISPMANX_WINDOW_T nativewindow;
if(!bcm_host) return NULL;
// create a simple RPI nativewindow of size w*h, on output 0 (i.e. LCD)...
// code heavily inspired from Allegro 5.2
uint32_t screenwidth, screenheight;
graphics_get_display_size(/*LCD*/ 0, &screenwidth, & screenheight);
if(w==0) w=screenwidth;
if(h==0) h=screenheight;
DISPMANX_ELEMENT_HANDLE_T dispman_element;
VC_RECT_T dst_rect, src_rect;
dst_rect.x = 0; dst_rect.y = 0;
dst_rect.width = screenwidth;
dst_rect.height = screenheight;
src_rect.x = 0; src_rect.y = 0;
src_rect.width = w << 16;
src_rect.height = h << 16;
dispman_display = vc_dispmanx_display_open(/*LCD*/ 0);
dispman_update = vc_dispmanx_update_start(0);
dispman_element = vc_dispmanx_element_add(
dispman_update,dispman_display, 0, &dst_rect,
0, &src_rect, /*DISPMANX_PROTECTION_NONE*/ 0, 0, 0,
/*DISPMAN_NO_ROTATE*/ 0);
nativewindow.element = dispman_element;
nativewindow.width = w;
nativewindow.height = h;
vc_dispmanx_update_submit_sync(dispman_update);
return &nativewindow;
}

View File

@@ -0,0 +1,10 @@
#ifndef __RPI_H_
#define __RPI_H_
// Code specific to RPI
void rpi_init();
void* create_rpi_window(int w, int h);
#endif //__RPI_H_

View File

@@ -3,6 +3,6 @@
#define MAJOR 0
#define MINOR 9
#define REVISION 5
#define REVISION 6
#endif //_GL4ES_VERSION_H

2
project/jni/iconv/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/include
/lib

View File

@@ -2,11 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) # Pre-compiled lib disabled for armhf ABI
ifneq ($(TARGET_ARCH_ABI),arm64-v8a) # Not supported yet
ifneq ($(TARGET_ARCH_ABI),x86_64) # Not supported yet
ifneq ($(TARGET_ARCH_ABI),mips64) # Not supported yet
LOCAL_MODULE := $(notdir $(LOCAL_PATH))
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
@@ -15,7 +10,3 @@ LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
endif
endif
endif
endif

View File

@@ -1,242 +0,0 @@
/* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
The GNU LIBICONV Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301, USA. */
/* When installed, this file is called "iconv.h". */
#ifndef _LIBICONV_H
#define _LIBICONV_H
#define _LIBICONV_VERSION 0x010E /* version number: (major<<8) + minor */
extern int _libiconv_version; /* Likewise */
/* We would like to #include any system header file which could define
iconv_t, 1. in order to eliminate the risk that the user gets compilation
errors because some other system header file includes /usr/include/iconv.h
which defines iconv_t or declares iconv after this file, 2. when compiling
for LIBICONV_PLUG, we need the proper iconv_t type in order to produce
binary compatible code.
But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
has been installed in /usr/local/include, there is no way any more to
include the original /usr/include/iconv.h. We simply have to get away
without it.
Ad 1. The risk that a system header file does
#include "iconv.h" or #include_next "iconv.h"
is small. They all do #include <iconv.h>.
Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It
has to be a scalar type because (iconv_t)(-1) is a possible return value
from iconv_open().) */
/* Define iconv_t ourselves. */
#undef iconv_t
#define iconv_t libiconv_t
typedef void* iconv_t;
/* Get size_t declaration.
Get wchar_t declaration if it exists. */
#include <stddef.h>
/* Get errno declaration and values. */
#include <errno.h>
/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
have EILSEQ in a different header. On these systems, define EILSEQ
ourselves. */
#ifndef EILSEQ
#define EILSEQ
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Allocates descriptor for code conversion from encoding fromcode to
encoding tocode. */
#ifndef LIBICONV_PLUG
#define iconv_open libiconv_open
#endif
extern iconv_t iconv_open (const char* tocode, const char* fromcode);
/* Converts, using conversion descriptor cd, at most *inbytesleft bytes
starting at *inbuf, writing at most *outbytesleft bytes starting at
*outbuf.
Decrements *inbytesleft and increments *inbuf by the same amount.
Decrements *outbytesleft and increments *outbuf by the same amount. */
#ifndef LIBICONV_PLUG
#define iconv libiconv
#endif
extern size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
/* Frees resources allocated for conversion descriptor cd. */
#ifndef LIBICONV_PLUG
#define iconv_close libiconv_close
#endif
extern int iconv_close (iconv_t cd);
#ifdef __cplusplus
}
#endif
#ifndef LIBICONV_PLUG
/* Nonstandard extensions. */
#if 1
#if 0
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
included before <wchar.h>. */
#include <stddef.h>
#include <stdio.h>
#include <time.h>
#endif
#include <wchar.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* A type that holds all memory needed by a conversion descriptor.
A pointer to such an object can be used as an iconv_t. */
typedef struct {
void* dummy1[28];
#if 1
mbstate_t dummy2;
#endif
} iconv_allocation_t;
/* Allocates descriptor for code conversion from encoding fromcode to
encoding tocode into preallocated memory. Returns an error indicator
(0 or -1 with errno set). */
#define iconv_open_into libiconv_open_into
extern int iconv_open_into (const char* tocode, const char* fromcode,
iconv_allocation_t* resultp);
/* Control of attributes. */
#define iconvctl libiconvctl
extern int iconvctl (iconv_t cd, int request, void* argument);
/* Hook performed after every successful conversion of a Unicode character. */
typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
/* Hook performed after every successful conversion of a wide character. */
typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
/* Set of hooks. */
struct iconv_hooks {
iconv_unicode_char_hook uc_hook;
iconv_wide_char_hook wc_hook;
void* data;
};
/* Fallback function. Invoked when a small number of bytes could not be
converted to a Unicode character. This function should process all
bytes from inbuf and may produce replacement Unicode characters by calling
the write_replacement callback repeatedly. */
typedef void (*iconv_unicode_mb_to_uc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const unsigned int *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a Unicode character could not be converted
to the target encoding. This function should process the character and
may produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_unicode_uc_to_mb_fallback)
(unsigned int code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#if 1
/* Fallback function. Invoked when a number of bytes could not be converted to
a wide character. This function should process all bytes from inbuf and may
produce replacement wide characters by calling the write_replacement
callback repeatedly. */
typedef void (*iconv_wchar_mb_to_wc_fallback)
(const char* inbuf, size_t inbufsize,
void (*write_replacement) (const wchar_t *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
/* Fallback function. Invoked when a wide character could not be converted to
the target encoding. This function should process the character and may
produce replacement bytes (in the target encoding) by calling the
write_replacement callback repeatedly. */
typedef void (*iconv_wchar_wc_to_mb_fallback)
(wchar_t code,
void (*write_replacement) (const char *buf, size_t buflen,
void* callback_arg),
void* callback_arg,
void* data);
#else
/* If the wchar_t type does not exist, these two fallback functions are never
invoked. Their argument list therefore does not matter. */
typedef void (*iconv_wchar_mb_to_wc_fallback) ();
typedef void (*iconv_wchar_wc_to_mb_fallback) ();
#endif
/* Set of fallbacks. */
struct iconv_fallbacks {
iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
void* data;
};
/* Requests for iconvctl. */
#define ICONV_TRIVIALP 0 /* int *argument */
#define ICONV_GET_TRANSLITERATE 1 /* int *argument */
#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */
#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */
#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */
#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */
#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */
/* Listing of locale independent encodings. */
#define iconvlist libiconvlist
extern void iconvlist (int (*do_one) (unsigned int namescount,
const char * const * names,
void* data),
void* data);
/* Canonicalize an encoding name.
The result is either a canonical encoding name, or name itself. */
extern const char * iconv_canonicalize (const char * name);
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern void libiconv_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif
#endif /* _LIBICONV_H */

View File

@@ -1,46 +0,0 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
The GNU CHARSET Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU CHARSET Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _LIBCHARSET_H
#define _LIBCHARSET_H
#include <localcharset.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern void libcharset_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif /* _LIBCHARSET_H */

View File

@@ -1,42 +0,0 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
#ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H
#ifdef __cplusplus
extern "C" {
#endif
/* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed in config.charset.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
extern const char * locale_charset (void);
#ifdef __cplusplus
}
#endif
#endif /* _LOCALCHARSET_H */

1
project/jni/icu-le-hb Symbolic link
View File

@@ -0,0 +1 @@
icuuc

2
project/jni/icuuc/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/include
/lib

View File

@@ -2,11 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) # Pre-compiled lib disabled for armhf ABI
ifneq ($(TARGET_ARCH_ABI),arm64-v8a) # Not supported yet
ifneq ($(TARGET_ARCH_ABI),x86_64) # Not supported yet
ifneq ($(TARGET_ARCH_ABI),mips64) # Not supported yet
LOCAL_MODULE := $(notdir $(LOCAL_PATH))
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
@@ -18,8 +13,3 @@ obj/local/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE).a: $(LOCAL_PATH)/$(LOCAL_SRC_FIL
cp -f $< $@
include $(PREBUILT_STATIC_LIBRARY)
endif
endif
endif
endif

Binary file not shown.

View File

@@ -1,550 +0,0 @@
/*
*
* (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
*
*/
#ifndef __LEFONTINSTANCE_H
#define __LEFONTINSTANCE_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Layout Engine Font Instance object
*/
U_NAMESPACE_BEGIN
/**
* Instances of this class are used by <code>LEFontInstance::mapCharsToGlyphs</code> and
* <code>LEFontInstance::mapCharToGlyph</code> to adjust character codes before the character
* to glyph mapping process. Examples of this are filtering out control characters
* and character mirroring - replacing a character which has both a left and a right
* hand form with the opposite form.
*
* @stable ICU 3.2
*/
class LECharMapper /* not : public UObject because this is an interface/mixin class */
{
public:
/**
* Destructor.
* @stable ICU 3.2
*/
virtual ~LECharMapper();
/**
* This method does the adjustments.
*
* @param ch - the input character
*
* @return the adjusted character
*
* @stable ICU 2.8
*/
virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
};
/**
* This is a forward reference to the class which holds the per-glyph
* storage.
*
* @stable ICU 3.0
*/
class LEGlyphStorage;
/**
* This is a virtual base class that serves as the interface between a LayoutEngine
* and the platform font environment. It allows a LayoutEngine to access font tables, do
* character to glyph mapping, and obtain metrics information without knowing any platform
* specific details. There are also a few utility methods for converting between points,
* pixels and funits. (font design units)
*
* An instance of an <code>LEFontInstance</code> represents a font at a particular point
* size. Each instance can represent either a single physical font, or a composite font.
* A composite font is a collection of physical fonts, each of which contains a subset of
* the characters contained in the composite font.
*
* Note: with the exception of <code>getSubFont</code>, the methods in this class only
* make sense for a physical font. If you have an <code>LEFontInstance</code> which
* represents a composite font you should only call the methods below which have
* an <code>LEGlyphID</code>, an <code>LEUnicode</code> or an <code>LEUnicode32</code>
* as one of the arguments because these can be used to select a particular subfont.
*
* Subclasses which implement composite fonts should supply an implementation of these
* methods with some default behavior such as returning constant values, or using the
* values from the first subfont.
*
* @stable ICU 3.0
*/
class U_LAYOUT_API LEFontInstance : public UObject
{
public:
/**
* This virtual destructor is here so that the subclass
* destructors can be invoked through the base class.
*
* @stable ICU 2.8
*/
virtual ~LEFontInstance();
/**
* Get a physical font which can render the given text. For composite fonts,
* if there is no single physical font which can render all of the text,
* return a physical font which can render an initial substring of the text,
* and set the <code>offset</code> parameter to the end of that substring.
*
* Internally, the LayoutEngine works with runs of text all in the same
* font and script, so it is best to call this method with text which is
* in a single script, passing the script code in as a hint. If you don't
* know the script of the text, you can use zero, which is the script code
* for characters used in more than one script.
*
* The default implementation of this method is intended for instances of
* <code>LEFontInstance</code> which represent a physical font. It returns
* <code>this</code> and indicates that the entire string can be rendered.
*
* This method will return a valid <code>LEFontInstance</code> unless you
* have passed illegal parameters, or an internal error has been encountered.
* For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
* to indicate that the returned font may not be able to render all of
* the text. Whenever a valid font is returned, the <code>offset</code> parameter
* will be advanced by at least one.
*
* Subclasses which implement composite fonts must override this method.
* Where it makes sense, they should use the script code as a hint to render
* characters from the COMMON script in the font which is used for the given
* script. For example, if the input text is a series of Arabic words separated
* by spaces, and the script code passed in is <code>arabScriptCode</code> you
* should return the font used for Arabic characters for all of the input text,
* including the spaces. If, on the other hand, the input text contains characters
* which cannot be rendered by the font used for Arabic characters, but which can
* be rendered by another font, you should return that font for those characters.
*
* @param chars - the array of Unicode characters.
* @param offset - a pointer to the starting offset in the text. On exit this
* will be set the the limit offset of the text which can be
* rendered using the returned font.
* @param limit - the limit offset for the input text.
* @param script - the script hint.
* @param success - set to an error code if the arguments are illegal, or no font
* can be returned for some reason. May also be set to
* <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
* was returned cannot render all of the text.
*
* @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
* <code>NULL</code> if there is an error.
*
* @see LEScripts.h
*
* @stable ICU 3.2
*/
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
//
// Font file access
//
/**
* This method reads a table from the font. Note that in general,
* it only makes sense to call this method on an <code>LEFontInstance</code>
* which represents a physical font - i.e. one which has been returned by
* <code>getSubFont()</code>. This is because each subfont in a composite font
* will have different tables, and there's no way to know which subfont to access.
*
* Subclasses which represent composite fonts should always return <code>NULL</code>.
*
* Note that implementing this function does not allow for range checking.
* Subclasses that desire the safety of range checking must implement the
* variation which has a length parameter.
*
* @param tableTag - the four byte table tag. (e.g. 'cmap')
*
* @return the address of the table in memory, or <code>NULL</code>
* if the table doesn't exist.
*
* @stable ICU 2.8
*/
virtual const void *getFontTable(LETag tableTag) const = 0;
/**
* This method reads a table from the font. Note that in general,
* it only makes sense to call this method on an <code>LEFontInstance</code>
* which represents a physical font - i.e. one which has been returned by
* <code>getSubFont()</code>. This is because each subfont in a composite font
* will have different tables, and there's no way to know which subfont to access.
*
* Subclasses which represent composite fonts should always return <code>NULL</code>.
*
* This version sets a length, for range checking.
* Note that range checking can only be accomplished if this function is
* implemented in subclasses.
*
* @param tableTag - the four byte table tag. (e.g. 'cmap')
* @param length - ignored on entry, on exit will be the length of the table if known, or -1 if unknown.
* @return the address of the table in memory, or <code>NULL</code>
* if the table doesn't exist.
* @draft ICU 52
*/
virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */
/**
* This method is used to determine if the font can
* render the given character. This can usually be done
* by looking the character up in the font's character
* to glyph mapping.
*
* The default implementation of this method will return
* <code>TRUE</code> if <code>mapCharToGlyph(ch)</code>
* returns a non-zero value.
*
* @param ch - the character to be tested
*
* @return <code>TRUE</code> if the font can render ch.
*
* @stable ICU 3.2
*/
virtual le_bool canDisplay(LEUnicode32 ch) const;
/**
* This method returns the number of design units in
* the font's EM square.
*
* @return the number of design units pre EM.
*
* @stable ICU 2.8
*/
virtual le_int32 getUnitsPerEM() const = 0;
/**
* This method maps an array of character codes to an array of glyph
* indices, using the font's character to glyph map.
*
* The default implementation iterates over all of the characters and calls
* <code>mapCharToGlyph(ch, mapper)</code> on each one. It also handles surrogate
* characters, storing the glyph ID for the high surrogate, and a deleted glyph (0xFFFF)
* for the low surrogate.
*
* Most sublcasses will not need to implement this method.
*
* @param chars - the character array
* @param offset - the index of the first character
* @param count - the number of characters
* @param reverse - if <code>TRUE</code>, store the glyph indices in reverse order.
* @param mapper - the character mapper.
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
* @param glyphStorage - the object which contains the output glyph array
*
* @see LECharMapper
*
* @stable ICU 3.6
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
/**
* This method maps a single character to a glyph index, using the
* font's character to glyph map. The default implementation of this
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
*
* @param ch - the character
* @param mapper - the character mapper
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
*
* @return the glyph index
*
* @see LECharMapper
*
* @stable ICU 3.6
*/
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
/**
* This method maps a single character to a glyph index, using the
* font's character to glyph map. The default implementation of this
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
*
* @param ch - the character
* @param mapper - the character mapper
*
* @return the glyph index
*
* @see LECharMapper
*
* @stable ICU 3.2
*/
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
/**
* This method maps a single character to a glyph index, using the
* font's character to glyph map. There is no default implementation
* of this method because it requires information about the platform
* font implementation.
*
* @param ch - the character
*
* @return the glyph index
*
* @stable ICU 3.2
*/
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
//
// Metrics
//
/**
* This method gets the X and Y advance of a particular glyph, in pixels.
*
* @param glyph - the glyph index
* @param advance - the X and Y pixel values will be stored here
*
* @stable ICU 3.2
*/
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
/**
* This method gets the hinted X and Y pixel coordinates of a particular
* point in the outline of the given glyph.
*
* @param glyph - the glyph index
* @param pointNumber - the number of the point
* @param point - the point's X and Y pixel values will be stored here
*
* @return <code>TRUE</code> if the point coordinates could be stored.
*
* @stable ICU 2.8
*/
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
/**
* This method returns the width of the font's EM square
* in pixels.
*
* @return the pixel width of the EM square
*
* @stable ICU 2.8
*/
virtual float getXPixelsPerEm() const = 0;
/**
* This method returns the height of the font's EM square
* in pixels.
*
* @return the pixel height of the EM square
*
* @stable ICU 2.8
*/
virtual float getYPixelsPerEm() const = 0;
/**
* This method converts font design units in the
* X direction to points.
*
* @param xUnits - design units in the X direction
*
* @return points in the X direction
*
* @stable ICU 3.2
*/
virtual float xUnitsToPoints(float xUnits) const;
/**
* This method converts font design units in the
* Y direction to points.
*
* @param yUnits - design units in the Y direction
*
* @return points in the Y direction
*
* @stable ICU 3.2
*/
virtual float yUnitsToPoints(float yUnits) const;
/**
* This method converts font design units to points.
*
* @param units - X and Y design units
* @param points - set to X and Y points
*
* @stable ICU 3.2
*/
virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
/**
* This method converts pixels in the
* X direction to font design units.
*
* @param xPixels - pixels in the X direction
*
* @return font design units in the X direction
*
* @stable ICU 3.2
*/
virtual float xPixelsToUnits(float xPixels) const;
/**
* This method converts pixels in the
* Y direction to font design units.
*
* @param yPixels - pixels in the Y direction
*
* @return font design units in the Y direction
*
* @stable ICU 3.2
*/
virtual float yPixelsToUnits(float yPixels) const;
/**
* This method converts pixels to font design units.
*
* @param pixels - X and Y pixel
* @param units - set to X and Y font design units
*
* @stable ICU 3.2
*/
virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
/**
* Get the X scale factor from the font's transform. The default
* implementation of <code>transformFunits()</code> will call this method.
*
* @return the X scale factor.
*
*
* @see transformFunits
*
* @stable ICU 3.2
*/
virtual float getScaleFactorX() const = 0;
/**
* Get the Y scale factor from the font's transform. The default
* implementation of <code>transformFunits()</code> will call this method.
*
* @return the Yscale factor.
*
* @see transformFunits
*
* @stable ICU 3.2
*/
virtual float getScaleFactorY() const = 0;
/**
* This method transforms an X, Y point in font design units to a
* pixel coordinate, applying the font's transform. The default
* implementation of this method calls <code>getScaleFactorX()</code>
* and <code>getScaleFactorY()</code>.
*
* @param xFunits - the X coordinate in font design units
* @param yFunits - the Y coordinate in font design units
* @param pixels - the tranformed co-ordinate in pixels
*
* @see getScaleFactorX
* @see getScaleFactorY
*
* @stable ICU 3.2
*/
virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
/**
* This is a convenience method used to convert
* values in a 16.16 fixed point format to floating point.
*
* @param fixed - the fixed point value
*
* @return the floating point value
*
* @stable ICU 2.8
*/
static inline float fixedToFloat(le_int32 fixed);
/**
* This is a convenience method used to convert
* floating point values to 16.16 fixed point format.
*
* @param theFloat - the floating point value
*
* @return the fixed point value
*
* @stable ICU 2.8
*/
static inline le_int32 floatToFixed(float theFloat);
//
// These methods won't ever be called by the LayoutEngine,
// but are useful for clients of <code>LEFontInstance</code> who
// need to render text.
//
/**
* Get the font's ascent.
*
* @return the font's ascent, in points. This value
* will always be positive.
*
* @stable ICU 3.2
*/
virtual le_int32 getAscent() const = 0;
/**
* Get the font's descent.
*
* @return the font's descent, in points. This value
* will always be positive.
*
* @stable ICU 3.2
*/
virtual le_int32 getDescent() const = 0;
/**
* Get the font's leading.
*
* @return the font's leading, in points. This value
* will always be positive.
*
* @stable ICU 3.2
*/
virtual le_int32 getLeading() const = 0;
/**
* Get the line height required to display text in
* this font. The default implementation of this method
* returns the sum of the ascent, descent, and leading.
*
* @return the line height, in points. This vaule will
* always be positive.
*
* @stable ICU 3.2
*/
virtual le_int32 getLineHeight() const;
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 3.2
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 3.2
*/
static UClassID getStaticClassID();
};
inline float LEFontInstance::fixedToFloat(le_int32 fixed)
{
return (float) (fixed / 65536.0);
}
inline le_int32 LEFontInstance::floatToFixed(float theFloat)
{
return (le_int32) (theFloat * 65536.0);
}
U_NAMESPACE_END
#endif

View File

@@ -1,45 +0,0 @@
/*
*
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
*
*/
#ifndef __LEGLYPHFILTER__H
#define __LEGLYPHFILTER__H
#include "LETypes.h"
U_NAMESPACE_BEGIN
#ifndef U_HIDE_INTERNAL_API
/**
* This is a helper class that is used to
* recognize a set of glyph indices.
*
* @internal
*/
class LEGlyphFilter /* not : public UObject because this is an interface/mixin class */ {
public:
/**
* Destructor.
* @internal
*/
virtual ~LEGlyphFilter();
/**
* This method is used to test a particular
* glyph index to see if it is in the set
* recognized by the filter.
*
* @param glyph - the glyph index to be tested
*
* @return TRUE if the glyph index is in the set.
*
* @internal
*/
virtual le_bool accept(LEGlyphID glyph) const = 0;
};
#endif /* U_HIDE_INTERNAL_API */
U_NAMESPACE_END
#endif

View File

@@ -1,546 +0,0 @@
/*
**********************************************************************
* Copyright (C) 1998-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#ifndef __LEGLYPHSTORAGE_H
#define __LEGLYPHSTORAGE_H
#include "LETypes.h"
#include "LEInsertionList.h"
/**
* \file
* \brief C++ API: This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
*/
U_NAMESPACE_BEGIN
/**
* This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
* For each glyph it holds the glyph ID, the index of the backing store character
* which produced the glyph, the X and Y position of the glyph and an auxillary data
* pointer.
*
* The storage is growable using the <code>LEInsertionList</code> class.
*
*
* @see LEInsertionList.h
*
* @stable ICU 3.6
*/
class U_LAYOUT_API LEGlyphStorage : public UObject, protected LEInsertionCallback
{
private:
/**
* The number of entries in the per-glyph arrays.
*
* @internal
*/
le_int32 fGlyphCount;
/**
* The glyph ID array.
*
* @internal
*/
LEGlyphID *fGlyphs;
/**
* The char indices array.
*
* @internal
*/
le_int32 *fCharIndices;
/**
* The glyph positions array.
*
* @internal
*/
float *fPositions;
/**
* The auxillary data array.
*
* @internal
*/
le_uint32 *fAuxData;
/**
* The insertion list, used to grow the above arrays.
*
* @internal
*/
LEInsertionList *fInsertionList;
/**
* The source index while growing the data arrays.
*
* @internal
*/
le_int32 fSrcIndex;
/**
* The destination index used while growing the data arrays.
*
* @internal
*/
le_int32 fDestIndex;
protected:
/**
* This implements <code>LEInsertionCallback</code>. The <code>LEInsertionList</code>
* will call this method once for each insertion.
*
* @param atPosition the position of the insertion
* @param count the number of glyphs being inserted
* @param newGlyphs the address of the new glyph IDs
*
* @return <code>true</code> if <code>LEInsertionList</code> should stop
* processing the insertion list after this insertion.
*
* @see LEInsertionList.h
*
* @stable ICU 3.0
*/
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]);
public:
/**
* Allocates an empty <code>LEGlyphStorage</code> object. You must call
* <code>allocateGlyphArray, allocatePositions and allocateAuxData</code>
* to allocate the data.
*
* @stable ICU 3.0
*/
LEGlyphStorage();
/**
* The destructor. This will deallocate all of the arrays.
*
* @stable ICU 3.0
*/
~LEGlyphStorage();
/**
* This method returns the number of glyphs in the glyph array.
*
* @return the number of glyphs in the glyph array
*
* @stable ICU 3.0
*/
inline le_int32 getGlyphCount() const;
/**
* This method copies the glyph array into a caller supplied array.
* The caller must ensure that the array is large enough to hold all
* the glyphs.
*
* @param glyphs - the destiniation glyph array
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
/**
* This method copies the glyph array into a caller supplied array,
* ORing in extra bits. (This functionality is needed by the JDK,
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
* the composite font slot number)
*
* @param glyphs - the destination (32 bit) glyph array
* @param extraBits - this value will be ORed with each glyph index
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
/**
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
/**
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param indexBase - an offset which will be added to each index
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
/**
* This method copies the position array into a caller supplied array.
* The caller must ensure that the array is large enough to hold an
* X and Y position for each glyph, plus an extra X and Y for the
* advance of the last glyph.
*
* @param positions - the destiniation position array
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getGlyphPositions(float positions[], LEErrorCode &success) const;
/**
* This method returns the X and Y position of the glyph at
* the given index.
*
* Input parameters:
* @param glyphIndex - the index of the glyph
*
* Output parameters:
* @param x - the glyph's X position
* @param y - the glyph's Y position
* @param success - set to an error code if the operation fails
*
* @stable ICU 3.0
*/
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
/**
* This method allocates the glyph array, the char indices array and the insertion list. You
* must call this method before using the object. This method also initializes the char indices
* array.
*
* @param initialGlyphCount the initial size of the glyph and char indices arrays.
* @param rightToLeft <code>true</code> if the original input text is right to left.
* @param success set to an error code if the storage cannot be allocated of if the initial
* glyph count is not positive.
*
* @stable ICU 3.0
*/
void allocateGlyphArray(le_int32 initialGlyphCount, le_bool rightToLeft, LEErrorCode &success);
/**
* This method allocates the storage for the glyph positions. It allocates one extra X, Y
* position pair for the position just after the last glyph.
*
* @param success set to an error code if the positions array cannot be allocated.
*
* @return the number of X, Y position pairs allocated.
*
* @stable ICU 3.0
*/
le_int32 allocatePositions(LEErrorCode &success);
/**
* This method allocates the storage for the auxillary glyph data.
*
* @param success set to an error code if the aulillary data array cannot be allocated.
*
* @return the size of the auxillary data array.
*
* @stable ICU 3.6
*/
le_int32 allocateAuxData(LEErrorCode &success);
/**
* Copy the entire auxillary data array.
*
* @param auxData the auxillary data array will be copied to this address
* @param success set to an error code if the data cannot be copied
*
* @stable ICU 3.6
*/
void getAuxData(le_uint32 auxData[], LEErrorCode &success) const;
/**
* Get the glyph ID for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the glyph ID cannot be retrieved.
*
* @return the glyph ID
*
* @stable ICU 3.0
*/
LEGlyphID getGlyphID(le_int32 glyphIndex, LEErrorCode &success) const;
/**
* Get the char index for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the char index cannot be retrieved.
*
* @return the character index
*
* @stable ICU 3.0
*/
le_int32 getCharIndex(le_int32 glyphIndex, LEErrorCode &success) const;
/**
* Get the auxillary data for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the auxillary data cannot be retrieved.
*
* @return the auxillary data
*
* @stable ICU 3.6
*/
le_uint32 getAuxData(le_int32 glyphIndex, LEErrorCode &success) const;
/**
* This operator allows direct access to the glyph array
* using the index operator.
*
* @param glyphIndex the index into the glyph array
*
* @return a reference to the given location in the glyph array
*
* @stable ICU 3.0
*/
inline LEGlyphID &operator[](le_int32 glyphIndex) const;
/**
* Call this method to replace a single glyph in the glyph array
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
* to do the insertion. It returns the address of storage where the new
* glyph IDs can be stored. They will not actually be inserted into the
* glyph array until <code>applyInsertions</code> is called.
*
* @param atIndex the index of the glyph to be replaced
* @param insertCount the number of glyphs to replace it with
* @param success set to an error code if the auxillary data cannot be retrieved.
*
* @return the address at which to store the replacement glyphs.
*
* @see LEInsertionList.h
*
* @stable ICU 4.2
*/
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount, LEErrorCode& success);
/**
* Call this method to replace a single glyph in the glyph array
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
* to do the insertion. It returns the address of storage where the new
* glyph IDs can be stored. They will not actually be inserted into the
* glyph array until <code>applyInsertions</code> is called.
*
* Note: Don't use this version, use the other version of this function which has an error code.
*
* @param atIndex the index of the glyph to be replaced
* @param insertCount the number of glyphs to replace it with
*
* @return the address at which to store the replacement glyphs.
*
* @see LEInsertionList.h
*
* @stable ICU 3.0
*/
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount);
/**
* This method is used to reposition glyphs during Indic v2 processing. It moves
* all of the relevant glyph information ( glyph, indices, positions, and auxData ),
* from the source position to the target position, and also allows for a marker bit
* to be set in the target glyph's auxData so that it won't be reprocessed later in the
* cycle.
*
* @param fromPosition - position of the glyph to be moved
* @param toPosition - target position of the glyph
* @param marker marker bit
*
* @stable ICU 4.2
*/
void moveGlyph(le_int32 fromPosition, le_int32 toPosition, le_uint32 marker);
/**
* This method causes all of the glyph insertions recorded by
* <code>insertGlyphs</code> to be applied to the glyph array. The
* new slots in the char indices and the auxillary data arrays
* will be filled in with the values for the glyph being replaced.
*
* @return the new size of the glyph array
*
* @see LEInsertionList.h
*
* @stable ICU 3.0
*/
le_int32 applyInsertions();
/**
* Set the glyph ID for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param glyphID the new glyph ID
* @param success will be set to an error code if the glyph ID cannot be set.
*
* @stable ICU 3.0
*/
void setGlyphID(le_int32 glyphIndex, LEGlyphID glyphID, LEErrorCode &success);
/**
* Set the char index for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param charIndex the new char index
* @param success will be set to an error code if the char index cannot be set.
*
* @stable ICU 3.0
*/
void setCharIndex(le_int32 glyphIndex, le_int32 charIndex, LEErrorCode &success);
/**
* Set the X, Y position for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param x the new X position
* @param y the new Y position
* @param success will be set to an error code if the position cannot be set.
*
* @stable ICU 3.0
*/
void setPosition(le_int32 glyphIndex, float x, float y, LEErrorCode &success);
/**
* Adjust the X, Y position for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param xAdjust the adjustment to the glyph's X position
* @param yAdjust the adjustment to the glyph's Y position
* @param success will be set to an error code if the glyph's position cannot be adjusted.
*
* @stable ICU 3.0
*/
void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust, LEErrorCode &success);
/**
* Set the auxillary data for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param auxData the new auxillary data
* @param success will be set to an error code if the auxillary data cannot be set.
*
* @stable ICU 3.6
*/
void setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success);
/**
* Delete the glyph array and replace it with the one
* in <code>from</code>. Set the glyph array pointer
* in <code>from</code> to <code>NULL</code>.
*
* @param from the <code>LEGlyphStorage</code> object from which
* to get the new glyph array.
*
* @stable ICU 3.0
*/
void adoptGlyphArray(LEGlyphStorage &from);
/**
* Delete the char indices array and replace it with the one
* in <code>from</code>. Set the char indices array pointer
* in <code>from</code> to <code>NULL</code>.
*
* @param from the <code>LEGlyphStorage</code> object from which
* to get the new char indices array.
*
* @stable ICU 3.0
*/
void adoptCharIndicesArray(LEGlyphStorage &from);
/**
* Delete the position array and replace it with the one
* in <code>from</code>. Set the position array pointer
* in <code>from</code> to <code>NULL</code>.
*
* @param from the <code>LEGlyphStorage</code> object from which
* to get the new position array.
*
* @stable ICU 3.0
*/
void adoptPositionArray(LEGlyphStorage &from);
/**
* Delete the auxillary data array and replace it with the one
* in <code>from</code>. Set the auxillary data array pointer
* in <code>from</code> to <code>NULL</code>.
*
* @param from the <code>LEGlyphStorage</code> object from which
* to get the new auxillary data array.
*
* @stable ICU 3.0
*/
void adoptAuxDataArray(LEGlyphStorage &from);
/**
* Change the glyph count of this object to be the same
* as the one in <code>from</code>.
*
* @param from the <code>LEGlyphStorage</code> object from which
* to get the new glyph count.
*
* @stable ICU 3.0
*/
void adoptGlyphCount(LEGlyphStorage &from);
/**
* Change the glyph count of this object to the given value.
*
* @param newGlyphCount the new glyph count.
*
* @stable ICU 3.0
*/
void adoptGlyphCount(le_int32 newGlyphCount);
/**
* This method frees the glyph, character index, position and
* auxillary data arrays so that the LayoutEngine can be reused
* to layout a different characer array. (This method is also called
* by the destructor)
*
* @stable ICU 3.0
*/
void reset();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 3.0
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 3.0
*/
static UClassID getStaticClassID();
};
inline le_int32 LEGlyphStorage::getGlyphCount() const
{
return fGlyphCount;
}
inline LEGlyphID &LEGlyphStorage::operator[](le_int32 glyphIndex) const
{
return fGlyphs[glyphIndex];
}
U_NAMESPACE_END
#endif

View File

@@ -1,177 +0,0 @@
/*
**********************************************************************
* Copyright (C) 1998-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#ifndef __LEINSERTIONLIST_H
#define __LEINSERTIONLIST_H
#include "LETypes.h"
U_NAMESPACE_BEGIN
struct InsertionRecord;
#ifndef U_HIDE_INTERNAL_API
/**
* This class encapsulates the callback used by <code>LEInsertionList</code>
* to apply an insertion from the insertion list.
*
* @internal
*/
class U_LAYOUT_API LEInsertionCallback
{
public:
/**
* This method will be called by <code>LEInsertionList::applyInsertions</code> for each
* entry on the insertion list.
*
* @param atPosition the position of the insertion
* @param count the number of glyphs to insert
* @param newGlyphs the address of the glyphs to insert
*
* @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
* stop after applying this insertion.
*
* @internal
*/
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
/**
* The destructor
*/
virtual ~LEInsertionCallback();
};
/**
* This class is used to keep track of insertions to an array of
* <code>LEGlyphIDs</code>. The insertions are kept on a linked
* list of <code>InsertionRecords</code> so that the glyph array
* doesn't have to be grown for each insertion. The insertions are
* stored on the list from leftmost to rightmost to make it easier
* to do the insertions.
*
* The insertions are applied to the array by calling the
* <code>applyInsertions</code> method, which calls a client
* supplied <code>LEInsertionCallback</code> object to actually
* apply the individual insertions.
*
* @internal
*/
class LEInsertionList : public UObject
{
public:
/**
* Construct an empty insertion list.
*
* @param rightToLeft <code>TRUE</code> if the glyphs are stored
* in the array in right to left order.
*
* @internal
*/
LEInsertionList(le_bool rightToLeft);
/**
* The destructor.
*/
~LEInsertionList();
/**
* Add an entry to the insertion list.
*
* @param position the glyph at this position in the array will be
* replaced by the new glyphs.
* @param count the number of new glyphs
* @param success set to an error code if the auxillary data cannot be retrieved.
*
* @return the address of an array in which to store the new glyphs. This will
* <em>not</em> be in the glyph array.
*
* @internal
*/
LEGlyphID *insert(le_int32 position, le_int32 count, LEErrorCode &success);
/**
* Return the number of new glyphs that have been inserted.
*
* @return the number of new glyphs which have been inserted
*
* @internal
*/
le_int32 getGrowAmount();
/**
* Call the <code>LEInsertionCallback</code> once for each
* entry on the insertion list.
*
* @param callback the <code>LEInsertionCallback</code> to call for each insertion.
*
* @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
* terminate the insertion list processing.
*
* @internal
*/
le_bool applyInsertions(LEInsertionCallback *callback);
/**
* Empty the insertion list and free all associated
* storage.
*
* @internal
*/
void reset();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
private:
/**
* The head of the insertion list.
*
* @internal
*/
InsertionRecord *head;
/**
* The tail of the insertion list.
*
* @internal
*/
InsertionRecord *tail;
/**
* The total number of new glyphs on the insertion list.
*
* @internal
*/
le_int32 growAmount;
/**
* Set to <code>TRUE</code> if the glyphs are in right
* to left order. Since we want the rightmost insertion
* to be first on the list, we need to append the
* insertions in this case. Otherwise they're prepended.
*
* @internal
*/
le_bool append;
};
#endif /* U_HIDE_INTERNAL_API */
U_NAMESPACE_END
#endif

View File

@@ -1,111 +0,0 @@
/*
*
* (C) Copyright IBM Corp. 1998-2010. All Rights Reserved.
*
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
* YOU REALLY KNOW WHAT YOU'RE DOING.
*
* Generated on: 10/26/2010 02:53:33 PM PDT
*/
#ifndef __LELANGUAGES_H
#define __LELANGUAGES_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: List of language codes for LayoutEngine
*/
U_NAMESPACE_BEGIN
/**
* A provisional list of language codes. For now,
* this is just a list of languages which the LayoutEngine
* supports.
*
* @stable ICU 2.6
*/
enum LanguageCodes {
nullLanguageCode = 0,
araLanguageCode = 1,
asmLanguageCode = 2,
benLanguageCode = 3,
farLanguageCode = 4,
gujLanguageCode = 5,
hinLanguageCode = 6,
iwrLanguageCode = 7,
jiiLanguageCode = 8,
janLanguageCode = 9,
kanLanguageCode = 10,
kokLanguageCode = 11,
korLanguageCode = 12,
kshLanguageCode = 13,
malLanguageCode = 14,
marLanguageCode = 15,
mlrLanguageCode = 16,
mniLanguageCode = 17,
oriLanguageCode = 18,
sanLanguageCode = 19,
sndLanguageCode = 20,
snhLanguageCode = 21,
syrLanguageCode = 22,
tamLanguageCode = 23,
telLanguageCode = 24,
thaLanguageCode = 25,
urdLanguageCode = 26,
zhpLanguageCode = 27,
zhsLanguageCode = 28,
zhtLanguageCode = 29,
/** New language codes added 03/13/2008 @stable ICU 4.0 */
afkLanguageCode = 30,
belLanguageCode = 31,
bgrLanguageCode = 32,
catLanguageCode = 33,
cheLanguageCode = 34,
copLanguageCode = 35,
csyLanguageCode = 36,
danLanguageCode = 37,
deuLanguageCode = 38,
dznLanguageCode = 39,
ellLanguageCode = 40,
engLanguageCode = 41,
espLanguageCode = 42,
etiLanguageCode = 43,
euqLanguageCode = 44,
finLanguageCode = 45,
fraLanguageCode = 46,
gaeLanguageCode = 47,
hauLanguageCode = 48,
hrvLanguageCode = 49,
hunLanguageCode = 50,
hyeLanguageCode = 51,
indLanguageCode = 52,
itaLanguageCode = 53,
khmLanguageCode = 54,
mngLanguageCode = 55,
mtsLanguageCode = 56,
nepLanguageCode = 57,
nldLanguageCode = 58,
pasLanguageCode = 59,
plkLanguageCode = 60,
ptgLanguageCode = 61,
romLanguageCode = 62,
rusLanguageCode = 63,
skyLanguageCode = 64,
slvLanguageCode = 65,
sqiLanguageCode = 66,
srbLanguageCode = 67,
sveLanguageCode = 68,
tibLanguageCode = 69,
trkLanguageCode = 70,
welLanguageCode = 71,
languageCodeCount = 72
};
U_NAMESPACE_END
#endif

View File

@@ -1,253 +0,0 @@
/*
*
* (C) Copyright IBM Corp. 1998-2013. All Rights Reserved.
*
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
* YOU REALLY KNOW WHAT YOU'RE DOING.
*
* Generated on: 11/01/2011 04:08:09 PM PDT
*/
#ifndef __LESCRIPTS_H
#define __LESCRIPTS_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Constants for Unicode script values
*/
U_NAMESPACE_BEGIN
/**
* Constants for Unicode script values, generated using
* ICU4J's <code>UScript</code> class.
*
* @stable ICU 2.2
*/
enum ScriptCodes {
zyyyScriptCode = 0,
zinhScriptCode = 1,
qaaiScriptCode = zinhScriptCode, /* manually added alias, for API stability */
arabScriptCode = 2,
armnScriptCode = 3,
bengScriptCode = 4,
bopoScriptCode = 5,
cherScriptCode = 6,
coptScriptCode = 7,
cyrlScriptCode = 8,
dsrtScriptCode = 9,
devaScriptCode = 10,
ethiScriptCode = 11,
georScriptCode = 12,
gothScriptCode = 13,
grekScriptCode = 14,
gujrScriptCode = 15,
guruScriptCode = 16,
haniScriptCode = 17,
hangScriptCode = 18,
hebrScriptCode = 19,
hiraScriptCode = 20,
kndaScriptCode = 21,
kanaScriptCode = 22,
khmrScriptCode = 23,
laooScriptCode = 24,
latnScriptCode = 25,
mlymScriptCode = 26,
mongScriptCode = 27,
mymrScriptCode = 28,
ogamScriptCode = 29,
italScriptCode = 30,
oryaScriptCode = 31,
runrScriptCode = 32,
sinhScriptCode = 33,
syrcScriptCode = 34,
tamlScriptCode = 35,
teluScriptCode = 36,
thaaScriptCode = 37,
thaiScriptCode = 38,
tibtScriptCode = 39,
/**
* @stable ICU 2.6
*/
cansScriptCode = 40,
/**
* @stable ICU 2.2
*/
yiiiScriptCode = 41,
tglgScriptCode = 42,
hanoScriptCode = 43,
buhdScriptCode = 44,
tagbScriptCode = 45,
/**
* @stable ICU 2.6
*/
braiScriptCode = 46,
cprtScriptCode = 47,
limbScriptCode = 48,
linbScriptCode = 49,
osmaScriptCode = 50,
shawScriptCode = 51,
taleScriptCode = 52,
ugarScriptCode = 53,
/**
* @stable ICU 3.0
*/
hrktScriptCode = 54,
/**
* @stable ICU 3.4
*/
bugiScriptCode = 55,
glagScriptCode = 56,
kharScriptCode = 57,
syloScriptCode = 58,
taluScriptCode = 59,
tfngScriptCode = 60,
xpeoScriptCode = 61,
/**
* @stable ICU 3.6
*/
baliScriptCode = 62,
batkScriptCode = 63,
blisScriptCode = 64,
brahScriptCode = 65,
chamScriptCode = 66,
cirtScriptCode = 67,
cyrsScriptCode = 68,
egydScriptCode = 69,
egyhScriptCode = 70,
egypScriptCode = 71,
geokScriptCode = 72,
hansScriptCode = 73,
hantScriptCode = 74,
hmngScriptCode = 75,
hungScriptCode = 76,
indsScriptCode = 77,
javaScriptCode = 78,
kaliScriptCode = 79,
latfScriptCode = 80,
latgScriptCode = 81,
lepcScriptCode = 82,
linaScriptCode = 83,
mandScriptCode = 84,
mayaScriptCode = 85,
meroScriptCode = 86,
nkooScriptCode = 87,
orkhScriptCode = 88,
permScriptCode = 89,
phagScriptCode = 90,
phnxScriptCode = 91,
plrdScriptCode = 92,
roroScriptCode = 93,
saraScriptCode = 94,
syreScriptCode = 95,
syrjScriptCode = 96,
syrnScriptCode = 97,
tengScriptCode = 98,
vaiiScriptCode = 99,
vispScriptCode = 100,
xsuxScriptCode = 101,
zxxxScriptCode = 102,
zzzzScriptCode = 103,
/**
* @stable ICU 3.8
*/
cariScriptCode = 104,
jpanScriptCode = 105,
lanaScriptCode = 106,
lyciScriptCode = 107,
lydiScriptCode = 108,
olckScriptCode = 109,
rjngScriptCode = 110,
saurScriptCode = 111,
sgnwScriptCode = 112,
sundScriptCode = 113,
moonScriptCode = 114,
mteiScriptCode = 115,
/**
* @stable ICU 4.0
*/
armiScriptCode = 116,
avstScriptCode = 117,
cakmScriptCode = 118,
koreScriptCode = 119,
kthiScriptCode = 120,
maniScriptCode = 121,
phliScriptCode = 122,
phlpScriptCode = 123,
phlvScriptCode = 124,
prtiScriptCode = 125,
samrScriptCode = 126,
tavtScriptCode = 127,
zmthScriptCode = 128,
zsymScriptCode = 129,
/**
* @stable ICU 4.4
*/
bamuScriptCode = 130,
lisuScriptCode = 131,
nkgbScriptCode = 132,
sarbScriptCode = 133,
/**
* @stable ICU 4.6
*/
bassScriptCode = 134,
duplScriptCode = 135,
elbaScriptCode = 136,
granScriptCode = 137,
kpelScriptCode = 138,
lomaScriptCode = 139,
mendScriptCode = 140,
mercScriptCode = 141,
narbScriptCode = 142,
nbatScriptCode = 143,
palmScriptCode = 144,
sindScriptCode = 145,
waraScriptCode = 146,
/**
* @stable ICU 4.8
*/
afakScriptCode = 147,
jurcScriptCode = 148,
mrooScriptCode = 149,
nshuScriptCode = 150,
shrdScriptCode = 151,
soraScriptCode = 152,
takrScriptCode = 153,
tangScriptCode = 154,
woleScriptCode = 155,
/**
* @stable ICU 49
*/
hluwScriptCode = 156, /* bump to match current ICU */
khojScriptCode = 157,
tirhScriptCode = 158,
/**
* @stable ICU 52
*/
aghbScriptCode = 159,
mahjScriptCode = 160,
/**
* @stable ICU 2.2
*/
scriptCodeCount
};
U_NAMESPACE_END
#endif

View File

@@ -1,100 +0,0 @@
/*
*
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
*
*/
#ifndef __LESWAPS_H
#define __LESWAPS_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Endian independent access to data for LayoutEngine
*/
U_NAMESPACE_BEGIN
/**
* A convenience macro which invokes the swapWord member function
* from a concise call.
*
* @stable ICU 2.8
*/
#define SWAPW(value) LESwaps::swapWord((le_uint16)(value))
/**
* A convenience macro which invokes the swapLong member function
* from a concise call.
*
* @stable ICU 2.8
*/
#define SWAPL(value) LESwaps::swapLong((le_uint32)(value))
/**
* This class is used to access data which stored in big endian order
* regardless of the conventions of the platform.
*
* All methods are static and inline in an attempt to induce the compiler
* to do most of the calculations at compile time.
*
* @stable ICU 2.8
*/
class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
public:
/**
* Reads a big-endian 16-bit word and returns a native-endian value.
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
*
* @param value - the word to be byte swapped
*
* @return the byte swapped word
*
* @stable ICU 2.8
*/
static le_uint16 swapWord(le_uint16 value)
{
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
defined(__BIG_ENDIAN__)
// Fastpath when we know that the platform is big-endian.
return value;
#else
// Reads a big-endian value on any platform.
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
return (le_uint16)((p[0] << 8) | p[1]);
#endif
};
/**
* Reads a big-endian 32-bit word and returns a native-endian value.
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
*
* @param value - the long to be byte swapped
*
* @return the byte swapped long
*
* @stable ICU 2.8
*/
static le_uint32 swapLong(le_uint32 value)
{
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
defined(__BIG_ENDIAN__)
// Fastpath when we know that the platform is big-endian.
return value;
#else
// Reads a big-endian value on any platform.
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
return (le_uint32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
#endif
};
private:
LESwaps() {} // private - forbid instantiation
};
U_NAMESPACE_END
#endif

View File

@@ -1,418 +0,0 @@
/*
* -*- c++ -*-
*
* (C) Copyright IBM Corp. and others 2013 - All Rights Reserved
*
* Range checking
*
*/
#ifndef __LETABLEREFERENCE_H
#define __LETABLEREFERENCE_H
#include "LETypes.h"
#include "LEFontInstance.h"
#define kQuestionmarkTableTag 0x3F3F3F3FUL
#define kTildeTableTag 0x7e7e7e7eUL
#ifdef __cplusplus
// internal - interface for range checking
U_NAMESPACE_BEGIN
#if LE_ASSERT_BAD_FONT
class LETableReference; // fwd
/**
* defined in OpenTypeUtilities.cpp
* @internal
*/
extern void _debug_LETableReference(const char *f, int l, const char *msg, const LETableReference *what, const void *ptr, size_t len);
#define LE_DEBUG_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
#define LE_DEBUG_TR3(x,y,z) _debug_LETableReference(__FILE__, __LINE__, x, this, (const void*)y, (size_t)z);
#if 0
#define LE_TRACE_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
#else
#define LE_TRACE_TR(x)
#endif
#else
#define LE_DEBUG_TR(x)
#define LE_DEBUG_TR3(x,y,z)
#define LE_TRACE_TR(x)
#endif
/**
* @internal
*/
class LETableReference {
public:
/**
* @internal
* Construct from a specific tag
*/
LETableReference(const LEFontInstance* font, LETag tableTag, LEErrorCode &success) :
fFont(font), fTag(tableTag), fParent(NULL), fStart(NULL),fLength(LE_UINTPTR_MAX) {
loadTable(success);
LE_TRACE_TR("INFO: new table load")
}
LETableReference(const LETableReference &parent, LEErrorCode &success) : fFont(parent.fFont), fTag(parent.fTag), fParent(&parent), fStart(parent.fStart), fLength(parent.fLength) {
if(LE_FAILURE(success)) {
clear();
}
LE_TRACE_TR("INFO: new clone")
}
LETableReference(const le_uint8* data, size_t length = LE_UINTPTR_MAX) :
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(data), fLength(length) {
LE_TRACE_TR("INFO: new raw")
}
LETableReference() :
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(NULL), fLength(0) {
LE_TRACE_TR("INFO: new empty")
}
~LETableReference() {
fTag=kTildeTableTag;
LE_TRACE_TR("INFO: new dtor")
}
/**
* @internal
* @param length if LE_UINTPTR_MAX means "whole table"
* subset
*/
LETableReference(const LETableReference &parent, size_t offset, size_t length,
LEErrorCode &err) :
fFont(parent.fFont), fTag(parent.fTag), fParent(&parent),
fStart((parent.fStart)+offset), fLength(length) {
if(LE_SUCCESS(err)) {
if(isEmpty()) {
//err = LE_MISSING_FONT_TABLE_ERROR;
clear(); // it's just empty. Not an error.
} else if(offset >= fParent->fLength) {
LE_DEBUG_TR3("offset out of range: (%p) +%d", NULL, offset);
err = LE_INDEX_OUT_OF_BOUNDS_ERROR;
clear();
} else {
if(fLength == LE_UINTPTR_MAX &&
fParent->fLength != LE_UINTPTR_MAX) {
fLength = (fParent->fLength) - offset; // decrement length as base address is incremented
}
if(fLength != LE_UINTPTR_MAX) { // if we have bounds:
if(offset+fLength > fParent->fLength) {
LE_DEBUG_TR3("offset+fLength out of range: (%p) +%d", NULL, offset+fLength);
err = LE_INDEX_OUT_OF_BOUNDS_ERROR; // exceeded
clear();
}
}
}
} else {
clear();
}
LE_TRACE_TR("INFO: new subset")
}
const void* getAlias() const { return (const void*)fStart; }
const void* getAliasRAW() const { LE_DEBUG_TR("getAliasRAW()"); return (const void*)fStart; }
le_bool isEmpty() const { return fStart==NULL || fLength==0; }
le_bool isValid() const { return !isEmpty(); }
le_bool hasBounds() const { return fLength!=LE_UINTPTR_MAX; }
void clear() { fLength=0; fStart=NULL; }
size_t getLength() const { return fLength; }
const LEFontInstance* getFont() const { return fFont; }
LETag getTag() const { return fTag; }
const LETableReference* getParent() const { return fParent; }
void addOffset(size_t offset, LEErrorCode &success) {
if(hasBounds()) {
if(offset > fLength) {
LE_DEBUG_TR("addOffset off end");
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return;
} else {
fLength -= offset;
}
}
fStart += offset;
}
size_t ptrToOffset(const void *atPtr, LEErrorCode &success) const {
if(atPtr==NULL) return 0;
if(LE_FAILURE(success)) return LE_UINTPTR_MAX;
if((atPtr < fStart) ||
(hasBounds() && (atPtr > fStart+fLength))) {
LE_DEBUG_TR3("ptrToOffset args out of range: %p", atPtr, 0);
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return LE_UINTPTR_MAX;
}
return ((const le_uint8*)atPtr)-fStart;
}
/**
* Clamp down the length, for range checking.
*/
size_t contractLength(size_t newLength) {
if(fLength!=LE_UINTPTR_MAX&&newLength>0&&newLength<=fLength) {
fLength = newLength;
}
return fLength;
}
/**
* Throw an error if offset+length off end
*/
public:
size_t verifyLength(size_t offset, size_t length, LEErrorCode &success) {
if(isValid()&&
LE_SUCCESS(success) &&
fLength!=LE_UINTPTR_MAX && length!=LE_UINTPTR_MAX && offset!=LE_UINTPTR_MAX &&
(offset+length)>fLength) {
LE_DEBUG_TR3("verifyLength failed (%p) %d",NULL, offset+length);
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
#if LE_ASSERT_BAD_FONT
fprintf(stderr, "offset=%lu, len=%lu, would be at %p, (%lu) off end. End at %p\n", offset,length, fStart+offset+length, (offset+length-fLength), (offset+length-fLength)+fStart);
#endif
}
return fLength;
}
/**
* Change parent link to another
*/
LETableReference &reparent(const LETableReference &base) {
fParent = &base;
return *this;
}
/**
* remove parent link. Factory functions should do this.
*/
void orphan(void) {
fParent=NULL;
}
protected:
const LEFontInstance* fFont;
LETag fTag;
const LETableReference *fParent;
const le_uint8 *fStart; // keep as 8 bit internally, for pointer math
size_t fLength;
void loadTable(LEErrorCode &success) {
if(LE_SUCCESS(success)) {
fStart = (const le_uint8*)(fFont->getFontTable(fTag, fLength)); // note - a null table is not an error.
}
}
void setRaw(const void *data, size_t length = LE_UINTPTR_MAX) {
fFont = NULL;
fTag = kQuestionmarkTableTag;
fParent = NULL;
fStart = (const le_uint8*)data;
fLength = length;
}
};
template<class T>
class LETableVarSizer {
public:
inline static size_t getSize();
};
// base definition- could override for adjustments
template<class T> inline
size_t LETableVarSizer<T>::getSize() {
return sizeof(T);
}
/**
* \def LE_VAR_ARRAY
* @param x Type (T)
* @param y some member that is of length ANY_NUMBER
* Call this after defining a class, for example:
* LE_VAR_ARRAY(FeatureListTable,featureRecordArray)
* this is roughly equivalent to:
* template<> inline size_t LETableVarSizer<FeatureListTable>::getSize() { return sizeof(FeatureListTable) - (sizeof(le_uint16)*ANY_NUMBER); }
* it's a specialization that informs the LETableReference subclasses to NOT include the variable array in the size.
* dereferencing NULL is valid here because we never actually dereference it, just inside sizeof.
*/
#define LE_VAR_ARRAY(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return sizeof(x) - (sizeof(((const x*)0)->y)); }
/**
* \def LE_CORRECT_SIZE
* @param x type (T)
* @param y fixed size for T
*/
#define LE_CORRECT_SIZE(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return y; }
/**
* Open a new entry based on an existing table
*/
/**
* \def LE_UNBOUNDED_ARRAY
* define an array with no *known* bound. Will trim to available size.
* @internal
*/
#define LE_UNBOUNDED_ARRAY LE_UINT32_MAX
template<class T>
class LEReferenceToArrayOf : public LETableReference {
public:
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, size_t offset, le_uint32 count)
: LETableReference(parent, offset, LE_UINTPTR_MAX, success), fCount(count) {
LE_TRACE_TR("INFO: new RTAO by offset")
if(LE_SUCCESS(success)) {
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
}
if(LE_FAILURE(success)) {
fCount=0;
clear();
}
}
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, le_uint32 count)
: LETableReference(parent, parent.ptrToOffset(array, success), LE_UINTPTR_MAX, success), fCount(count) {
LE_TRACE_TR("INFO: new RTAO")
if(LE_SUCCESS(success)) {
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
}
if(LE_FAILURE(success)) clear();
}
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, size_t offset, le_uint32 count)
: LETableReference(parent, parent.ptrToOffset(array, success)+offset, LE_UINTPTR_MAX, success), fCount(count) {
LE_TRACE_TR("INFO: new RTAO")
if(LE_SUCCESS(success)) {
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
}
if(LE_FAILURE(success)) clear();
}
LEReferenceToArrayOf() :LETableReference(), fCount(0) {}
le_uint32 getCount() const { return fCount; }
using LETableReference::getAlias;
const T *getAlias(le_uint32 i, LEErrorCode &success) const {
return ((const T*)(((const char*)getAlias())+getOffsetFor(i, success)));
}
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
const T& getObject(le_uint32 i, LEErrorCode &success) const {
return *getAlias(i,success);
}
const T& operator()(le_uint32 i, LEErrorCode &success) const {
return *getAlias(i,success);
}
size_t getOffsetFor(le_uint32 i, LEErrorCode &success) const {
if(LE_SUCCESS(success)&&i<getCount()) {
return LETableVarSizer<T>::getSize()*i;
} else {
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
}
return 0;
}
LEReferenceToArrayOf<T> &reparent(const LETableReference &base) {
fParent = &base;
return *this;
}
LEReferenceToArrayOf(const LETableReference& parent, LEErrorCode & success) : LETableReference(parent,0, LE_UINTPTR_MAX, success), fCount(0) {
LE_TRACE_TR("INFO: null RTAO")
}
private:
le_uint32 fCount;
};
template<class T>
class LEReferenceTo : public LETableReference {
public:
/**
* open a sub reference.
* @param parent parent reference
* @param success error status
* @param atPtr location of reference - if NULL, will be at offset zero (i.e. downcast of parent). Otherwise must be a pointer within parent's bounds.
*/
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
: LETableReference(parent, parent.ptrToOffset(atPtr, success), LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
/**
* ptr plus offset
*/
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
: LETableReference(parent, parent.ptrToOffset(atPtr, success)+offset, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
: LETableReference(parent, offset, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
: LETableReference(parent, 0, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
inline LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
: LETableReference(font, tableTag, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
inline LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
inline LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
inline LEReferenceTo() : LETableReference(NULL) {}
inline LEReferenceTo<T>& operator=(const T* other) {
setRaw(other);
return *this;
}
LEReferenceTo<T> &reparent(const LETableReference &base) {
fParent = &base;
return *this;
}
/**
* roll forward by one <T> size.
* same as addOffset(LETableVarSizer<T>::getSize(),success)
*/
void addObject(LEErrorCode &success) {
addOffset(LETableVarSizer<T>::getSize(), success);
}
void addObject(size_t count, LEErrorCode &success) {
addOffset(LETableVarSizer<T>::getSize()*count, success);
}
const T *operator->() const { return getAlias(); }
const T *getAlias() const { return (const T*)fStart; }
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
};
U_NAMESPACE_END
#endif
#endif

View File

@@ -1,728 +0,0 @@
/*
*
* (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
*
*/
#ifndef __LETYPES_H
#define __LETYPES_H
#if !defined(LE_USE_CMEMORY) && (defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_STATIC_IMPLEMENTATION) || defined(U_COMBINED_IMPLEMENTATION))
#define LE_USE_CMEMORY
#endif
#include "unicode/utypes.h"
#ifdef __cplusplus
#include "unicode/uobject.h"
#endif
#ifdef LE_USE_CMEMORY
#include "cmemory.h"
#endif
/*!
* \file
* \brief C API: Basic definitions for the ICU LayoutEngine
*/
/**
* A type used for signed, 32-bit integers.
*
* @stable ICU 2.4
*/
typedef int32_t le_int32;
/**
* A type used for unsigned, 32-bit integers.
*
* @stable ICU 2.4
*/
typedef uint32_t le_uint32;
/**
* A type used for signed, 16-bit integers.
*
* @stable ICU 2.4
*/
typedef int16_t le_int16;
/**
* A type used for unsigned, 16-bit integers.
*
* @stable ICU 2.4
*/
typedef uint16_t le_uint16;
/**
* A type used for signed, 8-bit integers.
*
* @stable ICU 2.4
*/
typedef int8_t le_int8;
/**
* A type used for unsigned, 8-bit integers.
*
* @stable ICU 2.4
*/
typedef uint8_t le_uint8;
/**
* A type used for boolean values.
*
* @stable ICU 2.4
*/
typedef UBool le_bool;
#ifndef NULL
/**
* Used to represent empty pointers.
*
* @stable ICU 2.4
*/
#define NULL 0
#endif
/**
* Used for four character tags.
*
* @stable ICU 2.4
*/
typedef le_uint32 LETag;
/**
* Used for 16-bit glyph indices as they're represented
* in TrueType font tables.
*
* @stable ICU 3.2
*/
typedef le_uint16 TTGlyphID;
/**
* Used for glyph indices. The low-order 16 bits are
* the glyph ID within the font. The next 8 bits are
* the sub-font ID within a compound font. The high-
* order 8 bits are client defined. The LayoutEngine
* will never change or look at the client defined bits.
*
* @stable ICU 3.2
*/
typedef le_uint32 LEGlyphID;
/**
* Used to mask off the glyph ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_GLYPH_MASK 0x0000FFFF
/**
* Used to shift the glyph ID part of an LEGlyphID
* into the low-order bits.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_GLYPH_SHIFT 0
/**
* Used to mask off the sub-font ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_SUB_FONT_MASK 0x00FF0000
/**
* Used to shift the sub-font ID part of an LEGlyphID
* into the low-order bits.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_SUB_FONT_SHIFT 16
/**
* Used to mask off the client-defined part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_CLIENT_MASK 0xFF000000
/**
* Used to shift the sub-font ID part of an LEGlyphID
* into the low-order bits.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_CLIENT_SHIFT 24
/**
* A convenience macro to get the Glyph ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_GET_GLYPH(gid) ((gid & LE_GLYPH_MASK) >> LE_GLYPH_SHIFT)
/**
* A convenience macro to get the sub-font ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_GET_SUB_FONT(gid) ((gid & LE_SUB_FONT_MASK) >> LE_SUB_FONT_SHIFT)
/**
* A convenience macro to get the client-defined part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_GET_CLIENT(gid) ((gid & LE_CLIENT_MASK) >> LE_CLIENT_SHIFT)
/**
* A convenience macro to set the Glyph ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_SET_GLYPH(gid, glyph) ((gid & ~LE_GLYPH_MASK) | ((glyph << LE_GLYPH_SHIFT) & LE_GLYPH_MASK))
/**
* A convenience macro to set the sub-font ID part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_SET_SUB_FONT(gid, font) ((gid & ~LE_SUB_FONT_MASK) | ((font << LE_SUB_FONT_SHIFT) & LE_SUB_FONT_MASK))
/**
* A convenience macro to set the client-defined part of an LEGlyphID.
*
* @see LEGlyphID
* @stable ICU 3.2
*/
#define LE_SET_CLIENT(gid, client) ((gid & ~LE_CLIENT_MASK) | ((client << LE_CLIENT_SHIFT) & LE_CLIENT_MASK))
/**
* Used to represent 16-bit Unicode code points.
*
* @stable ICU 2.4
*/
typedef UChar LEUnicode16;
/**
* Used to represent 32-bit Unicode code points.
*
* @stable ICU 2.4
*/
typedef UChar32 LEUnicode32;
#ifndef U_HIDE_DEPRECATED_API
/**
* Used to represent 16-bit Unicode code points.
*
* @deprecated since ICU 2.4. Use LEUnicode16 instead
*/
typedef UChar LEUnicode;
#endif /* U_HIDE_DEPRECATED_API */
/**
* Used to hold a pair of (x, y) values which represent a point.
*
* @stable ICU 2.4
*/
struct LEPoint
{
/**
* The x coordinate of the point.
*
* @stable ICU 2.4
*/
float fX;
/**
* The y coordinate of the point.
*
* @stable ICU 2.4
*/
float fY;
};
#ifndef __cplusplus
/**
* Used to hold a pair of (x, y) values which represent a point.
*
* @stable ICU 2.4
*/
typedef struct LEPoint LEPoint;
#endif
#ifndef U_HIDE_INTERNAL_API
/**
* \def
* @internal
*/
#ifndef LE_ASSERT_BAD_FONT
#define LE_ASSERT_BAD_FONT 0
#endif
/**
* \def LE_DEBUG_BAD_FONT
* @internal
*/
#if LE_ASSERT_BAD_FONT
#include <stdio.h>
#define LE_DEBUG_BAD_FONT(x) fprintf(stderr,"%s:%d: BAD FONT: %s\n", __FILE__, __LINE__, (x));
#else
#define LE_DEBUG_BAD_FONT(x)
#endif
/**
* \def LE_UINTPTR_MAX
* Max value representable by a uintptr
*/
#ifndef UINT32_MAX
#define LE_UINT32_MAX 0xFFFFFFFFU
#else
#define LE_UINT32_MAX UINT32_MAX
#endif
#ifndef UINTPTR_MAX
#define LE_UINTPTR_MAX LE_UINT32_MAX
#else
#define LE_UINTPTR_MAX UINTPTR_MAX
#endif
/**
* Range check for overflow
*/
#define LE_RANGE_CHECK(type, count, ptrfn) (( (LE_UINTPTR_MAX / sizeof(type)) < (size_t)count ) ? NULL : (ptrfn))
/**
* A convenience macro to get the length of an array.
*
* @internal
*/
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
#ifdef LE_USE_CMEMORY
/**
* A convenience macro for copying an array.
*
* @internal
*/
#define LE_ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
/**
* Allocate an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_NEW_ARRAY(type, count) (type *) LE_RANGE_CHECK(type,count,uprv_malloc((count) * sizeof(type)))
/**
* Re-allocate an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_GROW_ARRAY(array, newSize) uprv_realloc((void *) (array), (newSize) * sizeof (array)[0])
/**
* Free an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_DELETE_ARRAY(array) uprv_free((void *) (array))
#else
/* Not using ICU memory - use C std lib versions */
#include <stdlib.h>
#include <string.h>
/**
* A convenience macro to get the length of an array.
*
* @internal
*/
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
/**
* A convenience macro for copying an array.
*
* @internal
*/
#define LE_ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
/**
* Allocate an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_NEW_ARRAY(type, count) LE_RANGE_CHECK(type,count,(type *) malloc((count) * sizeof(type)))
/**
* Re-allocate an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_GROW_ARRAY(array, newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
/**
* Free an array of basic types. This is used to isolate the rest of
* the LayoutEngine code from cmemory.h.
*
* @internal
*/
#define LE_DELETE_ARRAY(array) free((void *) (array))
#endif
#endif /* U_HIDE_INTERNAL_API */
/**
* A macro to construct the four-letter tags used to
* label TrueType tables, and for script, language and
* feature tags in OpenType tables.
*
* WARNING: THIS MACRO WILL ONLY WORK CORRECTLY IF
* THE ARGUMENT CHARACTERS ARE ASCII.
*
* @stable ICU 3.2
*/
#define LE_MAKE_TAG(a, b, c, d) \
(((le_uint32)(a) << 24) | \
((le_uint32)(b) << 16) | \
((le_uint32)(c) << 8) | \
(le_uint32)(d))
/**
* This enumeration defines constants for the standard
* TrueType, OpenType and AAT table tags.
*
* @stable ICU 3.2
*/
enum LETableTags {
LE_ACNT_TABLE_TAG = 0x61636E74UL, /**< 'acnt' */
LE_AVAR_TABLE_TAG = 0x61766172UL, /**< 'avar' */
LE_BASE_TABLE_TAG = 0x42415345UL, /**< 'BASE' */
LE_BDAT_TABLE_TAG = 0x62646174UL, /**< 'bdat' */
LE_BHED_TABLE_TAG = 0x62686564UL, /**< 'bhed' */
LE_BLOC_TABLE_TAG = 0x626C6F63UL, /**< 'bloc' */
LE_BSLN_TABLE_TAG = 0x62736C6EUL, /**< 'bsln' */
LE_CFF__TABLE_TAG = 0x43464620UL, /**< 'CFF ' */
LE_CMAP_TABLE_TAG = 0x636D6170UL, /**< 'cmap' */
LE_CVAR_TABLE_TAG = 0x63766172UL, /**< 'cvar' */
LE_CVT__TABLE_TAG = 0x63767420UL, /**< 'cvt ' */
LE_DSIG_TABLE_TAG = 0x44534947UL, /**< 'DSIG' */
LE_EBDT_TABLE_TAG = 0x45424454UL, /**< 'EBDT' */
LE_EBLC_TABLE_TAG = 0x45424C43UL, /**< 'EBLC' */
LE_EBSC_TABLE_TAG = 0x45425343UL, /**< 'EBSC' */
LE_FDSC_TABLE_TAG = 0x66647363UL, /**< 'fdsc' */
LE_FEAT_TABLE_TAG = 0x66656174UL, /**< 'feat' */
LE_FMTX_TABLE_TAG = 0x666D7478UL, /**< 'fmtx' */
LE_FPGM_TABLE_TAG = 0x6670676DUL, /**< 'fpgm' */
LE_FVAR_TABLE_TAG = 0x66766172UL, /**< 'fvar' */
LE_GASP_TABLE_TAG = 0x67617370UL, /**< 'gasp' */
LE_GDEF_TABLE_TAG = 0x47444546UL, /**< 'GDEF' */
LE_GLYF_TABLE_TAG = 0x676C7966UL, /**< 'glyf' */
LE_GPOS_TABLE_TAG = 0x47504F53UL, /**< 'GPOS' */
LE_GSUB_TABLE_TAG = 0x47535542UL, /**< 'GSUB' */
LE_GVAR_TABLE_TAG = 0x67766172UL, /**< 'gvar' */
LE_HDMX_TABLE_TAG = 0x68646D78UL, /**< 'hdmx' */
LE_HEAD_TABLE_TAG = 0x68656164UL, /**< 'head' */
LE_HHEA_TABLE_TAG = 0x68686561UL, /**< 'hhea' */
LE_HMTX_TABLE_TAG = 0x686D7478UL, /**< 'hmtx' */
LE_HSTY_TABLE_TAG = 0x68737479UL, /**< 'hsty' */
LE_JUST_TABLE_TAG = 0x6A757374UL, /**< 'just' */
LE_JSTF_TABLE_TAG = 0x4A535446UL, /**< 'JSTF' */
LE_KERN_TABLE_TAG = 0x6B65726EUL, /**< 'kern' */
LE_LCAR_TABLE_TAG = 0x6C636172UL, /**< 'lcar' */
LE_LOCA_TABLE_TAG = 0x6C6F6361UL, /**< 'loca' */
LE_LTSH_TABLE_TAG = 0x4C545348UL, /**< 'LTSH' */
LE_MAXP_TABLE_TAG = 0x6D617870UL, /**< 'maxp' */
LE_MORT_TABLE_TAG = 0x6D6F7274UL, /**< 'mort' */
LE_MORX_TABLE_TAG = 0x6D6F7278UL, /**< 'morx' */
LE_NAME_TABLE_TAG = 0x6E616D65UL, /**< 'name' */
LE_OPBD_TABLE_TAG = 0x6F706264UL, /**< 'opbd' */
LE_OS_2_TABLE_TAG = 0x4F532F32UL, /**< 'OS/2' */
LE_PCLT_TABLE_TAG = 0x50434C54UL, /**< 'PCLT' */
LE_POST_TABLE_TAG = 0x706F7374UL, /**< 'post' */
LE_PREP_TABLE_TAG = 0x70726570UL, /**< 'prep' */
LE_PROP_TABLE_TAG = 0x70726F70UL, /**< 'prop' */
LE_TRAK_TABLE_TAG = 0x7472616BUL, /**< 'trak' */
LE_VDMX_TABLE_TAG = 0x56444D58UL, /**< 'VDMX' */
LE_VHEA_TABLE_TAG = 0x76686561UL, /**< 'vhea' */
LE_VMTX_TABLE_TAG = 0x766D7478UL, /**< 'vmtx' */
LE_VORG_TABLE_TAG = 0x564F5247UL, /**< 'VORG' */
LE_ZAPF_TABLE_TAG = 0x5A617066UL /**< 'Zapf' */
};
/**
* This enumeration defines constants for all
* the common OpenType feature tags.
*
* @stable ICU 3.2
*/
enum LEFeatureTags {
LE_AALT_FEATURE_TAG = 0x61616C74UL, /**< 'aalt' */
LE_ABVF_FEATURE_TAG = 0x61627666UL, /**< 'abvf' */
LE_ABVM_FEATURE_TAG = 0x6162766DUL, /**< 'abvm' */
LE_ABVS_FEATURE_TAG = 0x61627673UL, /**< 'abvs' */
LE_AFRC_FEATURE_TAG = 0x61667263UL, /**< 'afrc' */
LE_AKHN_FEATURE_TAG = 0x616B686EUL, /**< 'akhn' */
LE_BLWF_FEATURE_TAG = 0x626C7766UL, /**< 'blwf' */
LE_BLWM_FEATURE_TAG = 0x626C776DUL, /**< 'blwm' */
LE_BLWS_FEATURE_TAG = 0x626C7773UL, /**< 'blws' */
LE_CALT_FEATURE_TAG = 0x63616C74UL, /**< 'calt' */
LE_CASE_FEATURE_TAG = 0x63617365UL, /**< 'case' */
LE_CCMP_FEATURE_TAG = 0x63636D70UL, /**< 'ccmp' */
LE_CJCT_FEATURE_TAG = 0x636A6374UL, /**< 'cjct' */
LE_CLIG_FEATURE_TAG = 0x636C6967UL, /**< 'clig' */
LE_CPSP_FEATURE_TAG = 0x63707370UL, /**< 'cpsp' */
LE_CSWH_FEATURE_TAG = 0x63737768UL, /**< 'cswh' */
LE_CURS_FEATURE_TAG = 0x63757273UL, /**< 'curs' */
LE_C2SC_FEATURE_TAG = 0x63327363UL, /**< 'c2sc' */
LE_C2PC_FEATURE_TAG = 0x63327063UL, /**< 'c2pc' */
LE_DIST_FEATURE_TAG = 0x64697374UL, /**< 'dist' */
LE_DLIG_FEATURE_TAG = 0x646C6967UL, /**< 'dlig' */
LE_DNOM_FEATURE_TAG = 0x646E6F6DUL, /**< 'dnom' */
LE_EXPT_FEATURE_TAG = 0x65787074UL, /**< 'expt' */
LE_FALT_FEATURE_TAG = 0x66616C74UL, /**< 'falt' */
LE_FIN2_FEATURE_TAG = 0x66696E32UL, /**< 'fin2' */
LE_FIN3_FEATURE_TAG = 0x66696E33UL, /**< 'fin3' */
LE_FINA_FEATURE_TAG = 0x66696E61UL, /**< 'fina' */
LE_FRAC_FEATURE_TAG = 0x66726163UL, /**< 'frac' */
LE_FWID_FEATURE_TAG = 0x66776964UL, /**< 'fwid' */
LE_HALF_FEATURE_TAG = 0x68616C66UL, /**< 'half' */
LE_HALN_FEATURE_TAG = 0x68616C6EUL, /**< 'haln' */
LE_HALT_FEATURE_TAG = 0x68616C74UL, /**< 'halt' */
LE_HIST_FEATURE_TAG = 0x68697374UL, /**< 'hist' */
LE_HKNA_FEATURE_TAG = 0x686B6E61UL, /**< 'hkna' */
LE_HLIG_FEATURE_TAG = 0x686C6967UL, /**< 'hlig' */
LE_HNGL_FEATURE_TAG = 0x686E676CUL, /**< 'hngl' */
LE_HWID_FEATURE_TAG = 0x68776964UL, /**< 'hwid' */
LE_INIT_FEATURE_TAG = 0x696E6974UL, /**< 'init' */
LE_ISOL_FEATURE_TAG = 0x69736F6CUL, /**< 'isol' */
LE_ITAL_FEATURE_TAG = 0x6974616CUL, /**< 'ital' */
LE_JALT_FEATURE_TAG = 0x6A616C74UL, /**< 'jalt' */
LE_JP78_FEATURE_TAG = 0x6A703738UL, /**< 'jp78' */
LE_JP83_FEATURE_TAG = 0x6A703833UL, /**< 'jp83' */
LE_JP90_FEATURE_TAG = 0x6A703930UL, /**< 'jp90' */
LE_KERN_FEATURE_TAG = 0x6B65726EUL, /**< 'kern' */
LE_LFBD_FEATURE_TAG = 0x6C666264UL, /**< 'lfbd' */
LE_LIGA_FEATURE_TAG = 0x6C696761UL, /**< 'liga' */
LE_LJMO_FEATURE_TAG = 0x6C6A6D6FUL, /**< 'ljmo' */
LE_LNUM_FEATURE_TAG = 0x6C6E756DUL, /**< 'lnum' */
LE_LOCL_FEATURE_TAG = 0x6C6F636CUL, /**< 'locl' */
LE_MARK_FEATURE_TAG = 0x6D61726BUL, /**< 'mark' */
LE_MED2_FEATURE_TAG = 0x6D656432UL, /**< 'med2' */
LE_MEDI_FEATURE_TAG = 0x6D656469UL, /**< 'medi' */
LE_MGRK_FEATURE_TAG = 0x6D67726BUL, /**< 'mgrk' */
LE_MKMK_FEATURE_TAG = 0x6D6B6D6BUL, /**< 'mkmk' */
LE_MSET_FEATURE_TAG = 0x6D736574UL, /**< 'mset' */
LE_NALT_FEATURE_TAG = 0x6E616C74UL, /**< 'nalt' */
LE_NLCK_FEATURE_TAG = 0x6E6C636BUL, /**< 'nlck' */
LE_NUKT_FEATURE_TAG = 0x6E756B74UL, /**< 'nukt' */
LE_NUMR_FEATURE_TAG = 0x6E756D72UL, /**< 'numr' */
LE_ONUM_FEATURE_TAG = 0x6F6E756DUL, /**< 'onum' */
LE_OPBD_FEATURE_TAG = 0x6F706264UL, /**< 'opbd' */
LE_ORDN_FEATURE_TAG = 0x6F72646EUL, /**< 'ordn' */
LE_ORNM_FEATURE_TAG = 0x6F726E6DUL, /**< 'ornm' */
LE_PALT_FEATURE_TAG = 0x70616C74UL, /**< 'palt' */
LE_PCAP_FEATURE_TAG = 0x70636170UL, /**< 'pcap' */
LE_PNUM_FEATURE_TAG = 0x706E756DUL, /**< 'pnum' */
LE_PREF_FEATURE_TAG = 0x70726566UL, /**< 'pref' */
LE_PRES_FEATURE_TAG = 0x70726573UL, /**< 'pres' */
LE_PSTF_FEATURE_TAG = 0x70737466UL, /**< 'pstf' */
LE_PSTS_FEATURE_TAG = 0x70737473UL, /**< 'psts' */
LE_PWID_FEATURE_TAG = 0x70776964UL, /**< 'pwid' */
LE_QWID_FEATURE_TAG = 0x71776964UL, /**< 'qwid' */
LE_RAND_FEATURE_TAG = 0x72616E64UL, /**< 'rand' */
LE_RLIG_FEATURE_TAG = 0x726C6967UL, /**< 'rlig' */
LE_RPHF_FEATURE_TAG = 0x72706866UL, /**< 'rphf' */
LE_RKRF_FEATURE_TAG = 0x726B7266UL, /**< 'rkrf' */
LE_RTBD_FEATURE_TAG = 0x72746264UL, /**< 'rtbd' */
LE_RTLA_FEATURE_TAG = 0x72746C61UL, /**< 'rtla' */
LE_RUBY_FEATURE_TAG = 0x72756279UL, /**< 'ruby' */
LE_SALT_FEATURE_TAG = 0x73616C74UL, /**< 'salt' */
LE_SINF_FEATURE_TAG = 0x73696E66UL, /**< 'sinf' */
LE_SIZE_FEATURE_TAG = 0x73697A65UL, /**< 'size' */
LE_SMCP_FEATURE_TAG = 0x736D6370UL, /**< 'smcp' */
LE_SMPL_FEATURE_TAG = 0x736D706CUL, /**< 'smpl' */
LE_SS01_FEATURE_TAG = 0x73733031UL, /**< 'ss01' */
LE_SS02_FEATURE_TAG = 0x73733032UL, /**< 'ss02' */
LE_SS03_FEATURE_TAG = 0x73733033UL, /**< 'ss03' */
LE_SS04_FEATURE_TAG = 0x73733034UL, /**< 'ss04' */
LE_SS05_FEATURE_TAG = 0x73733035UL, /**< 'ss05' */
LE_SS06_FEATURE_TAG = 0x73733036UL, /**< 'ss06' */
LE_SS07_FEATURE_TAG = 0x73733037UL, /**< 'ss07' */
LE_SS08_FEATURE_TAG = 0x73733038UL, /**< 'ss08' */
LE_SS09_FEATURE_TAG = 0x73733039UL, /**< 'ss09' */
LE_SS10_FEATURE_TAG = 0x73733130UL, /**< 'ss10' */
LE_SS11_FEATURE_TAG = 0x73733131UL, /**< 'ss11' */
LE_SS12_FEATURE_TAG = 0x73733132UL, /**< 'ss12' */
LE_SS13_FEATURE_TAG = 0x73733133UL, /**< 'ss13' */
LE_SS14_FEATURE_TAG = 0x73733134UL, /**< 'ss14' */
LE_SS15_FEATURE_TAG = 0x73733135UL, /**< 'ss15' */
LE_SS16_FEATURE_TAG = 0x73733136UL, /**< 'ss16' */
LE_SS17_FEATURE_TAG = 0x73733137UL, /**< 'ss17' */
LE_SS18_FEATURE_TAG = 0x73733138UL, /**< 'ss18' */
LE_SS19_FEATURE_TAG = 0x73733139UL, /**< 'ss19' */
LE_SS20_FEATURE_TAG = 0x73733230UL, /**< 'ss20' */
LE_SUBS_FEATURE_TAG = 0x73756273UL, /**< 'subs' */
LE_SUPS_FEATURE_TAG = 0x73757073UL, /**< 'sups' */
LE_SWSH_FEATURE_TAG = 0x73777368UL, /**< 'swsh' */
LE_TITL_FEATURE_TAG = 0x7469746CUL, /**< 'titl' */
LE_TJMO_FEATURE_TAG = 0x746A6D6FUL, /**< 'tjmo' */
LE_TNAM_FEATURE_TAG = 0x746E616DUL, /**< 'tnam' */
LE_TNUM_FEATURE_TAG = 0x746E756DUL, /**< 'tnum' */
LE_TRAD_FEATURE_TAG = 0x74726164UL, /**< 'trad' */
LE_TWID_FEATURE_TAG = 0x74776964UL, /**< 'twid' */
LE_UNIC_FEATURE_TAG = 0x756E6963UL, /**< 'unic' */
LE_VALT_FEATURE_TAG = 0x76616C74UL, /**< 'valt' */
LE_VATU_FEATURE_TAG = 0x76617475UL, /**< 'vatu' */
LE_VERT_FEATURE_TAG = 0x76657274UL, /**< 'vert' */
LE_VHAL_FEATURE_TAG = 0x7668616CUL, /**< 'vhal' */
LE_VJMO_FEATURE_TAG = 0x766A6D6FUL, /**< 'vjmo' */
LE_VKNA_FEATURE_TAG = 0x766B6E61UL, /**< 'vkna' */
LE_VKRN_FEATURE_TAG = 0x766B726EUL, /**< 'vkrn' */
LE_VPAL_FEATURE_TAG = 0x7670616CUL, /**< 'vpal' */
LE_VRT2_FEATURE_TAG = 0x76727432UL, /**< 'vrt2' */
LE_ZERO_FEATURE_TAG = 0x7A65726FUL /**< 'zero' */
};
/**
* @internal
*/
enum LEFeatureENUMs {
LE_Kerning_FEATURE_ENUM = 0, /**< Requests Kerning. Formerly LayoutEngine::kTypoFlagKern */
LE_Ligatures_FEATURE_ENUM = 1, /**< Requests Ligatures. Formerly LayoutEngine::kTypoFlagLiga */
LE_CLIG_FEATURE_ENUM, /**< Feature specific enum */
LE_DLIG_FEATURE_ENUM, /**< Feature specific enum */
LE_HLIG_FEATURE_ENUM, /**< Feature specific enum */
LE_LIGA_FEATURE_ENUM, /**< Feature specific enum */
LE_RLIG_FEATURE_ENUM, /**< Feature specific enum */
LE_SMCP_FEATURE_ENUM, /**< Feature specific enum */
LE_FRAC_FEATURE_ENUM, /**< Feature specific enum */
LE_AFRC_FEATURE_ENUM, /**< Feature specific enum */
LE_ZERO_FEATURE_ENUM, /**< Feature specific enum */
LE_SWSH_FEATURE_ENUM, /**< Feature specific enum */
LE_CSWH_FEATURE_ENUM, /**< Feature specific enum */
LE_SALT_FEATURE_ENUM, /**< Feature specific enum */
LE_NALT_FEATURE_ENUM, /**< Feature specific enum */
LE_RUBY_FEATURE_ENUM, /**< Feature specific enum */
LE_SS01_FEATURE_ENUM, /**< Feature specific enum */
LE_SS02_FEATURE_ENUM, /**< Feature specific enum */
LE_SS03_FEATURE_ENUM, /**< Feature specific enum */
LE_SS04_FEATURE_ENUM, /**< Feature specific enum */
LE_SS05_FEATURE_ENUM, /**< Feature specific enum */
LE_SS06_FEATURE_ENUM, /**< Feature specific enum */
LE_SS07_FEATURE_ENUM, /**< Feature specific enum */
LE_CHAR_FILTER_FEATURE_ENUM = 31, /**< Apply CharSubstitutionFilter */
LE_FEATURE_ENUM_MAX = LE_CHAR_FILTER_FEATURE_ENUM
};
/**
* Flags for typographic features.
* @internal
* @{
*/
#define LE_Kerning_FEATURE_FLAG (1 << LE_Kerning_FEATURE_ENUM)
#define LE_Ligatures_FEATURE_FLAG (1 << LE_Ligatures_FEATURE_ENUM)
#define LE_CLIG_FEATURE_FLAG (1 << LE_CLIG_FEATURE_ENUM)
#define LE_DLIG_FEATURE_FLAG (1 << LE_DLIG_FEATURE_ENUM)
#define LE_HLIG_FEATURE_FLAG (1 << LE_HLIG_FEATURE_ENUM)
#define LE_LIGA_FEATURE_FLAG (1 << LE_LIGA_FEATURE_ENUM)
#define LE_RLIG_FEATURE_FLAG (1 << LE_RLIG_FEATURE_ENUM)
#define LE_SMCP_FEATURE_FLAG (1 << LE_SMCP_FEATURE_ENUM)
#define LE_FRAC_FEATURE_FLAG (1 << LE_FRAC_FEATURE_ENUM)
#define LE_AFRC_FEATURE_FLAG (1 << LE_AFRC_FEATURE_ENUM)
#define LE_ZERO_FEATURE_FLAG (1 << LE_ZERO_FEATURE_ENUM)
#define LE_SWSH_FEATURE_FLAG (1 << LE_SWSH_FEATURE_ENUM)
#define LE_CSWH_FEATURE_FLAG (1 << LE_CSWH_FEATURE_ENUM)
#define LE_SALT_FEATURE_FLAG (1 << LE_SALT_FEATURE_ENUM)
#define LE_NALT_FEATURE_FLAG (1 << LE_NALT_FEATURE_ENUM)
#define LE_RUBY_FEATURE_FLAG (1 << LE_RUBY_FEATURE_ENUM)
#define LE_SS01_FEATURE_FLAG (1 << LE_SS01_FEATURE_ENUM)
#define LE_SS02_FEATURE_FLAG (1 << LE_SS02_FEATURE_ENUM)
#define LE_SS03_FEATURE_FLAG (1 << LE_SS03_FEATURE_ENUM)
#define LE_SS04_FEATURE_FLAG (1 << LE_SS04_FEATURE_ENUM)
#define LE_SS05_FEATURE_FLAG (1 << LE_SS05_FEATURE_ENUM)
#define LE_SS06_FEATURE_FLAG (1 << LE_SS06_FEATURE_ENUM)
#define LE_SS07_FEATURE_FLAG (1 << LE_SS07_FEATURE_ENUM)
#define LE_CHAR_FILTER_FEATURE_FLAG (1 << LE_CHAR_FILTER_FEATURE_ENUM)
/**
* @}
*/
#define LE_DEFAULT_FEATURE_FLAG (LE_Kerning_FEATURE_FLAG | LE_Ligatures_FEATURE_FLAG) /**< default features */
/**
* Error codes returned by the LayoutEngine.
*
* @stable ICU 2.4
*/
enum LEErrorCode {
/* informational */
LE_NO_SUBFONT_WARNING = U_USING_DEFAULT_WARNING, /**< The font does not contain subfonts. */
/* success */
LE_NO_ERROR = U_ZERO_ERROR, /**< No error, no warning. */
/* failures */
LE_ILLEGAL_ARGUMENT_ERROR = U_ILLEGAL_ARGUMENT_ERROR, /**< An illegal argument was detected. */
LE_MEMORY_ALLOCATION_ERROR = U_MEMORY_ALLOCATION_ERROR, /**< Memory allocation error. */
LE_INDEX_OUT_OF_BOUNDS_ERROR = U_INDEX_OUTOFBOUNDS_ERROR, /**< Trying to access an index that is out of bounds. */
LE_NO_LAYOUT_ERROR = U_UNSUPPORTED_ERROR, /**< You must call layoutChars() first. */
LE_INTERNAL_ERROR = U_INTERNAL_PROGRAM_ERROR, /**< An internal error was encountered. */
LE_FONT_FILE_NOT_FOUND_ERROR = U_FILE_ACCESS_ERROR, /**< The requested font file cannot be opened. */
LE_MISSING_FONT_TABLE_ERROR = U_MISSING_RESOURCE_ERROR /**< The requested font table does not exist. */
};
#ifndef __cplusplus
/**
* Error codes returned by the LayoutEngine.
*
* @stable ICU 2.4
*/
typedef enum LEErrorCode LEErrorCode;
#endif
/**
* A convenience macro to test for the success of a LayoutEngine call.
*
* @stable ICU 2.4
*/
#define LE_SUCCESS(code) (U_SUCCESS((UErrorCode)code))
/**
* A convenience macro to test for the failure of a LayoutEngine call.
*
* @stable ICU 2.4
*/
#define LE_FAILURE(code) (U_FAILURE((UErrorCode)code))
#endif

View File

@@ -1,511 +0,0 @@
/*
* (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
*/
#ifndef __LAYOUTENGINE_H
#define __LAYOUTENGINE_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Virtual base class for complex text layout.
*/
U_NAMESPACE_BEGIN
class LEFontInstance;
class LEGlyphFilter;
class LEGlyphStorage;
/**
* This is a virtual base class used to do complex text layout. The text must all
* be in a single font, script, and language. An instance of a LayoutEngine can be
* created by calling the layoutEngineFactory method. Fonts are identified by
* instances of the LEFontInstance class. Script and language codes are identified
* by integer codes, which are defined in ScriptAndLanuageTags.h.
*
* Note that this class is not public API. It is declared public so that it can be
* exported from the library that it is a part of.
*
* The input to the layout process is an array of characters in logical order,
* and a starting X, Y position for the text. The output is an array of glyph indices,
* an array of character indices for the glyphs, and an array of glyph positions.
* These arrays are protected members of LayoutEngine which can be retreived by a
* public method. The reset method can be called to free these arrays so that the
* LayoutEngine can be reused.
*
* The layout process is done in three steps. There is a protected virtual method
* for each step. These methods have a default implementation which only does
* character to glyph mapping and default positioning using the glyph's advance
* widths. Subclasses can override these methods for more advanced layout.
* There is a public method which invokes the steps in the correct order.
*
* The steps are:
*
* 1) Glyph processing - character to glyph mapping and any other glyph processing
* such as ligature substitution and contextual forms.
*
* 2) Glyph positioning - position the glyphs based on their advance widths.
*
* 3) Glyph position adjustments - adjustment of glyph positions for kerning,
* accent placement, etc.
*
* NOTE: in all methods below, output parameters are references to pointers so
* the method can allocate and free the storage as needed. All storage allocated
* in this way is owned by the object which created it, and will be freed when it
* is no longer needed, or when the object's destructor is invoked.
*
* @see LEFontInstance
* @see ScriptAndLanguageTags.h
*
* @stable ICU 2.8
*/
class U_LAYOUT_API LayoutEngine : public UObject {
public:
#ifndef U_HIDE_INTERNAL_API
/** @internal Flag to request kerning. Use LE_Kerning_FEATURE_FLAG instead. */
static const le_int32 kTypoFlagKern;
/** @internal Flag to request ligatures. Use LE_Ligatures_FEATURE_FLAG instead. */
static const le_int32 kTypoFlagLiga;
#endif /* U_HIDE_INTERNAL_API */
protected:
/**
* The object which holds the glyph storage
*
* @internal
*/
LEGlyphStorage *fGlyphStorage;
/**
* The font instance for the text font.
*
* @see LEFontInstance
*
* @internal
*/
const LEFontInstance *fFontInstance;
/**
* The script code for the text
*
* @see ScriptAndLanguageTags.h for script codes.
*
* @internal
*/
le_int32 fScriptCode;
/**
* The langauge code for the text
*
* @see ScriptAndLanguageTags.h for language codes.
*
* @internal
*/
le_int32 fLanguageCode;
/**
* The typographic control flags
*
* @internal
*/
le_int32 fTypoFlags;
/**
* <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
* with no contours.
*
* @internal
*/
le_bool fFilterZeroWidth;
#ifndef U_HIDE_INTERNAL_API
/**
* This constructs an instance for a given font, script and language. Subclass constructors
* must call this constructor.
*
* @param fontInstance - the font for the text
* @param scriptCode - the script for the text
* @param languageCode - the language for the text
* @param typoFlags - the typographic control flags for the text (a bitfield). Use kTypoFlagKern
* if kerning is desired, kTypoFlagLiga if ligature formation is desired. Others are reserved.
* @param success - set to an error code if the operation fails
*
* @see LEFontInstance
* @see ScriptAndLanguageTags.h
*
* @internal
*/
LayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode,
le_int32 languageCode,
le_int32 typoFlags,
LEErrorCode &success);
#endif /* U_HIDE_INTERNAL_API */
// Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
// or else the compiler will create a public default constructor.
/**
* This overrides the default no argument constructor to make it
* difficult for clients to call it. Clients are expected to call
* layoutEngineFactory.
*
* @internal
*/
LayoutEngine();
/**
* This method does any required pre-processing to the input characters. It
* may generate output characters that differ from the input charcters due to
* insertions, deletions, or reorderings. In such cases, it will also generate an
* output character index array reflecting these changes.
*
* Subclasses must override this method.
*
* Input parameters:
* @param chars - the input character context
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - TRUE if the characters are in a right to left directional run
* @param outChars - the output character array, if different from the input
* @param glyphStorage - the object that holds the per-glyph storage. The character index array may be set.
* @param success - set to an error code if the operation fails
*
* @return the output character count (input character count if no change)
*
* @internal
*/
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method does the glyph processing. It converts an array of characters
* into an array of glyph indices and character indices. The characters to be
* processed are passed in a surrounding context. The context is specified as
* a starting address and a maximum character count. An offset and a count are
* used to specify the characters to be processed.
*
* The default implementation of this method only does character to glyph mapping.
* Subclasses needing more elaborate glyph processing must override this method.
*
* Input parameters:
* @param chars - the character context
* @param offset - the offset of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the context.
* @param rightToLeft - TRUE if the text is in a right to left directional run
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char indices arrays
* will be set.
*
* Output parameters:
* @param success - set to an error code if the operation fails
*
* @return the number of glyphs in the glyph index array
*
* @internal
*/
virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method does basic glyph positioning. The default implementation positions
* the glyphs based on their advance widths. This is sufficient for most uses. It
* is not expected that many subclasses will override this method.
*
* Input parameters:
* @param glyphStorage - the object which holds the per-glyph storage. The glyph position array will be set.
* @param x - the starting X position
* @param y - the starting Y position
* @param success - set to an error code if the operation fails
*
* @internal
*/
virtual void positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success);
/**
* This method does positioning adjustments like accent positioning and
* kerning. The default implementation does nothing. Subclasses needing
* position adjustments must override this method.
*
* Note that this method has both characters and glyphs as input so that
* it can use the character codes to determine glyph types if that information
* isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
* table)
*
* @param chars - the input character context
* @param offset - the offset of the first character to process
* @param count - the number of characters to process
* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
* @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
* adjusted as needed.
* @param success - output parameter set to an error code if the operation fails
*
* @internal
*/
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method gets a table from the font associated with
* the text. The default implementation gets the table from
* the font instance. Subclasses which need to get the tables
* some other way must override this method.
*
* @param tableTag - the four byte table tag.
* @param length - length to use
*
* @return the address of the table.
*
* @internal
*/
virtual const void *getFontTable(LETag tableTag, size_t &length) const;
/**
* @deprecated
*/
virtual const void *getFontTable(LETag tableTag) const { size_t ignored; return getFontTable(tableTag, ignored); }
/**
* This method does character to glyph mapping. The default implementation
* uses the font instance to do the mapping. It will allocate the glyph and
* character index arrays if they're not already allocated. If it allocates the
* character index array, it will fill it it.
*
* This method supports right to left
* text with the ability to store the glyphs in reverse order, and by supporting
* character mirroring, which will replace a character which has a left and right
* form, such as parens, with the opposite form before mapping it to a glyph index.
*
* Input parameters:
* @param chars - the input character context
* @param offset - the offset of the first character to be mapped
* @param count - the number of characters to be mapped
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
* @param mirror - if <code>TRUE</code>, do character mirroring
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char
* indices arrays will be filled in.
* @param success - set to an error code if the operation fails
*
* @see LEFontInstance
*
* @internal
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphStorage &glyphStorage, LEErrorCode &success);
#ifndef U_HIDE_INTERNAL_API
/**
* This is a convenience method that forces the advance width of mark
* glyphs to be zero, which is required for proper selection and highlighting.
*
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
* @param markFilter - used to identify mark glyphs
* @param success - output parameter set to an error code if the operation fails
*
* @see LEGlyphFilter
*
* @internal
*/
static void adjustMarkGlyphs(LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
/**
* This is a convenience method that forces the advance width of mark
* glyphs to be zero, which is required for proper selection and highlighting.
* This method uses the input characters to identify marks. This is required in
* cases where the font does not contain enough information to identify them based
* on the glyph IDs.
*
* @param chars - the array of input characters
* @param charCount - the number of input characers
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
* @param reverse - <code>TRUE</code> if the glyph array has been reordered
* @param markFilter - used to identify mark glyphs
* @param success - output parameter set to an error code if the operation fails
*
* @see LEGlyphFilter
*
* @internal
*/
static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
#endif /* U_HIDE_INTERNAL_API */
public:
/**
* The destructor. It will free any storage allocated for the
* glyph, character index and position arrays by calling the reset
* method. It is declared virtual so that it will be invoked by the
* subclass destructors.
*
* @stable ICU 2.8
*/
virtual ~LayoutEngine();
/**
* This method will invoke the layout steps in their correct order by calling
* the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. It will
* compute the glyph, character index and position arrays.
*
* @param chars - the input character context
* @param offset - the offset of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - TRUE if the characers are in a right to left directional run
* @param x - the initial X position
* @param y - the initial Y position
* @param success - output parameter set to an error code if the operation fails
*
* @return the number of glyphs in the glyph array
*
* Note: The glyph, character index and position array can be accessed
* using the getter methods below.
*
* Note: If you call this method more than once, you must call the reset()
* method first to free the glyph, character index and position arrays
* allocated by the previous call.
*
* @stable ICU 2.8
*/
virtual le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success);
/**
* This method returns the number of glyphs in the glyph array. Note
* that the number of glyphs will be greater than or equal to the number
* of characters used to create the LayoutEngine.
*
* @return the number of glyphs in the glyph array
*
* @stable ICU 2.8
*/
le_int32 getGlyphCount() const;
/**
* This method copies the glyph array into a caller supplied array.
* The caller must ensure that the array is large enough to hold all
* the glyphs.
*
* @param glyphs - the destiniation glyph array
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
/**
* This method copies the glyph array into a caller supplied array,
* ORing in extra bits. (This functionality is needed by the JDK,
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
* the composite font slot number)
*
* @param glyphs - the destination (32 bit) glyph array
* @param extraBits - this value will be ORed with each glyph index
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
/**
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
/**
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param indexBase - an offset which will be added to each index
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
/**
* This method copies the position array into a caller supplied array.
* The caller must ensure that the array is large enough to hold an
* X and Y position for each glyph, plus an extra X and Y for the
* advance of the last glyph.
*
* @param positions - the destiniation position array
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
void getGlyphPositions(float positions[], LEErrorCode &success) const;
/**
* This method returns the X and Y position of the glyph at
* the given index.
*
* Input parameters:
* @param glyphIndex - the index of the glyph
*
* Output parameters:
* @param x - the glyph's X position
* @param y - the glyph's Y position
* @param success - set to an error code if the operation fails
*
* @stable ICU 2.8
*/
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
/**
* This method frees the glyph, character index and position arrays
* so that the LayoutEngine can be reused to layout a different
* characer array. (This method is also called by the destructor)
*
* @stable ICU 2.8
*/
virtual void reset();
/**
* This method returns a LayoutEngine capable of laying out text
* in the given font, script and langauge. Note that the LayoutEngine
* returned may be a subclass of LayoutEngine.
*
* @param fontInstance - the font of the text
* @param scriptCode - the script of the text
* @param languageCode - the language of the text
* @param success - output parameter set to an error code if the operation fails
*
* @return a LayoutEngine which can layout text in the given font.
*
* @see LEFontInstance
*
* @stable ICU 2.8
*/
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
/**
* Override of existing call that provides flags to control typography.
* @stable ICU 3.4
*/
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success);
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
};
U_NAMESPACE_END
#endif

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