+++ /dev/null
-config-devices.*
-config-all-devices.*
-config-host.*
-config-target.*
-trace.h
-trace.c
-trace-dtrace.h
-trace-dtrace.dtrace
-*-timestamp
-*-softmmu
-*-darwin-user
-*-linux-user
-*-bsd-user
-libdis*
-libhw32
-libhw64
-libuser
-linux-headers/asm
-qapi-generated
-qapi-types.[ch]
-qapi-visit.[ch]
-qmp-commands.h
-qmp-marshal.c
-qemu-doc.html
-qemu-tech.html
-qemu-doc.info
-qemu-tech.info
-qemu.1
-qemu.pod
-qemu-img.1
-qemu-img.pod
-qemu-img
-qemu-nbd
-qemu-nbd.8
-qemu-nbd.pod
-qemu-options.def
-qemu-options.texi
-qemu-img-cmds.texi
-qemu-img-cmds.h
-qemu-io
-qemu-ga
-qemu-bridge-helper
-qemu-monitor.texi
-vscclient
-QMP/qmp-commands.txt
-test-coroutine
-test-qmp-input-visitor
-test-qmp-output-visitor
-test-string-input-visitor
-test-string-output-visitor
-test-visitor-serialization
-fsdev/virtfs-proxy-helper.1
-fsdev/virtfs-proxy-helper.pod
-.gdbinit
-*.a
-*.aux
-*.cp
-*.dvi
-*.exe
-*.fn
-*.ky
-*.log
-*.pdf
-*.cps
-*.fns
-*.kys
-*.pg
-*.pyc
-*.toc
-*.tp
-*.vr
-*.d
-*.o
-*.lo
-*.la
-*.pc
-.libs
-*.swp
-*.orig
-.pc
-patches
-pc-bios/bios-pq/status
-pc-bios/vgabios-pq/status
-pc-bios/optionrom/linuxboot.bin
-pc-bios/optionrom/linuxboot.raw
-pc-bios/optionrom/linuxboot.img
-pc-bios/optionrom/multiboot.bin
-pc-bios/optionrom/multiboot.raw
-pc-bios/optionrom/multiboot.img
-pc-bios/optionrom/kvmvapic.bin
-pc-bios/optionrom/kvmvapic.raw
-pc-bios/optionrom/kvmvapic.img
-.stgit-*
-cscope.*
-tags
-TAGS
-*~
-tizen/emulator
-tizen/src/build_info.h
-tizen/src/skin/client/src/about.properties
-tizen/src/skin/client/bin
-tizen/src/skin/client/build
-tizen/src/skin/client/emulator-skin.jar
-tizen/src/skin/client/lib
-tizen/src/skin/client/native_src/*.so
-tizen/src/skin/client/native_src/*.dynlib
-tizen/src/check-cam
-fsdev/virtfs-proxy-helper
-.cproject
-.project
-
+++ /dev/null
-[submodule "roms/vgabios"]
- path = roms/vgabios
- url = git://git.qemu.org/vgabios.git/
-[submodule "roms/seabios"]
- path = roms/seabios
- url = git://git.qemu.org/seabios.git/
-[submodule "roms/SLOF"]
- path = roms/SLOF
- url = git://git.qemu.org/SLOF.git
-[submodule "roms/ipxe"]
- path = roms/ipxe
- url = git://git.qemu.org/ipxe.git
-[submodule "roms/openbios"]
- path = roms/openbios
- url = git://git.qemu.org/openbios.git
-[submodule "roms/qemu-palcode"]
- path = roms/qemu-palcode
- url = git://repo.or.cz/qemu-palcode.git
-[submodule "roms/sgabios"]
- path = roms/sgabios
- url = git://git.qemu.org/sgabios.git
+++ /dev/null
-# This mailmap just translates the weird addresses from the original import into git
-# into proper addresses so that they are counted properly in git shortlog output.
-#
-Andrzej Zaborowski <balrogg@gmail.com> balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>
-Anthony Liguori <aliguori@us.ibm.com> aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
-Aurelien Jarno <aurelien@aurel32.net> aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
-Blue Swirl <blauwirbel@gmail.com> blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>
-Edgar E. Iglesias <edgar.iglesias@gmail.com> edgar_igl <edgar_igl@c046a42c-6fe2-441c-8c8c-71466251a162>
-Fabrice Bellard <fabrice@bellard.org> bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
-Jocelyn Mayer <l_indien@magic.fr> j_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>
-Paul Brook <paul@codesourcery.com> pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
-Thiemo Seufer <ths@networkno.de> ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
-malc <av1474@comtv.ru> malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>
-# There is also a:
-# (no author) <(no author)@c046a42c-6fe2-441c-8c8c-71466251a162>
-# for the cvs2svn initialization commit e63c3dc74bf.
+++ /dev/null
-prefix=/home/stas/Projects/qemu/gl/dgles2/../lib/Linux/x86
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: egl
-Description: DGLES egl library
-Version: 1.4.2
-Libs: -L${libdir} -lEGL
-Cflags: -I${includedir}
+++ /dev/null
-prefix=/home/stas/Projects/qemu/gl/dgles2/../lib/Linux/x86
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: glesv1_cm
-Description: DGLES OpenGL ES 1.1 CM library
-Requires.private: egl
-Version: 1.4.1
-Libs: -L${libdir} -lGLES_CM
-Cflags: -I${includedir}
+++ /dev/null
-prefix=/home/stas/Projects/qemu/gl/dgles2/../lib/Linux/x86
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: glesv2
-Description: DGLES OpenGL ES 2.0 library
-Requires.private: egl
-Version: 2.0.0
-Libs: -L${libdir} -lGLESv2
-Cflags: -I${includedir}
-
+++ /dev/null
-prefix=/home/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../lib/Linux/x86
-exec_prefix=${prefix}
-libdir=/home/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../lib/Linux/x86
-includedir=/home/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../include
-
-Name: osmesa
-Description: Mesa Off-screen Rendering library
-Requires:
-Version: 8.0.3
-Libs: -L${libdir} -lOSMesa
-Libs.private: -lm -lpthread -ldl
-Cflags: -I${includedir}
+++ /dev/null
-prefix=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/dgles2/../lib/Linux/x86_64
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: egl
-Description: DGLES egl library
-Version: 1.4.2
-Libs: -L${libdir} -lEGL
-Cflags: -I${includedir}
+++ /dev/null
-prefix=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/dgles2/../lib/Linux/x86_64
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: glesv1_cm
-Description: DGLES OpenGL ES 1.1 CM library
-Requires.private: egl
-Version: 1.4.1
-Libs: -L${libdir} -lGLES_CM
-Cflags: -I${includedir}
+++ /dev/null
-prefix=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/dgles2/../lib/Linux/x86_64
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: glesv2
-Description: DGLES OpenGL ES 2.0 library
-Requires.private: egl
-Version: 2.0.0
-Libs: -L${libdir} -lGLESv2
-Cflags: -I${includedir}
-
+++ /dev/null
-prefix=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../lib/Linux/x86_64
-exec_prefix=${prefix}
-libdir=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../lib/Linux/x86_64
-includedir=/media/afaa385f-d818-4cfe-bec0-31ada40a8d36/mackross/eclipse_linux_cdt_space/qemu_exynos4_gles/gl/mesa/../include
-
-Name: osmesa
-Description: Mesa Off-screen Rendering library
-Requires:
-Version: 8.0.3
-Libs: -L${libdir} -lOSMesa
-Libs.private: -lm -lpthread -ldl
-Cflags: -I${includedir}
}
break;
case VBE_DISPI_INDEX_XRES:
- if ((val <= VBE_DISPI_MAX_XRES) && ((val & 7) == 0)) {
+ if (val <= VBE_DISPI_MAX_XRES) {
s->vbe_regs[s->vbe_index] = val;
}
break;
clean()
{
prepare
+ set_build_env
cd $SRCDIR/tizen
if test -e "Makefile"
then
- ./emulator_configure.sh x86
+ ./emulator_configure.sh x86 -ef "$BUILD_CFLAGS"
make distclean
fi
rm -rf $SRCDIR/*.zip
fi
}
+# libav build environment
+set_build_env()
+{
+ PATH=$PATH:$ROOTDIR/bin
+ export PATH
+
+ BUILD_CFLAGS=--extra-cflags="-I$ROOTDIR/include"
+ BUILD_CFLAGS+=--extra-cflags="-lyasm"
+ BUILD_CFLAGS+=--extra-cflags="-L$ROOTDIR/lib"
+}
+
# build
build()
{
+ set_build_env
+
cd $SRCDIR/tizen/
- ./emulator_configure.sh x86
+ ./emulator_configure.sh x86 -ef "$BUILD_CFLAGS"
make all_dibs
if [ $? -eq 0 ]
then
-* 2.2.0
-- tizen_2.2 source update
-== Sangjin Kim <sangjin3.kim@samsung.com> 2013-06-24
+* 1.5.115
+- keep the touch point grabbing while finger rearranging
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-10-30
+* 1.5.114
+- remove setInterpolation
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-10-28
+* 1.5.113
+- fixed sync problem in the multi threading.
+== Kitae Kim <kt920.kim@samsung.com> 2013-10-25
+* 1.5.112
+- Close opened camera fd when error occurs while maru camera starts
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-10-23
+* 1.5.111
+- disable gc interpolation for stretched image
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-10-22
+* 1.5.110
+- fixed seek operation when decoding video.
+== Kitae Kim <kt920.kim@samsung.com> 2013-10-18
+* 1.5.109
+- enable yasm option to use mmx feature on FFmpeg.
+== Kitae Kim <kt920.kim@samsung.com> 2013-10-16
+* 1.5.108
+- remove memory leak on macosx
+== Munkyu Im <munkyu.im@samsung.com> 2013-10-15
+* 1.5.107
+- fixed lock-up error when decoding video, especially on Windows.
+== Kitae Kim <kt920.kim@samsung.com> 2013-10-14
+* 1.5.106
+- modified SDL_SetVideoMode flag
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-10-14
+* 1.5.105
+- Added the error handling for dequeue webcam buffer
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-10-08
+* 1.5.104
+- added some logs in skin
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-10-07
+* 1.5.103
+- Add install_name_tool rule for libcurl on MacOS
+== Munkyu Im <munkyu.im@samsung.com> 2013-10-04
+* 1.5.102
+- clean-up memory release routine.
+== Kitae Kim <kt920.kim@samsung.com> 2013-10-04
+* 1.5.101
+- fixed sync problem when closing codec context.
+== Kitae Kim <kt920.kim@samsung.com> 2013-09-27
+* 1.5.100
+- menu blocking while touching
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-09-27
+* 1.5.99
+- enable brillcodec device and disable old codec device.
+== Kitae Kim <kt920.kim@samsung.com> 2013-09-25
+* 1.5.98
+- remove About and Preferences menu item
+== Munkyu Im <munkyu.im@samsung.com> 2013-09-24
+* 1.5.97
+- release the touch event automatically
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-09-17
+* 1.5.94
+- fix typo
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-09-16
+* 1.5.89
+- no need to shell pack while layout changing
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-09-06
+* 1.5.85
+- modified SDL logic
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-09-05
+* 1.5.84
+- seperate a key event on Windows
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-08-29
+* 1.5.82
+- modified qHD HwKey Region
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-08-22
+* 1.5.81
+- modified sdb port
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-08-21
+* 1.5.79
+- unified string utility functions as glib.
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-08-20
+* 1.5.78
+- modified qHD dbi file
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-08-20
+* 1.5.71
+- modified structure of virtio-hwkey
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-07-25
+* 1.5.70
+- Support multiple linux dist when installing and remove qemu package.
+== Kitae Kim <kt920.kim@samsung.com> 2013-07-17
+* 1.5.69
+- Version upgrade for pixmap bug.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-07-12
+* 1.5.68
+- Changed sh to bash in the install and remove script.
+== Kitae Kim <kt920.kim@samsung.com> 2013-07-11
+* 1.5.67
+- Modified install and build script to apply TSUDO on Linux.
+== Kitae Kim <kt920.kim@samsung.com> 2013-07-11
+* 1.5.66
+- Version upgrade for glXPixmap management bug.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-07-11
+* 1.5.65
+- Version upgrade for the fix of glXDestroyPixmap bug.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-07-09
+* 1.5.64
+- Version upgrade for the fix of gallery slideshow problem.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-07-08
+* 1.5.63
+- added sdbd_start protocol
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-07-04
+* 1.5.62
+- Modified to reduce the spend-time when the display rotate/scale
+- Added virtio config function to touchscreen device
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-07-02
+* 1.5.61
+- Rollback the loopback lookup code on Windows.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-06-30
+* 1.5.60
+- cancel a scrollbar timer
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-29
+* 1.5.58
+- remove notifying to sdb server
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-29
+* 1.5.57
+- keep the multi-touching when rotation
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-26
+* 1.5.55
+- apply a custom scrollbar to KeyWindow
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-24
+* 1.5.54
+- change the default skin type
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-20
+* 1.5.53
+- position correction for emulator window
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-19
+* 1.5.50
+- Modified the display to use the pixman library.
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-06-14
+* 1.5.49
+- modified keycode for 480x800-3btn
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-13
+* 1.5.48
+- The KeyWindow has extended its docking area
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-12
+* 1.5.45
+- changed the images of 3btn skin
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-06-04
+* 1.5.44
+- added 3btn skins
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-05-31
+* 1.5.43
+- Fixed a bug that appears horizontal flip images on Windows OS.
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-05-29
+* 1.5.42
+- Fixed a bug that appear a white region on the LCD.
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-05-27
+* 1.5.41
+- erase unused variable in virtio-keyboard
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-05-21
+* 1.5.38
+- modified process of using virtio keyboard queue and added key release event when context menu is activated
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-05-14
+* 1.5.37
+- remove Open_Source_Announcement.txt file
+== jihye kim <jihye1128.kim@samsung.com> 2013-05-09
+
+* 1.5.36
+- call setBounds of display in arrangeSkin
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-05-03
+* 1.5.35
+- dispose the framebuffer through syncExec
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-05-02
+* 1.5.33
+- apply patch modified by Fengqian.Gao
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-04-29
+* 1.5.32
+- Fix the slideshow problem of gallery app.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-04-23
+* 1.5.31
+- rollback 'optimize a framebuffer copying'
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-04-18
+* 1.5.28
+- Fix pBuffer issue for xcomposite.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-04-16
+* 1.5.27
+- Change the FB configs limitaion from 10 to 32 for each process.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-04-12
+* 1.5.26
+- Add glFinish() after AGL function aglTexImagePBuffer() cause of pbuffer bug on MAC os.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-04-11
+* 1.5.25
+- Do not exit if log directory is deleted on runtime.
+== Seokyeon Hwang <syeon.hwang@samsung.com> 2013-04-10
+* 1.5.24
+- Verify the passed texture ID in glBindTexture_func. If ID is invalid, do nothing.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-04-09
+* 1.5.23
+- increased virtio keyboard queue and fixed overwrite bug
+== SungMin Ha <sungmin82.ha@samsung.com> 2013-04-06
+* 1.5.22
+- no need to get the shmkey from another shm
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-04-02
+* 1.5.21
+- Fixed a bug that a camera frame is not sent to FW.
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-03-29
+* 1.5.20
+- modified skin's dbi file for key code of phone shape
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-03-29
+* 1.5.19
+- modified elem index and mutex lock in virtio-kbd
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-03-29
+* 1.5.18
+- Skip the display updates until the LCD is turned off
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-03-28
+* 1.5.17
+- modified Makefile to library load on mac from check-gl
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-03-26
+* 1.5.16
+- Fix dibs install error by mis-typing.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-03-25
+* 1.5.15
+- Fix dibs build error.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-03-21
+* 1.5.14
+- Generate check-gl binary to use at an emulator-manager.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-03-21
+* 1.5.13
+- Enable pbuffer surface.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-03-20
+* 1.5.6
+- modified virtio hwkey device and improved hwkey mapping
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-03-20
+* 1.5.5
+- moved kvm script files from qemu-common to qemu-x86 package.
+== Kitae Kim <kt920.kim@samsung.com> 2013-03-15
+* 1.5.4
+- added routine in case that there is no gksudo.
+== Kitae Kim <kt920.kim@samsung.com> 2013-03-08
+* 1.5.03
+- modified path separator
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-02-25
+* 1.5.02
+- Sync-up with tizen 2.0 latest gl source code.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-02-21
+* 1.5.01
+- added virtio hwkey device
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-02-21
+* 1.4.90
+- version up
+== SungMin Ha <sungmin82.ha@samsung.com> 2013-02-15
+* 1.4.89
+- added bottom half instead of mloop
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-02-15
+* 1.4.80
+- version up for making new package
+== Munkyu Im <munkyu.im@samsung.com> 2013-02-04
+* 1.4.79
+- added pthread_mutex_destroy
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-29
+* 1.4.76
+- prepare 10 colors for Pair Tag
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-25
+* 1.4.67
+- Changed host keyboard status routine on OS X.
+== Kitae Kim <kt920.kim@samsung.com> 2013-01-24
+* 1.4.66
+- modified screenshot operation when vga is not ready
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-01-23
+* 1.4.65
+- version up for making new package
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-22
+* 1.4.64
+- Fix emulator crash problem when using EffectsApp.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2013-01-17
+* 1.4.62
+- removed ifndef for screenshot
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-01-17
+* 1.4.61
+- Fixed a problem about displayed useless line on screenshot
+== Sungmin Ha <sungmin82.ha@samsung.com> 2013-01-16
+* 1.4.60
+- removed setFocus on mac
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-16
+* 1.4.58
+- modify init process
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-16
+* 1.4.57
+- modified include path
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-15
+* 1.4.55
+- move SDL_gfx files
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-15
+* 1.4.51
+- control the focus in general skin
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-14
+* 1.4.49
+- switch the z-order between main window and key window
+== GiWoong Kim <giwoong.kim@samsung.com> 2013-01-11
+* 1.4.43
+- change temp file path
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-09
+* 1.4.42
+- fix dynamic loading library path
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-04
+* 1.4.41
+- fix multi touch on Mac
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-03
+* 1.4.40
+- version up
+== Munkyu Im <munkyu.im@samsung.com> 2013-01-03
+* 1.4.39
+- version up
+== Sooyoung Ha <yoosah.ha@samsung.com> 2013-01-03
+* 1.4.38
+- Fixed a memory leak while decoding video.
+== Kitae Kim <kt920.kim@samsung.com> 2012-12-28
+* 1.4.35
+- fix gl capability check fail on windows intel graphics machine.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2012-12-28
+* 1.4.34
+- fix getting proxy
+== Munkyu Im <munkyu.im@samsung.com> 2012-12-27
+* 1.4.33
+- Fixed codec module and added function declarations for virtio-keyboard.
+== Kitae Kim <kt920.kim@samsung.com> 2012-12-18
+* 1.4.32
+- Copy sdbscript file to bin folder on mac.
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-12-18
+* 1.4.25
+- Fixed a capture failure on Linux system.
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2012-12-17
+* 1.4.24
+- Reverted dibs build script.
+- The previous build script was wrong.
+== Kitae Kim <kt920.kim@samsung.com> 2012-12-17
+* 1.4.23
+- Fixed an unexpected termination on Windows while previewing camera.
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2012-12-17
+* 1.4.22
+- Added multi-touch control scenario
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-12-10
+* 1.4.17
+- Added double quotation mark for path.
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-12-06
+* 1.4.15
+- rearrange finger image when rotate
+== Munkyu In <munkyu.im@samsung.com> 2012-11-29
+* 1.4.14
+- added try-catch to AboutDialog
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-29
+* 1.4.13
+- Text dimming issue fixed at windows with nvidia card.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2012-11-28
+* 1.4.12
+- Convert a HW key container in general skin
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-26
+* 1.4.9
+- Fix EGL_BAD_ALLOC error when using pixmap surface repeatedly.
+== Sangjin Kim <sangjin3.kim@samsung.com> 2012-11-22
+* 1.4.8
+- Added force close menu
+- Advanced>Force Close
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-12
+* 1.4.7
+- Fixed a bug of brightness level
+== Jinhyung Jo <jinhyung.jo@samsung.com> 2012-11-15
+* 1.4.6
+- refactoring of skin code
+- Fixed N_SE-12805 issue
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-14
+* 1.4.5
+- refactoring of skin code
+- Added EmulatorSkinState file & define ISkinComposer interface
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-12
+* 1.4.4
+- Apply qemu_ld/st optimization according to QEMU 1.2
+== Yeongkyoon Lee <yeongkyoon.lee@samsung.com> 2012-11-09
+* 1.4.2
+- Added libattr1-dev, libcap library
+- Added libattr1-dev, libcap library
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-08
+* 1.4.1
+- Disable folding button in general skin
+- Disable folding button in general skin
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-11-06
+* 1.4.0
+- vga: Support HVGA, WXGA, HD1080, WQXGA resolution.
+- Support HVGA, WXGA, HD1080, WQXGA resolution.
+== Signed-off-by: Sangjin Kim <sangjin3.kim@samsung.com> 2012-11-02
+* 1.3.68
+- Don't lose the release event of HW key
+- Event if user releases the mouse cursor at outside of HW key area, it does not lose the event.
+== GiWoong Kim <giwoong.kim@samsung.com> 2012-10-29
+* 1.3.66
+- Change SDK version.
+- Change version from 2.0a3 to 2.0a4-RC1
+== Kitae Kim <kt920.kim@samsung.com> 2012-10-23
#!/bin/bash -ex
-TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
-if [ -z $TIZEN_SDK_INSTALL_PATH ]
+TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}`
+if [ -z ${TIZEN_SDK_INSTALL_PATH} ]
then
# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
exit 2;
fi
-if [ -e /etc/os-release ]; then
- OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+LSB_RELEASE=`which lsb_release`
+if [ "${LSB_RELEASE}" = "" ]; then
+ if [ -e /etc/os-release ]; then
+ OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+ fi
+ # TODO: Detect other linux distributions.
+else
+ OS_NAME=`lsb_release --id --short`
+fi
+
+if [ ! -z "${OS_NAME}" ]; then
+ OS_NAME=`echo ${OS_NAME} | tr '[:upper:]' '[:lower:]'`
fi
+echo "Linux Distribution: ${OS_NAME}"
TMP_FILE=init_tizen-kvm.sh
-echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/tizen-kvm /etc/init.d/" >> $TMP_FILE
-echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> $TMP_FILE
-echo "/etc/init.d/tizen-kvm start" >> $TMP_FILE
+echo "#!/bin/bash -ex" >> ${TMP_FILE}
+echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/tizen-kvm /etc/init.d/" >> ${TMP_FILE}
+echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> ${TMP_FILE}
+echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE}
if [ "ubuntu" = "${OS_NAME}" ] ; then
- echo "update-rc.d tizen-kvm defaults" >> $TMP_FILE
+ echo "update-rc.d tizen-kvm defaults" >> ${TMP_FILE}
fi
-chmod +x $TMP_FILE
+chmod +x ${TMP_FILE}
-if [ "$TSUDO" != "" ] # since installer v2.27
+if [ "${TSUDO}" != "" ] # since installer v2.27
then
TSUDO_MSG="Enter your password to enable kvm module if your machine supports hardware virtualization."
TMP_PATH="`pwd`/${TMP_FILE}"
- $TSUDO -m "${TSUDO_MSG}" sh $TMP_PATH
+ ${TSUDO} -m "${TSUDO_MSG}" sh ${TMP_PATH}
else
GKSUDO=`which gksudo`
- if [ "$GKSUDO" = "" ]
+ if [ "${GKSUDO}" = "" ]
then
echo "there is no gksudo."
- sudo ./$TMP_FILE
+ sudo ./${TMP_FILE}
else
- gksudo ./$TMP_FILE
+ gksudo ./${TMP_FILE}
fi
fi
-rm $TMP_FILE
+rm ${TMP_FILE}
#!/bin/bash -ex
-TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
-if [ -z $TIZEN_SDK_INSTALL_PATH ]
+TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}`
+if [ -z ${TIZEN_SDK_INSTALL_PATH} ]
then
# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
exit 2;
fi
-if [ -e /etc/os-release ]; then
- OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+LSB_RELEASE=`which lsb_release`
+if [ "${LSB_RELEASE}" = "" ]; then
+ if [ -e /etc/os-release ]; then
+ OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+ fi
+ # TODO: Detect other linux distributions.
+else
+ OS_NAME=`lsb_release --id --short`
+fi
+
+if [ ! -z "${OS_NAME}" ]; then
+ OS_NAME=`echo ${OS_NAME} | tr '[:upper:]' '[:lower:]'`
fi
+echo "Linux Distribution: ${OS_NAME}"
TMP_FILE=init_tizen-kvm.sh
-echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/tizen-kvm /etc/init.d/" >> $TMP_FILE
-echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> $TMP_FILE
-echo "/etc/init.d/tizen-kvm start" >> $TMP_FILE
+echo "#!/bin/bash -ex" >> ${TMP_FILE}
+echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/tizen-kvm /etc/init.d/" >> ${TMP_FILE}
+echo "cp ${TIZEN_SDK_INSTALL_PATH}/tools/emulator/etc/45-tizen-kvm.rules /lib/udev/rules.d/" >> ${TMP_FILE}
+echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE}
if [ "ubuntu" = "${OS_NAME}" ] ; then
- echo "update-rc.d tizen-kvm defaults" >> $TMP_FILE
+ echo "update-rc.d tizen-kvm defaults" >> ${TMP_FILE}
fi
-chmod +x $TMP_FILE
+chmod +x ${TMP_FILE}
-if [ "$TSUDO" != "" ] # since installer v2.27
+if [ "${TSUDO}" != "" ] # since installer v2.27
then
TSUDO_MSG="Enter your password to enable kvm module if your machine supports hardware virtualization."
TMP_PATH="`pwd`/${TMP_FILE}"
- $TSUDO -m "${TSUDO_MSG}" sh $TMP_PATH
+ ${TSUDO} -m "${TSUDO_MSG}" sh ${TMP_PATH}
else
GKSUDO=`which gksudo`
- if [ "$GKSUDO" = "" ]
+ if [ "${GKSUDO}" = "" ]
then
echo "there is no gksudo."
- sudo ./$TMP_FILE
+ sudo ./${TMP_FILE}
else
- gksudo ./$TMP_FILE
+ gksudo ./${TMP_FILE}
fi
fi
-rm $TMP_FILE
+rm ${TMP_FILE}
#!/bin/bash -ex
-TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
-if [ -z $TIZEN_SDK_INSTALL_PATH ]
+TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}`
+if [ -z ${TIZEN_SDK_INSTALL_PATH} ]
then
# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
exit 2;
fi
-if [ -e /etc/os-release ]; then
- OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+LSB_RELEASE=`which lsb_release`
+if [ "${LSB_RELEASE}" = "" ]; then
+ if [ -e /etc/os-release ]; then
+ OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+ fi
+ # TODO: Detect other linux distributions.
+else
+ OS_NAME=`lsb_release --id --short`
+fi
+
+if [ ! -z "${OS_NAME}" ]; then
+ OS_NAME=`echo ${OS_NAME} | tr '[:upper:]' '[:lower:]'`
fi
+echo "Linux Distribution: ${OS_NAME}"
TMP_FILE=remove_tizen-kvm.sh
+echo "#!/bin/bash -ex" >> ${TMP_FILE}
if [ "ubuntu" = "${OS_NAME}" ] ; then
- echo "update-rc.d -f tizen-kvm remove" >> $TMP_FILE
+ echo "update-rc.d -f tizen-kvm remove" >> ${TMP_FILE}
fi
-echo "rm -f /etc/init.d/tizen-kvm" >> $TMP_FILE
-echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> $TMP_FILE
+echo "rm -f /etc/init.d/tizen-kvm" >> ${TMP_FILE}
+echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> ${TMP_FILE}
-chmod +x $TMP_FILE
+chmod +x ${TMP_FILE}
-if [ "$TSUDO" != "" ] # since installer v2.27
+if [ "${TSUDO}" != "" ] # since installer v2.27
then
TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm."
TMP_PATH="`pwd`/${TMP_FILE}"
- $TSUDO -m "${TSUDO_MSG}" sh $TMP_PATH
+ $TSUDO -m "${TSUDO_MSG}" sh ${TMP_PATH}
else
GKSUDO=`which gksudo`
- if [ "$GKSUDO" = "" ]
+ if [ "${GKSUDO}" = "" ]
then
echo "there is no gksudo."
- sudo ./$TMP_FILE
+ sudo ./${TMP_FILE}
else
- gksudo ./$TMP_FILE
+ gksudo ./${TMP_FILE}
fi
fi
-rm $TMP_FILE
+rm ${TMP_FILE}
#!/bin/bash -ex
-TIZEN_SDK_INSTALL_PATH=`echo $INSTALLED_PATH`
-if [ -z $TIZEN_SDK_INSTALL_PATH ]
+TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}`
+if [ -z ${TIZEN_SDK_INSTALL_PATH} ]
then
# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log
exit 2;
fi
-if [ -e /etc/os-release ]; then
- OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+LSB_RELEASE=`which lsb_release`
+if [ "${LSB_RELEASE}" = "" ]; then
+ if [ -e /etc/os-release ]; then
+ OS_NAME=`cat /etc/os-release | grep ID | head -n 1 | awk -F= '{print $2}'`
+ fi
+ # TODO: Detect other linux distributions.
+else
+ OS_NAME=`lsb_release --id --short`
+fi
+
+if [ ! -z "${OS_NAME}" ]; then
+ OS_NAME=`echo ${OS_NAME} | tr '[:upper:]' '[:lower:]'`
fi
+echo "Linux Distribution: ${OS_NAME}"
TMP_FILE=remove_tizen-kvm.sh
+echo "#!/bin/bash -ex" >> ${TMP_FILE}
if [ "ubuntu" = "${OS_NAME}" ] ; then
- echo "update-rc.d -f tizen-kvm remove" >> $TMP_FILE
+ echo "update-rc.d -f tizen-kvm remove" >> ${TMP_FILE}
fi
-echo "rm -f /etc/init.d/tizen-kvm" >> $TMP_FILE
-echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> $TMP_FILE
+echo "rm -f /etc/init.d/tizen-kvm" >> ${TMP_FILE}
+echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> ${TMP_FILE}
-chmod +x $TMP_FILE
+chmod +x ${TMP_FILE}
-if [ "$TSUDO" != "" ] # since installer v2.27
+if [ "${TSUDO}" != "" ] # since installer v2.27
then
TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm."
TMP_PATH="`pwd`/${TMP_FILE}"
- $TSUDO -m "${TSUDO_MSG}" sh $TMP_PATH
+ $TSUDO -m "${TSUDO_MSG}" sh ${TMP_PATH}
else
GKSUDO=`which gksudo`
- if [ "$GKSUDO" = "" ]
+ if [ "${GKSUDO}" = "" ]
then
echo "there is no gksudo."
- sudo ./$TMP_FILE
+ sudo ./${TMP_FILE}
else
- gksudo ./$TMP_FILE
+ gksudo ./${TMP_FILE}
fi
fi
-rm $TMP_FILE
+rm ${TMP_FILE}
-Version: 2.2.0
+Version: 1.5.115
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Source: emulator
Package: emulator-qemu-common
OS: windows-32, windows-64
Build-host-os: windows-32
-Build-dependency: emulator-lib [ windows-32 ]
+Build-dependency: emulator-lib [ windows-32 ], yasm [ windows-32 ]
Description: Common binaries for Tizen Emulator
Package: emulator-qemu-common
OS: macos-64
Build-host-os: macos-64
-Build-dependency: emulator-lib [ macos-64 ]
+Build-dependency: emulator-lib [ macos-64 ], yasm [ macos-64 ]
Description: Common binaries for Tizen Emulator
Package: emulator-qemu-x86
Package: emulator-qemu-x86
OS: windows-32, windows-64
Build-host-os: windows-32
-Build-dependency: SDL-1.2.14 [ windows-32 ], apache-ant-1.8.3-bin [ windows-32 ], gtk-bundle_2.16.6 [ windows-32 ], directx-dev [ windows-32 ], libcurl-4 [ windows-32 ], pixman-0.30.0 [ windows-32 ], emulator-lib [ windows-32 ]
+Build-dependency: SDL-1.2.14 [ windows-32 ], apache-ant-1.8.3-bin [ windows-32 ], gtk-bundle_2.16.6 [ windows-32 ], directx-dev [ windows-32 ], libcurl-4 [ windows-32 ], pixman-0.30.0 [ windows-32 ], emulator-lib [ windows-32 ], yasm [ windows-32 ]
Install-dependency: emulator-kernel-x86 [ windows-32 ], vgabios [ windows-32 ]
Description: Tizen x86 Emulator
Package: emulator-qemu-x86
OS: macos-64
Build-host-os: macos-64
-Build-dependency: emulator-lib [ macos-64 ]
+Build-dependency: emulator-lib [ macos-64 ], yasm [ macos-64 ]
Install-dependency: emulator-kernel-x86 [ macos-64 ], vgabios [ macos-64 ]
Description: Tizen x86 Emulator
ai.ai_family = PF_INET6;
#ifdef CONFIG_MARU
+ #if !defined(_WIN32)
// for lookup loopback interface...
if (addr[0] == '\0') {
ai.ai_flags = 0;
addr = NULL;
}
+ #endif
#endif
/* lookup */
+++ /dev/null
-#!/bin/sh
-do_start () {
- if grep -qs "^flags.* vmx" /proc/cpuinfo; then
- modprobe -b kvm_intel "$KVM_NESTED"
- elif grep -qs "^flags.* svm" /proc/cpuinfo; then
- modprobe -b kvm_amd
- fi
-}
-
-case "$1" in
- start)
- do_start
- ;;
- restart|reload|force-reload)
- # No-op
- ;;
- stop)
- # No-op
- ;;
- *)
- echo "Usage: $0 start|stop" >&2
- exit 3
- ;;
-esac
+++ /dev/null
-LIBAVCODEC_$MAJOR {
- global: *;
- local:
- ff_*_bsf;
- ff_*_decoder;
- ff_*_encoder;
- ff_*_hwaccel;
- ff_*_parser;
-};
+++ /dev/null
-/*
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_VERSION_H
-#define AVCODEC_VERSION_H
-
-#define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR 5
-#define LIBAVCODEC_VERSION_MICRO 0
-
-#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
- LIBAVCODEC_VERSION_MINOR, \
- LIBAVCODEC_VERSION_MICRO)
-#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
- LIBAVCODEC_VERSION_MINOR, \
- LIBAVCODEC_VERSION_MICRO)
-#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
-
-#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
-
-/**
- * Those FF_API_* defines are not part of public API.
- * They may change, break or disappear at any time.
- */
-#ifndef FF_API_PALETTE_CONTROL
-#define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_OLD_SAMPLE_FMT
-#define FF_API_OLD_SAMPLE_FMT (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_OLD_AUDIOCONVERT
-#define FF_API_OLD_AUDIOCONVERT (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_ANTIALIAS_ALGO
-#define FF_API_ANTIALIAS_ALGO (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_REQUEST_CHANNELS
-#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_OPT_H
-#define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_THREAD_INIT
-#define FF_API_THREAD_INIT (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_OLD_FF_PICT_TYPES
-#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_FLAC_GLOBAL_OPTS
-#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_GET_PIX_FMT_NAME
-#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
-#endif
-
-#endif /* AVCODEC_VERSION_H */
+++ /dev/null
-LIBAVDEVICE_$MAJOR {
- global: avdevice_*;
- local: *;
-};
+++ /dev/null
-LIBAVFILTER_$MAJOR {
- global: avfilter_*; av_*;
- local: *;
-};
+++ /dev/null
-LIBAVFORMAT_$MAJOR {
- global: *;
- local:
- ff_*_demuxer;
- ff_*_muxer;
- ff_*_protocol;
-};
+++ /dev/null
-/*
- * Version macros.
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVFORMAT_VERSION_H
-#define AVFORMAT_VERSION_H
-
-#include "libavutil/avutil.h"
-
-#define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR 2
-#define LIBAVFORMAT_VERSION_MICRO 0
-
-#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
- LIBAVFORMAT_VERSION_MINOR, \
- LIBAVFORMAT_VERSION_MICRO)
-#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
- LIBAVFORMAT_VERSION_MINOR, \
- LIBAVFORMAT_VERSION_MICRO)
-#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
-
-#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
-
-/**
- * Those FF_API_* defines are not part of public API.
- * They may change, break or disappear at any time.
- */
-#ifndef FF_API_OLD_METADATA2
-#define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_READ_SEEK
-#define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_OLD_AVIO
-#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_DUMP_FORMAT
-#define FF_API_DUMP_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_PARSE_DATE
-#define FF_API_PARSE_DATE (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_FIND_INFO_TAG
-#define FF_API_FIND_INFO_TAG (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_PKT_DUMP
-#define FF_API_PKT_DUMP (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_GUESS_IMG2_CODEC
-#define FF_API_GUESS_IMG2_CODEC (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_SDP_CREATE
-#define FF_API_SDP_CREATE (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_FORMAT_PARAMETERS
-#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-#ifndef FF_API_FLAG_RTP_HINT
-#define FF_API_FLAG_RTP_HINT (LIBAVFORMAT_VERSION_MAJOR < 54)
-#endif
-
-#endif /* AVFORMAT_VERSION_H */
+++ /dev/null
-LIBAVUTIL_$MAJOR {
- global: av_*; ff_*; avutil_*;
- local: *;
-};
+++ /dev/null
-LIBPOSTPROC_$MAJOR {
- global: postproc_*; pp_*;
- local: *;
-};
+++ /dev/null
-LIBSWSCALE_$MAJOR {
- global: swscale_*; sws_*; ff_*;
- local: *;
-};
OPENGLES_EN=""
YAGL_EN=""
YAGL_STATS_EN=""
+FFMPEG_CONFIGURE_APPEND=""
usage() {
echo "usage: build.sh [options] [target]"
echo " enable YaGL stats"
echo "-e|--extra"
echo " extra options for QEMU configure"
+ echo "-ef|--extra-ffmpeg"
+ echo " extra options for FFmpeg configure"
echo "-u|-h|--help|--usage"
echo " display this help message and exit"
}
shift
CONFIGURE_APPEND="$CONFIGURE_APPEND $1"
;;
+ -ef|--extra-ffmpeg)
+ shift
+ FFMPEG_CONFIGURE_APPEND="$FFMPEG_CONFIGURE_APPEND $1"
+ ;;
-vgl|--virtio-gl)
virtgl_enable 1
;;
echo ""
echo "##### FFMPEG configure for emulator"
./configure \
- --prefix=./$bindir --arch=${ffmpegarc} --enable-static --enable-pic --enable-optimizations --disable-doc --disable-gpl --disable-yasm --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1
+ --prefix=./$bindir --arch=${ffmpegarc} --enable-static --enable-pic --enable-optimizations --disable-doc --disable-gpl --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1
cd ../..
cd ..
echo ""
echo "##### FFMPEG configure for emulator"
./configure \
- --prefix=./$bindir --arch=x86 --enable-static --enable-w32threads --enable-optimizations --enable-memalign-hack --disable-doc --disable-gpl --disable-yasm --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1
+ --prefix=./$bindir --arch=x86 --enable-static --enable-w32threads --enable-optimizations --enable-memalign-hack --disable-doc --disable-gpl --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1
cd ../..
cd ..
echo ""
echo "##### FFMPEG configure for emulator"
./configure \
---prefix=./$bindir --extra-cflags=-mmacosx-version-min=10.4 --arch=x86 --enable-static --enable-pic --enable-optimizations --disable-doc --disable-gpl --disable-yasm --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1 --cc=cc
+--prefix=./$bindir --extra-cflags=-mmacosx-version-min=10.4 --arch=${ffmpegarc} --enable-static --enable-pic --enable-optimizations --disable-doc --disable-gpl --disable-postproc --disable-swscale --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-ffplay --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-network --disable-bsfs --disable-devices --disable-filters --enable-encoder=h263 --enable-encoder=h263p --enable-encoder=mpeg4 --enable-encoder=msmpeg4v2 --enable-encoder=msmpeg4v3 --enable-decoder=aac --enable-decoder=h263 --enable-decoder=h264 --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mpeg4 --enable-decoder=mpegvideo --enable-decoder=msmpeg4v1 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmv3 --enable-decoder=vc1 --cc=cc $FFMPEG_CONFIGURE_APPEND
cd ../..
cd ..
install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(EMUL_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(EMUL_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(EMUL_DIR)/bin/qemu-img
+ install_name_tool -change /usr/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(EMUL_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libglib-2.0.*.dylib @loader_path/libglib-2.0.0.dylib $(EMUL_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/libintl.8.dylib @loader_path/libintl.8.dylib $(EMUL_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(EMUL_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(EMUL_DIR)/bin/emulator-x86 ;\
install_name_tool -change /opt/local/lib/libncurses.5.dylib @loader_path/libncurses.5.dylib $(EMUL_DIR)/bin/emulator-x86 ;\
install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(EMUL_DIR)/bin/emulator-x86 ;\
+ install_name_tool -change /usr/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(EMUL_DIR)/bin/emulator-x86 ;\
;; \
arm-softmmu) \
;; \
install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(DIBS_COMMON_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(DIBS_COMMON_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(DIBS_COMMON_DIR)/bin/qemu-img
+ install_name_tool -change /usr/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(DIBS_COMMON_DIR)/bin/qemu-img
install_name_tool -change /opt/local/lib/libglib-2.0.*.dylib @loader_path/libglib-2.0.0.dylib $(DIBS_COMMON_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/libintl.8.dylib @loader_path/libintl.8.dylib $(DIBS_COMMON_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/gcc47/libgcc_s.1.dylib @loader_path/libgcc_s.1.dylib $(DIBS_COMMON_DIR)/bin/check-gl
install_name_tool -change /opt/local/lib/libz.1.dylib @loader_path/libz.1.dylib $(DIBS_X86_DIR)/bin/emulator-x86 ;\
install_name_tool -change /opt/local/lib/libncurses.5.dylib @loader_path/libncurses.5.dylib $(DIBS_X86_DIR)/bin/emulator-x86 ;\
install_name_tool -change /opt/local/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(DIBS_X86_DIR)/bin/emulator-x86 ;\
+ install_name_tool -change /usr/lib/libcurl.4.dylib @loader_path/libcurl.4.dylib $(DIBS_X86_DIR)/bin/emulator-x86 ;\
;; \
arm-softmmu) \
;; \
QEMU_CFLAGS += -I$(SRC_PATH)/hw -I$(SRC_PATH)/tizen/src
QEMU_CFLAGS += -I$(SRC_PATH)/tizen/distrib/libav/$(ARCH)/include
-QEMU_CFLAGS += -L$(SRC_PATH)/tizen/distrib/libav/$(ARCH)/lib
+LDFLAGS += -L$(SRC_PATH)/tizen/distrib/libav/$(ARCH)/lib
QEMU_CFLAGS += $(SDL_CFLAGS)
QEMU_CFLAGS += $(GLIB_CFLAGS)
ifdef CONFIG_DARWIN
QEMU_CFLAGS += -framework Foundation -framework SystemConfiguration
QEMU_CFLAGS += -framework Cocoa -framework QTKit -framework CoreVideo
-QEMU_CFLAGS += -framework AppKit
+QEMU_CFLAGS += -framework AppKit -framework CoreServices
endif
ifndef CONFIG_DEBUG_EXEC
CFLAGS += -g -O2
obj-y += maru_codec.o
obj-y += maru_virtio_esm.o
obj-y += maru_virtio_hwkey.o
+obj-y += maru_brill_codec.o
obj-$(CONFIG_PCI) += maru_camera_common_pci.o
obj-$(CONFIG_LINUX) += maru_camera_linux_pci.o
#ifndef CONFIG_DARWIN
###########################################################
## opengl library for i386
-obj-$(CONFIG_GL) += virtio-gl.o
+obj-$(CONFIG_GL) += virtio-gl.o
obj-$(CONFIG_GL) += helper_opengl.o opengl_exec.o mesa_mipmap.o
-obj-$(CONFIG_NO_GL) += virtio-gl-stub.o
+obj-$(CONFIG_NO_GL) += virtio-gl-stub.o
obj-y += gloffscreen_test.o gloffscreen_xcomposite.o gloffscreen_common.o gloffscreen_wgl.o gloffscreen_agl.o
###########################################################
#endif
int dbg_log( enum _debug_class cls, struct _debug_channel *channel,
const char *format, ... )
{
- int ret = 0;
- int ret_write = 0;
- char buf[2048];
- va_list valist;
- int open_flags;
- int fd;
-
- if (!(_dbg_get_channel_flags( channel ) & (1 << cls)))
- return -1;
+ int ret = 0;
+ int ret_write = 0;
+ char buf_msg[2048];
+ char buf_time[128];
+ va_list valist;
+ int open_flags;
+ int fd;
+
+#ifdef _WIN32
+ struct tm *ptm;
+#else
+ struct tm tm;
+#endif
+ qemu_timeval tv = { 0, 0 };
+ time_t ti;
- ret += snprintf(buf, sizeof(buf),"[%s:%s", debug_classes[cls], channel->name);
+ if (!(_dbg_get_channel_flags( channel ) & (1 << cls))) {
+ return -1;
+ }
- if (*channel->multiname)
- ret += snprintf(buf + ret, sizeof(buf) - ret, ":%s]", channel->multiname);
- else
- ret += snprintf(buf + ret, sizeof(buf) - ret, "]");
+ qemu_gettimeofday(&tv);
+ ti = tv.tv_sec;
- va_start(valist, format);
- ret += vsnprintf(buf + ret, sizeof(buf) - ret, format, valist );
- va_end(valist);
-
- open_flags = O_RDWR | O_APPEND | O_BINARY | O_CREAT ;
- fd = qemu_open(log_path, open_flags, 0666);
- if(fd < 0) {
+#ifdef _WIN32
+ ptm = localtime(&ti);
+ strftime(buf_time, sizeof(buf_time),
+ "%H:%M:%S", ptm);
+#else
+ localtime_r(&ti, &tm);
+ strftime(buf_time, sizeof(buf_time),
+ "%H:%M:%S", &tm);
+#endif
+
+ ret += snprintf(buf_msg, sizeof(buf_msg),"%s [%s:%s",
+ buf_time, debug_classes[cls], channel->name);
+
+ if (*channel->multiname) {
+ ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s]", channel->multiname);
+ } else {
+ ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "]");
+ }
+
+ va_start(valist, format);
+ ret += vsnprintf(buf_msg + ret, sizeof(buf_msg) - ret, format, valist);
+ va_end(valist);
+
+ open_flags = O_RDWR | O_APPEND | O_BINARY | O_CREAT;
+
+ fd = qemu_open(log_path, open_flags, 0666);
+ if (fd < 0) {
fprintf(stderr, "Can't open logfile: %s\n", log_path);
- // commented out for prevent shutdown when log directory is removed on runtime.
+ /* commented out for prevent shutdown when log directory is removed on runtime. */
//exit(1);
}
- ret_write = qemu_write_full(fd, buf, ret);
+
+ ret_write = qemu_write_full(fd, buf_msg, ret);
if (ret_write != ret) {
// TODO: error handling...
}
close(fd);
- return ret;
+ return ret;
}
void assert_fail(char *exp, const char *file, int line)
#define LEN_MARU_KERNEL_CMDLINE 512
gchar maru_kernel_cmdline[LEN_MARU_KERNEL_CMDLINE];
-static int _skin_argc;
+static int _skin_argc = 0;
static char **_skin_argv;
-static int _qemu_argc;
+static int _qemu_argc = 0;
static char **_qemu_argv;
-#if defined(CONFIG_LINUX)
+#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN)
#include <sys/shm.h>
extern int g_shmid;
#endif
shutdown_skin_server();
shutdown_guest_server();
-#if defined(CONFIG_LINUX)
- /* clean up the vm lock memory by munkyu */
+#if defined(CONFIG_LINUX) || defined(CONFIG_DARWIN)
if (shmctl(g_shmid, IPC_RMID, 0) == -1) {
ERR("shmctl failed\n");
perror("emulator.c: ");
int skin_args_index = 0;
if (argc <= 1) {
- fprintf(stderr, "Arguments are not enough to launch Emulator. "
- "Please try to use Emulator Manager.\n");
+ fprintf(stderr,
+ "The arguments are not enough to launch emulator. "
+ "Please use Emulator Manager.\n");
exit(1);
}
g_strlcpy(dns, DEFAULT_QEMU_DNS_IP, strlen(DEFAULT_QEMU_DNS_IP) + 1);
check_vm_lock();
- socket_init();
make_vm_lock();
sdb_setup(); /* determine the base port for emulator */
{
parse_options(argc, argv, &_skin_argc,
&_skin_argv, &_qemu_argc, &_qemu_argv);
+
+ if (_skin_argc <= 0 || _qemu_argc <= 0) {
+ fprintf(stderr,
+ "The arguments are not enough to launch emulator. "
+ "Please use Emulator Manager.\n");
+ exit(1);
+ }
+
set_bin_path(_qemu_argv[0]);
extract_qemu_info(_qemu_argc, _qemu_argv);
fprintf(stdout, "%s ", _skin_argv[i]);
}
fprintf(stdout, "\nskin args: =========================================\n");
+ INFO("socket initialize\n");
+ socket_init();
INFO("qemu main start!\n");
qemu_main(_qemu_argc, _qemu_argv, NULL);
/*
- *
+ *
*
* Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
#include <arpa/inet.h>
#endif
+#include "emulator.h"
#include "guest_server.h"
#include "mloop_event.h"
#include "skin/maruskin_server.h"
#include "debug_ch.h"
#include "sdb.h"
+#include "maru_common.h"
MULTI_DEBUG_CHANNEL(qemu, guest_server);
-
#define RECV_BUF_SIZE 32
static void* run_guest_server(void* args);
static int parse_val(char *buff, unsigned char data, char *parsbuf);
-
pthread_t start_guest_server(int server_port)
{
svr_port = server_port;
}
-/* get_emulator_vms_sdcard_path = "/home/{USER}/tizen-sdk-data/emulator-vms/sdcard" */
-static char* get_emulator_vms_sdcard_path(void)
+/*
+ * In case that SDK does not refer to sdk.info to get tizen-sdk-data path.
+ * When SDK is not installed by the latest SDK installer,
+ * SDK installed path is fixed and there is no sdk.info file.
+ */
+static gchar *get_old_tizen_sdk_data_path(void)
{
- char *emulator_vms_sdcard_path = NULL;
+ gchar *tizen_sdk_data_path = NULL;
+
+ INFO("try to search tizen-sdk-data path in another way.\n");
-#ifndef _WIN32
- char emulator_vms[] = "/tizen-sdk-data/emulator-vms/sdcard/";
- char *homedir = (char*)g_getenv("HOME");
+#ifndef CONFIG_WIN32
+ gchar tizen_sdk_data[] = "/tizen-sdk-data";
+ gint tizen_sdk_data_len = 0;
+ gchar *home_dir;
- if (!homedir) {
- homedir = (char*)g_get_home_dir();
+ home_dir = (gchar *)g_getenv("HOME");
+ if (!home_dir) {
+ home_dir = (gchar *)g_get_home_dir();
+ }
+
+ tizen_sdk_data_len = strlen(home_dir) + sizeof(tizen_sdk_data) + 1;
+ tizen_sdk_data_path = g_malloc(tizen_sdk_data_len);
+ if (!tizen_sdk_data_path) {
+ ERR("failed to allocate memory.\n");
+ return NULL;
}
+ g_strlcpy(tizen_sdk_data_path, home_dir, tizen_sdk_data_len);
+ g_strlcat(tizen_sdk_data_path, tizen_sdk_data, tizen_sdk_data_len);
- emulator_vms_sdcard_path = malloc(strlen(homedir) + sizeof emulator_vms + 1);
- assert(emulator_vms_sdcard_path != NULL);
- strcpy(emulator_vms_sdcard_path, homedir);
- strcat(emulator_vms_sdcard_path, emulator_vms);
#else
- char emulator_vms[] = "\\tizen-sdk-data\\emulator-vms\\sdcard\\";
+ gchar tizen_sdk_data[] = "\\tizen-sdk-data\\";
+ gint tizen_sdk_data_len = 0;
HKEY hKey;
char strLocalAppDataPath[1024] = { 0 };
DWORD dwBufLen = 1024;
+
RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
0, KEY_QUERY_VALUE, &hKey);
- RegQueryValueEx(hKey, "Local AppData", NULL, NULL, (LPBYTE)strLocalAppDataPath, &dwBufLen);
+ RegQueryValueEx(hKey, "Local AppData", NULL,
+ NULL, (LPBYTE)strLocalAppDataPath, &dwBufLen);
RegCloseKey(hKey);
- emulator_vms_sdcard_path = malloc(strlen(strLocalAppDataPath) + sizeof emulator_vms + 1);
- strcpy(emulator_vms_sdcard_path, strLocalAppDataPath);
- strcat(emulator_vms_sdcard_path, emulator_vms);
+ tizen_sdk_data_len = strlen(strLocalAppDataPath) + sizeof(tizen_sdk_data) + 1;
+ tizen_sdk_data_path = g_malloc(tizen_sdk_data_len);
+ if (!tizen_sdk_data_path) {
+ ERR("failed to allocate memory.\n");
+ return NULL;
+ }
+
+ g_strlcpy(tizen_sdk_data_path, strLocalAppDataPath, tizen_sdk_data_len);
+ g_strlcat(tizen_sdk_data_path, tizen_sdk_data, tizen_sdk_data_len);
+#endif
+
+ INFO("tizen-sdk-data path: %s\n", tizen_sdk_data_path);
+ return tizen_sdk_data_path;
+}
+
+/*
+ * get tizen-sdk-data path from sdk.info.
+ */
+static gchar *get_tizen_sdk_data_path(void)
+{
+ gchar *emul_bin_path = NULL;
+ gchar *sdk_info_file_path = NULL;
+ gchar *tizen_sdk_data_path = NULL;
+#ifndef CONFIG_WIN32
+ const char *sdk_info = "../../../sdk.info";
+#else
+ const char *sdk_info = "..\\..\\..\\sdk.info";
+#endif
+ const char sdk_data_var[] = "TIZEN_SDK_DATA_PATH";
+
+ FILE *sdk_info_fp = NULL;
+ int sdk_info_path_len = 0;
+
+ TRACE("%s\n", __func__);
+
+ emul_bin_path = get_bin_path();
+ if (!emul_bin_path) {
+ ERR("failed to get emulator path.\n");
+ return NULL;
+ }
+
+ sdk_info_path_len = strlen(emul_bin_path) + strlen(sdk_info) + 1;
+ sdk_info_file_path = g_malloc(sdk_info_path_len);
+ if (!sdk_info_file_path) {
+ ERR("failed to allocate sdk-data buffer.\n");
+ return NULL;
+ }
+
+ g_snprintf(sdk_info_file_path, sdk_info_path_len, "%s%s",
+ emul_bin_path, sdk_info);
+ INFO("sdk.info path: %s\n", sdk_info_file_path);
+
+ sdk_info_fp = fopen(sdk_info_file_path, "r");
+ g_free(sdk_info_file_path);
+
+ if (sdk_info_fp) {
+ INFO("Succeeded to open [sdk.info].\n");
+
+ char tmp[256] = { '\0', };
+ char *tmpline = NULL;
+ while (fgets(tmp, sizeof(tmp), sdk_info_fp) != NULL) {
+ if ((tmpline = g_strstr_len(tmp, sizeof(tmp), sdk_data_var))) {
+ tmpline += strlen(sdk_data_var) + 1; // 1 for '='
+ break;
+ }
+ }
+
+ if (tmpline) {
+ if (tmpline[strlen(tmpline) - 1] == '\n') {
+ tmpline[strlen(tmpline) - 1] = '\0';
+ }
+ if (tmpline[strlen(tmpline) - 1] == '\r') {
+ tmpline[strlen(tmpline) - 1] = '\0';
+ }
+
+ tizen_sdk_data_path = g_malloc(strlen(tmpline) + 1);
+ g_strlcpy(tizen_sdk_data_path, tmpline, strlen(tmpline) + 1);
+
+ INFO("tizen-sdk-data path: %s\n", tizen_sdk_data_path);
+
+ return tizen_sdk_data_path;
+ }
+
+ fclose(sdk_info_fp);
+ }
+
+ // legacy mode
+ ERR("Failed to open [sdk.info].\n");
+
+ return get_old_tizen_sdk_data_path();
+}
+
+static char* get_emulator_vms_sdcard_path(void)
+{
+ gchar *emulator_vms_sdcard_path = NULL;
+ gchar *tizen_sdk_data = NULL;
+#ifndef CONFIG_WIN32
+ char emulator_vms[] = "/emulator-vms/sdcard/";
+#else
+ char emulator_vms[] = "\\emulator-vms\\sdcard\\";
#endif
+ TRACE("vms path: %s, %d\n", emulator_vms, sizeof(emulator_vms));
+
+ tizen_sdk_data = get_tizen_sdk_data_path();
+ if (!tizen_sdk_data) {
+ ERR("failed to get tizen-sdk-data path.\n");
+ return NULL;
+ }
+
+ emulator_vms_sdcard_path =
+ g_malloc(strlen(tizen_sdk_data) + sizeof(emulator_vms) + 1);
+ if (!emulator_vms_sdcard_path) {
+ ERR("failed to allocate memory.\n");
+ return NULL;
+ }
+
+ g_snprintf(emulator_vms_sdcard_path, strlen(tizen_sdk_data) + sizeof(emulator_vms),
+ "%s%s", tizen_sdk_data, emulator_vms);
+
+ g_free(tizen_sdk_data);
+
+ TRACE("sdcard dir: %s\n", emulator_vms_sdcard_path);
return emulator_vms_sdcard_path;
}
static void* run_guest_server(void* args)
{
- INFO("start guest server thread.\n");
-
- uint16_t port;
+ uint16_t port = svr_port;
+ int opt = 1, read_cnt = 0;
+ char readbuf[RECV_BUF_SIZE];
struct sockaddr_in server_addr, client_addr;
socklen_t client_len;
- port = svr_port;
+
+ INFO("start guest server thread.\n");
if ((server_sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
ERR("create listen socket error\n");
server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
server_addr.sin_port = htons(port);
- int opt = 1;
- setsockopt( server_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof( opt ) );
+ setsockopt(server_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
- if ( 0 > bind( server_sock, (struct sockaddr*) &server_addr, sizeof( server_addr ) ) ) {
- ERR( "guest server bind error: " );
- perror( "bind" );
+ if (bind(server_sock, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) {
+ ERR("guest server bind error: ");
+ perror("bind");
#ifdef _WIN32
if (server_sock) {
closesocket(server_sock);
server_sock = 0;
return NULL;
} else {
- INFO( "success to bind port[127.0.0.1:%d/udp] for guest_server in host \n", port );
+ INFO("success to bind port[127.0.0.1:%d/udp] for guest_server in host \n", port);
}
- client_len = sizeof( client_addr );
-
- char readbuf[RECV_BUF_SIZE];
+ client_len = sizeof(client_addr);
+ INFO("guest server start...port:%d\n", port);
- INFO( "guest server start...port:%d\n", port );
-
- while ( 1 ) {
+ while (1) {
memset(&readbuf, 0, RECV_BUF_SIZE);
if (server_sock == 0) {
INFO("server_sock is closed\n");
return NULL;
}
- int read_cnt = recvfrom(server_sock, readbuf,
- RECV_BUF_SIZE, 0, (struct sockaddr*) &client_addr, &client_len);
+ read_cnt = recvfrom(server_sock, readbuf, RECV_BUF_SIZE, 0,
+ (struct sockaddr*) &client_addr, &client_len);
- if (0 > read_cnt) {
+ if (read_cnt < 0) {
ERR("fail to recvfrom in guest_server.\n");
perror("fail to recvfrom in guest_server.:");
break;
} else {
- if (0 == read_cnt) {
+ if (read_cnt == 0) {
ERR("read_cnt is 0.\n");
break;
}
if (strcmp(command, "2\n" ) == 0) {
TRACE("command:%s\n", command);
notify_sdb_daemon_start();
- }
- if (strcmp(command, "3\n" ) == 0) {
+ } else if (strcmp(command, "3\n" ) == 0) {
TRACE("command:%s\n", command);
notify_sensor_daemon_start();
- }
- else if (strcmp(command, "4\n") == 0) {
+ notify_sdb_daemon_start();
+ } else if (strcmp(command, "4\n") == 0) {
/* sdcard mount/umount msg recv from emuld */
INFO("command:%s\n", command);
char token[] = "\n";
} else if (atoi(ret) == 1) {
/* mount sdcard */
char sdcard_path[256];
- char* vms_path = get_emulator_vms_sdcard_path();
- memset(sdcard_path, '\0', sizeof(sdcard_path));
+ char* vms_path = NULL;
- strcpy(sdcard_path, vms_path);
+ vms_path = get_emulator_vms_sdcard_path();
+ if (vms_path) {
+ g_strlcpy(sdcard_path, vms_path, sizeof(sdcard_path));
- /* emulator_vms_sdcard_path + sdcard img name */
- ret = strtok(NULL, token);
- strcat(sdcard_path, ret);
- INFO("%s\n", sdcard_path);
+ /* emulator_vms_sdcard_path + sdcard img name */
+ ret = strtok(NULL, token);
- //mloop_evcmd_usbdisk(sdcard_path);
- mloop_evcmd_sdcard(sdcard_path);
+ g_strlcat(sdcard_path, ret, sizeof(sdcard_path));
+ TRACE("sdcard path: %s\n", sdcard_path);
- free(vms_path);
+ //mloop_evcmd_usbdisk(sdcard_path);
+ mloop_evcmd_sdcard(sdcard_path);
+
+ g_free(vms_path);
+ } else {
+ ERR("failed to get sdcard path!!\n");
+ }
} else {
ERR("!!! unknown command : %s\n", ret);
}
}
}
-#ifdef _WIN32
+#ifdef CONFIG_WIN32
if (server_sock) {
closesocket(server_sock);
}
}
#endif
server_sock = 0;
+
return NULL;
}
{
int count = 0;
- while ( 1 ) {
+ while (1) {
if (count > 12) {
return -1;
}
server_sock = 0;
}
-
extern GloContext *__glo_context_create(int formatFlags);
/* Create an OpenGL context for a certain pixel format. formatflags are from the GLO_ constants */
-extern GloContext *glo_context_create(int formatFlags, GloContext *shareLists);
+extern GloContext *glo_context_create(int formatFlags, GloContext * shareLists);
/* Destroy a previouslu created OpenGL context */
-extern void glo_context_destroy(GloContext *context);
+extern void glo_context_destroy(GloContext * context);
/* Update the context in surface and free previous light-weight context */
-extern void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags);
+extern void glo_surface_update_context(GloSurface * surface,
+ GloContext * context, int free_flags);
/* Link the pixmap/pbuffer associated with surface as texture.
* ctxt is the target context for the texture operation
*/
-extern void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface, int surface_type);
+extern void glo_surface_as_texture(GloContext * ctxt, GloSurface * surface,
+ int surface_type);
/* Create a surface with given width and height, */
-extern GloSurface *glo_surface_create(int width, int height, GloContext *context);
+extern GloSurface *glo_surface_create(int width, int height,
+ GloContext * context);
/* Destroy the given surface */
-extern void glo_surface_destroy(GloSurface *surface);
+extern void glo_surface_destroy(GloSurface * surface);
/* Make the given surface current */
-extern int glo_surface_makecurrent(GloSurface *surface);
+extern int glo_surface_makecurrent(GloSurface * surface);
/* Get the contents of the given surface. Note that this is top-down, not
* bottom-up as glReadPixels would do. */
-extern void glo_surface_getcontents(GloSurface *surface, int stride, int type, void *data);
+extern void glo_surface_getcontents(GloSurface * surface, int stride, int type,
+ void *data);
/* Return the width and height of the given surface */
-extern void glo_surface_get_size(GloSurface *surface, int *width, int *height);
+extern void glo_surface_get_size(GloSurface * surface, int *width, int *height);
/* Functions to decode the format flags */
extern int glo_flags_get_depth_bits(int formatFlags);
extern int glo_flags_get_stencil_bits(int formatFlags);
extern void glo_flags_get_rgba_bits(int formatFlags, int *rgba);
extern int glo_flags_get_bytes_per_pixel(int formatFlags);
-extern void glo_flags_get_readpixel_type(int formatFlags, int *glFormat, int *glType);
+extern void glo_flags_get_readpixel_type(int formatFlags, int *glFormat,
+ int *glType);
/* Score how close the given format flags match. 0=great, >0 not so great */
extern int glo_flags_score(int formatFlagsExpected, int formatFlagsReal);
extern int glo_get_glx_from_flags(int formatFlags, int glxEnum);
/* Get the width and height from attrib_list */
-extern void glo_geometry_get_from_glx(const int* attrib_list, int* width, int* height);
+extern void glo_geometry_get_from_glx(const int *attrib_list, int *width,
+ int *height);
+
+extern void glo_surface_release_texture(GloSurface * surface);
+extern void glo_surface_updatecontents(GloSurface * surface);
/* In terms of speed, glReadPixels actually seems the best we can do.
* * On Windows PFB_DRAW_TO_BITMAP is software-only.
* doing this on Windows at least.
*/
-#endif /* GLOFFSCREEN_H_ */
+#endif /* GLOFFSCREEN_H_ */
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
-*/
-#ifdef __APPLE__
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+*/
+#ifdef __APPLE__
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#include <inttypes.h>
#include <dlfcn.h>
/*hack due to conflicting typedefs in qemu's softfloat.h*/
#define __SECURITYHI__ 1
-
-#include <OpenGL/OpenGL.h>
-#include <AGL/agl.h>
-#include "gloffscreen.h"
-
-#ifdef GL_DEBUG
-#define TRACE(fmt, ...) printf("%s@%d: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
-#else
-#define TRACE(...)
-#endif
-
-struct _GloContext
-{
- GLuint formatFlags;
- AGLPixelFormat pixelFormat;
- AGLContext context;
- };
-
-struct _GloSurface
-{
- GLuint width;
- GLuint height;
- GloContext *context;
- AGLPbuffer pbuffer;
- };
-
-extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
- int bpp, int width, int height,
- void *data, int noflip);
-
-
-
-/* Initialise gloffscreen */
-int glo_init(void)
+
+#include <OpenGL/OpenGL.h>
+#include <AGL/agl.h>
+#include "gloffscreen.h"
+
+#ifdef GL_DEBUG
+#define TRACE(fmt, ...) printf("%s@%d: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define TRACE(...)
+#endif
+
+struct _GloContext {
+ GLuint formatFlags;
+ AGLPixelFormat pixelFormat;
+ AGLContext context;
+};
+
+struct _GloSurface {
+ GLuint width;
+ GLuint height;
+ GloContext *context;
+ AGLPbuffer pbuffer;
+};
+
+extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
+ int bpp, int width, int height,
+ void *data, int noflip);
+
+/* Initialise gloffscreen */
+int glo_init(void)
+{
+ int major, minor;
+ aglGetVersion(&major, &minor);
+ fprintf(stdout, "%s----AGL version %d.%d\n", __FUNCTION__, major, minor);
+ return 0;
+}
+
+/* Uninitialise gloffscreen */
+void glo_kill(void)
+{
+
+}
+
+const char *glo_glXQueryExtensionsString(void)
+{
+ return "";
+}
+
+/* Like wglGetProcAddress/glxGetProcAddress */
+void *glo_getprocaddress(const char *procName)
{
- int major, minor;
- aglGetVersion(&major, &minor);
- fprintf(stdout, "%s----AGL version %d.%d\n",__FUNCTION__, major, minor);
- return 0;
- }
-
-/* Uninitialise gloffscreen */
-void glo_kill(void)
-{
-
-}
-
-const char *glo_glXQueryExtensionsString(void)
-{
- return "";
- }
-
-/* Like wglGetProcAddress/glxGetProcAddress */
- void *glo_getprocaddress(const char *procName)
- {
void *ret = NULL;
- if (procName)
- {
- if (!strncmp(procName, "glX", 3))
- ret = (void *)1;
- else
+ if (procName) {
+ if (!strncmp(procName, "glX", 3))
+ ret = (void *)1;
+ else
ret = dlsym(RTLD_NEXT, procName);
- }
-
-#if 0//standard code for mac to look up procaddress, but seems slow that above.
- NSSymbol symbol;
- char *symbolname;
- symbolname = malloc(strlen(procName) +2);
- strcpy(symbolname +1, procName);
- symbolname[0] = '_';
- symbol = NULL;
- if(NSIsSymbolNameDefined(symbolname))
- symbol = NSLookupAndBindSymbol(symbolname);
- free(symbolname);
- ret = symbol ? NSAddressOfSymbol (symbol) : NULL;
-#endif
- TRACE("'%s' --> %p", procName, ret);
- return ret;
-}
-
+ }
+#if 0 //standard code for mac to look up procaddress, but seems slow that above.
+ NSSymbol symbol;
+ char *symbolname;
+ symbolname = malloc(strlen(procName) + 2);
+ strcpy(symbolname + 1, procName);
+ symbolname[0] = '_';
+ symbol = NULL;
+ if (NSIsSymbolNameDefined(symbolname))
+ symbol = NSLookupAndBindSymbol(symbolname);
+ free(symbolname);
+ ret = symbol ? NSAddressOfSymbol(symbol) : NULL;
+#endif
+ TRACE("'%s' --> %p", procName, ret);
+ return ret;
+}
+
/* Create an OpenGL context for a certain pixel format.
* formatflags are from the GLO_ constants
*/
GloContext *__glo_context_create(int formatFlags)
{
- int rgba[4];
- glo_flags_get_rgba_bits(formatFlags, rgba);
- const int attribs[] = {
+ int rgba[4];
+ glo_flags_get_rgba_bits(formatFlags, rgba);
+ const int attribs[] = {
AGL_RGBA,
AGL_MINIMUM_POLICY,
AGL_PIXEL_SIZE, glo_flags_get_bytes_per_pixel(formatFlags) * 8,
glo_flags_get_depth_bits(formatFlags),
glo_flags_get_stencil_bits(formatFlags));
- AGLPixelFormat pf = aglChoosePixelFormat(NULL, 0, attribs);
+ AGLPixelFormat pf = aglChoosePixelFormat(NULL, 0, attribs);
if (pf == NULL)
fprintf(stderr, "No matching pixelformat found.");
- else
- {
+ else {
GLint bpp = 0, a = 0, d = 0, s = 0;
aglDescribePixelFormat(pf, AGL_PIXEL_SIZE, &bpp);
aglDescribePixelFormat(pf, AGL_ALPHA_SIZE, &a);
aglDescribePixelFormat(pf, AGL_DEPTH_SIZE, &d);
aglDescribePixelFormat(pf, AGL_STENCIL_SIZE, &s);
- formatFlags &= ~(GLO_FF_ALPHA_MASK | GLO_FF_BITS_MASK | GLO_FF_DEPTH_MASK | GLO_FF_STENCIL_MASK);
+ formatFlags &=
+ ~(GLO_FF_ALPHA_MASK | GLO_FF_BITS_MASK | GLO_FF_DEPTH_MASK |
+ GLO_FF_STENCIL_MASK);
switch (bpp) {
- case 16: formatFlags |= GLO_FF_BITS_16; break;
- case 24: formatFlags |= GLO_FF_BITS_24; break;
- case 32: formatFlags |= GLO_FF_BITS_32; break;
- default: fprintf(stderr, "got unsupported bpp %d", bpp); break;
- }
-
- if (a > 0)
- {
+ case 16:
+ formatFlags |= GLO_FF_BITS_16;
+ break;
+ case 24:
+ formatFlags |= GLO_FF_BITS_24;
+ break;
+ case 32:
+ formatFlags |= GLO_FF_BITS_32;
+ break;
+ default:
+ fprintf(stderr, "got unsupported bpp %d", bpp);
+ break;
+ }
+
+ if (a > 0) {
formatFlags |= GLO_FF_ALPHA;
}
switch (d) {
- case 0: break;
- case 16: formatFlags |= GLO_FF_DEPTH_16; break;
- case 24: formatFlags |= GLO_FF_DEPTH_24; break;
- case 32: formatFlags |= GLO_FF_DEPTH_32; break;
- default: fprintf(stderr, "got unsupported depth %d", d); break;
+ case 0:
+ break;
+ case 16:
+ formatFlags |= GLO_FF_DEPTH_16;
+ break;
+ case 24:
+ formatFlags |= GLO_FF_DEPTH_24;
+ break;
+ case 32:
+ formatFlags |= GLO_FF_DEPTH_32;
+ break;
+ default:
+ fprintf(stderr, "got unsupported depth %d", d);
+ break;
}
switch (s) {
- case 0: break;
- case 8: formatFlags |= GLO_FF_STENCIL_8; break;
- default: fprintf(stderr, "got unsupported stencil %d", s); break;
- }
- }
- GloContext *context = (GloContext *)g_malloc(sizeof(*context));
+ case 0:
+ break;
+ case 8:
+ formatFlags |= GLO_FF_STENCIL_8;
+ break;
+ default:
+ fprintf(stderr, "got unsupported stencil %d", s);
+ break;
+ }
+ }
+ GloContext *context = (GloContext *) g_malloc(sizeof(*context));
memset(context, 0, sizeof(*context));
context->formatFlags = formatFlags;
context->pixelFormat = pf;
return context;
}
-
-GloContext *glo_context_create(int formatFlags, GloContext *shareLists)
-{
- GloContext *context = __glo_context_create(formatFlags);
- if(!context)
- return NULL;
-
- context->context = aglCreateContext(context->pixelFormat, shareLists ? shareLists->context : NULL);
- if (context->context == NULL)
- {
- fprintf(stderr, "aglCreateContext failed: %s", aglErrorString(aglGetError()));
- }
-
- else
- {
- if(context->pixelFormat != NULL)
- {
- aglDestroyPixelFormat(context->pixelFormat);
- context->pixelFormat = NULL;
- }
- }
-
- TRACE("context=%p", context);
- return context;
-}
-
-/* Destroy a previously created OpenGL context */
-void glo_context_destroy(GloContext *context)
-{
- TRACE("context=%p", context);
- if (context)
- {
- aglDestroyContext(context->context);
- if(context->pixelFormat != NULL)
- {
- aglDestroyPixelFormat(context->pixelFormat);
- context->pixelFormat = NULL;
- }
- context->context = NULL;
- g_free(context);
- }
+
+GloContext *glo_context_create(int formatFlags, GloContext * shareLists)
+{
+ GloContext *context = __glo_context_create(formatFlags);
+ if (!context)
+ return NULL;
+
+ context->context =
+ aglCreateContext(context->pixelFormat,
+ shareLists ? shareLists->context : NULL);
+ if (context->context == NULL) {
+ fprintf(stderr, "aglCreateContext failed: %s",
+ aglErrorString(aglGetError()));
+ }
+
+ else {
+ if (context->pixelFormat != NULL) {
+ aglDestroyPixelFormat(context->pixelFormat);
+ context->pixelFormat = NULL;
+ }
+ }
+
+ TRACE("context=%p", context);
+ return context;
+}
+
+/* Destroy a previously created OpenGL context */
+void glo_context_destroy(GloContext * context)
+{
+ TRACE("context=%p", context);
+ if (context) {
+ aglDestroyContext(context->context);
+ if (context->pixelFormat != NULL) {
+ aglDestroyPixelFormat(context->pixelFormat);
+ context->pixelFormat = NULL;
+ }
+ context->context = NULL;
+ g_free(context);
+ }
}
-void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags)
+void glo_surface_update_context(GloSurface * surface, GloContext * context,
+ int free_flags)
{
- if ( surface->context )
- {
- if ( free_flags) /* light-weight context */
+ if (surface->context) {
+ if (free_flags) /* light-weight context */
g_free(surface->context);
}
surface->context = context;
}
-
-
/* Create a surface with given width and height, formatflags are from the
- * GLO_ constants */
-GloSurface *glo_surface_create(int width, int height, GloContext *context)
-{
- GloSurface *surface = NULL;
- if (context)
- {
- surface = (GloSurface *)g_malloc(sizeof(*surface));
- memset(surface, 0, sizeof(*surface));
- surface->width = width;
- surface->height = height;
- surface->context = context;
-
- TRACE("%dx%d", surface->width, surface->height);
- if (aglCreatePBuffer(width, height, GL_TEXTURE_2D, GL_RGBA, 0, &surface->pbuffer) == GL_FALSE)
- fprintf(stderr, "aglCreatePbuffer failed: %s", aglErrorString(aglGetError()));
-
- }
- TRACE("surface=%p", surface);
- return surface;
-}
-
-/* Destroy the given surface */
-void glo_surface_destroy(GloSurface *surface)
-{
- TRACE("surface=%p", surface);
- if (surface)
- {
- aglDestroyPBuffer(surface->pbuffer);
- surface->pbuffer = NULL;
- g_free(surface);
- }
-}
-
-/* Make the given surface current */
-int glo_surface_makecurrent(GloSurface *surface)
-{
- int ret = GL_FALSE;
- TRACE("surface=%p", surface);
- if (surface)
- {
- if (aglSetPBuffer(surface->context->context, surface->pbuffer, 0, 0, 0) == GL_FALSE)
- fprintf(stderr, "aglSetPbuffer failed: %s", aglErrorString(aglGetError()));
- ret = aglSetCurrentContext(surface->context->context);
- } else
- {
- ret = aglSetCurrentContext(NULL);
- }
+ * GLO_ constants */
+GloSurface *glo_surface_create(int width, int height, GloContext * context)
+{
+ GloSurface *surface = NULL;
+ if (context) {
+ surface = (GloSurface *) g_malloc(sizeof(*surface));
+ memset(surface, 0, sizeof(*surface));
+ surface->width = width;
+ surface->height = height;
+ surface->context = context;
+
+ TRACE("%dx%d", surface->width, surface->height);
+ if (aglCreatePBuffer
+ (width, height, GL_TEXTURE_2D, GL_RGBA, 0,
+ &surface->pbuffer) == GL_FALSE)
+ fprintf(stderr, "aglCreatePbuffer failed: %s",
+ aglErrorString(aglGetError()));
+
+ }
+ TRACE("surface=%p", surface);
+ return surface;
+}
+
+/* Destroy the given surface */
+void glo_surface_destroy(GloSurface * surface)
+{
+ TRACE("surface=%p", surface);
+ if (surface) {
+ aglDestroyPBuffer(surface->pbuffer);
+ surface->pbuffer = NULL;
+ g_free(surface);
+ }
+}
+
+/* Make the given surface current */
+int glo_surface_makecurrent(GloSurface * surface)
+{
+ int ret = GL_FALSE;
+ TRACE("surface=%p", surface);
+ if (surface) {
+ if (aglSetPBuffer(surface->context->context, surface->pbuffer, 0, 0, 0)
+ == GL_FALSE)
+ fprintf(stderr, "aglSetPbuffer failed: %s",
+ aglErrorString(aglGetError()));
+ ret = aglSetCurrentContext(surface->context->context);
+ } else {
+ ret = aglSetCurrentContext(NULL);
+ }
if (ret == GL_FALSE)
- fprintf(stderr, "aglSetCurrentContext failed: %s", aglErrorString(aglGetError()));
-
- TRACE("Return ret=%d\n", ret);
- return ret;
- }
+ fprintf(stderr, "aglSetCurrentContext failed: %s",
+ aglErrorString(aglGetError()));
-void glo_surface_updatecontents(GloSurface *surface)
+ TRACE("Return ret=%d\n", ret);
+ return ret;
+}
+
+void glo_surface_updatecontents(GloSurface * surface)
{
- const GLint swap_interval = 1;
+ const GLint swap_interval = 1;
+
+ if (!surface)
+ return;
+ aglSwapBuffers(surface->context->context);
+ aglSetInteger(surface->context->context, AGL_SWAP_INTERVAL, &swap_interval);
+}
- if(!surface)
- return;
- aglSwapBuffers(surface->context->context);
- aglSetInteger(surface->context->context, AGL_SWAP_INTERVAL, &swap_interval);
+/* Get the contents of the given surface */
+void glo_surface_getcontents(GloSurface * surface, int stride, int bpp,
+ void *data)
+{
+ const GLint swap_interval = 1;
+ if (surface) {
+ aglSwapBuffers(surface->context->context);
+ aglSetInteger(surface->context->context, AGL_SWAP_INTERVAL,
+ &swap_interval);
+ glo_surface_getcontents_readpixels(surface->context->formatFlags,
+ stride, bpp, surface->width,
+ surface->height, data, 0);
+ }
}
-
-/* Get the contents of the given surface */
-void glo_surface_getcontents(GloSurface *surface, int stride, int bpp,
- void *data)
+/* Return the width and height of the given surface */
+void glo_surface_get_size(GloSurface * surface, int *width, int *height)
{
- const GLint swap_interval = 1;
- if (surface)
- {
- aglSwapBuffers(surface->context->context);
- aglSetInteger(surface->context->context, AGL_SWAP_INTERVAL, &swap_interval);
- glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, surface->height, data, 0);
- }
-}
-
-/* Return the width and height of the given surface */
-void glo_surface_get_size(GloSurface *surface, int *width, int *height)
-{
- if (width)
- {
- *width = surface->width;
- }
-
- if (height)
- {
- *height = surface->height;
- }
-}
-
+ if (width) {
+ *width = surface->width;
+ }
+
+ if (height) {
+ *height = surface->height;
+ }
+}
+
/* Bind the surface as texture */
-void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface, int surface_type)
+void glo_surface_as_texture(GloContext * ctxt, GloSurface * surface,
+ int surface_type)
{
#if 0
- //Not QUit sure about this function;
- int glFormat, glType;
- glo_surface_updatecontents(surface);
- /*XXX: changet the fixed target: GL_TEXTURE_2D*/
- glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat, &glType);
- fprintf(stderr, "surface_as_texture:teximage:width=%d,height=%d, glFormat=0x%x, glType=0x%x.\n", surface->width, surface->height, glFormat, glType);
+ //Not QUit sure about this function;
+ int glFormat, glType;
+ glo_surface_updatecontents(surface);
+ /*XXX: changet the fixed target: GL_TEXTURE_2D */
+ glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat,
+ &glType);
+ fprintf(stderr,
+ "surface_as_texture:teximage:width=%d,height=%d, glFormat=0x%x, glType=0x%x.\n",
+ surface->width, surface->height, glFormat, glType);
/* glTexImage2D use different RGB order than the contexts in the pixmap surface */
/* glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->image->data);*/
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, surface->pbuffer);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0,
+ glFormat, glType, surface->pbuffer);
#else
- if (aglTexImagePBuffer(ctxt->context, surface->pbuffer, GL_BACK) == GL_FALSE)
- fprintf(stderr, "aglTexImagePBuffer failed: %s", aglErrorString(aglGetError()));
+ if (aglTexImagePBuffer(ctxt->context, surface->pbuffer, GL_BACK) ==
+ GL_FALSE)
+ fprintf(stderr, "aglTexImagePBuffer failed: %s",
+ aglErrorString(aglGetError()));
- glFinish();
+ glFinish();
#endif
}
-void glo_surface_release_texture(GloSurface *surface)
+void glo_surface_release_texture(GloSurface * surface)
{
}
-
-#endif
+#endif
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
-#elif __APPLE__
+#elif defined __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
// ---------------------------------------------------
extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
- int bpp, int width, int height, void *data, int noflip);
+ int bpp, int width, int height,
+ void *data, int noflip);
// ---------------------------------------------------
-int glo_flags_get_depth_bits(int formatFlags) {
- switch ( formatFlags & GLO_FF_DEPTH_MASK ) {
- case GLO_FF_DEPTH_16: return 16;
- case GLO_FF_DEPTH_24: return 24;
- case GLO_FF_DEPTH_32: return 32;
- default: return 0;
+int glo_flags_get_depth_bits(int formatFlags)
+{
+ switch (formatFlags & GLO_FF_DEPTH_MASK) {
+ case GLO_FF_DEPTH_16:
+ return 16;
+ case GLO_FF_DEPTH_24:
+ return 24;
+ case GLO_FF_DEPTH_32:
+ return 32;
+ default:
+ return 0;
}
}
-int glo_flags_get_stencil_bits(int formatFlags) {
- switch ( formatFlags & GLO_FF_STENCIL_MASK ) {
- case GLO_FF_STENCIL_8: return 8;
- default: return 0;
+int glo_flags_get_stencil_bits(int formatFlags)
+{
+ switch (formatFlags & GLO_FF_STENCIL_MASK) {
+ case GLO_FF_STENCIL_8:
+ return 8;
+ default:
+ return 0;
}
}
-void glo_flags_get_rgba_bits(int formatFlags, int *rgba) {
+void glo_flags_get_rgba_bits(int formatFlags, int *rgba)
+{
int alpha = (formatFlags & GLO_FF_ALPHA) != 0;
- switch ( formatFlags & GLO_FF_BITS_MASK ) {
- case GLO_FF_BITS_16:
- rgba[0] = alpha ? 4 : 5;
- rgba[1] = alpha ? 4 : 6;
- rgba[2] = alpha ? 4 : 5;
- rgba[3] = alpha ? 4 : 0;
- break;
- case GLO_FF_BITS_24:
- // ignore alpha
- rgba[0] = 8;
- rgba[1] = 8;
- rgba[2] = 8;
- rgba[3] = 0;
- break;
- case GLO_FF_BITS_32:
- rgba[0] = 8;
- rgba[1] = 8;
- rgba[2] = 8;
- rgba[3] = 8;
- break;
- default:
- rgba[0] = 8;
- rgba[1] = 8;
- rgba[2] = 8;
- rgba[3] = 0;
- break;
- }
+ switch (formatFlags & GLO_FF_BITS_MASK) {
+ case GLO_FF_BITS_16:
+ rgba[0] = alpha ? 4 : 5;
+ rgba[1] = alpha ? 4 : 6;
+ rgba[2] = alpha ? 4 : 5;
+ rgba[3] = alpha ? 4 : 0;
+ break;
+ case GLO_FF_BITS_24:
+ // ignore alpha
+ rgba[0] = 8;
+ rgba[1] = 8;
+ rgba[2] = 8;
+ rgba[3] = 0;
+ break;
+ case GLO_FF_BITS_32:
+ rgba[0] = 8;
+ rgba[1] = 8;
+ rgba[2] = 8;
+ rgba[3] = 8;
+ break;
+ default:
+ rgba[0] = 8;
+ rgba[1] = 8;
+ rgba[2] = 8;
+ rgba[3] = 0;
+ break;
+ }
}
-int glo_flags_get_bytes_per_pixel(int formatFlags) {
- switch ( formatFlags & GLO_FF_BITS_MASK ) {
- case GLO_FF_BITS_16: return 2;
- case GLO_FF_BITS_24: return 3;
- case GLO_FF_BITS_32: return 4;
- default: return 3;
+int glo_flags_get_bytes_per_pixel(int formatFlags)
+{
+ switch (formatFlags & GLO_FF_BITS_MASK) {
+ case GLO_FF_BITS_16:
+ return 2;
+ case GLO_FF_BITS_24:
+ return 3;
+ case GLO_FF_BITS_32:
+ return 4;
+ default:
+ return 3;
}
}
-void glo_flags_get_readpixel_type(int formatFlags, int *glFormat, int *glType) {
+void glo_flags_get_readpixel_type(int formatFlags, int *glFormat, int *glType)
+{
GLenum gFormat, gType;
if (formatFlags & GLO_FF_ALPHA) {
- switch ( formatFlags & GLO_FF_BITS_MASK ) {
- case GLO_FF_BITS_16:
- gFormat = GL_RGBA;
- gType = GL_UNSIGNED_SHORT_4_4_4_4;
- break;
- case GLO_FF_BITS_24:
- case GLO_FF_BITS_32:
- default:
- gFormat = GL_BGRA;
- gType = GL_UNSIGNED_BYTE;
- break;
+ switch (formatFlags & GLO_FF_BITS_MASK) {
+ case GLO_FF_BITS_16:
+ gFormat = GL_RGBA;
+ gType = GL_UNSIGNED_SHORT_4_4_4_4;
+ break;
+ case GLO_FF_BITS_24:
+ case GLO_FF_BITS_32:
+ default:
+ gFormat = GL_BGRA;
+ gType = GL_UNSIGNED_BYTE;
+ break;
}
} else {
- switch ( formatFlags & GLO_FF_BITS_MASK ) {
- case GLO_FF_BITS_16:
- gFormat = GL_RGB;
- gType = GL_UNSIGNED_SHORT_5_6_5;
- break;
- case GLO_FF_BITS_24:
- case GLO_FF_BITS_32:
- default:
- gFormat = GL_BGR;
- gType = GL_UNSIGNED_BYTE;
- break;
+ switch (formatFlags & GLO_FF_BITS_MASK) {
+ case GLO_FF_BITS_16:
+ gFormat = GL_RGB;
+ gType = GL_UNSIGNED_SHORT_5_6_5;
+ break;
+ case GLO_FF_BITS_24:
+ case GLO_FF_BITS_32:
+ default:
+ gFormat = GL_BGR;
+ gType = GL_UNSIGNED_BYTE;
+ break;
}
}
#if 0
// seems wrong below.
-int glo_flags_score(int formatFlagsExpected, int formatFlagsReal) {
+int glo_flags_score(int formatFlagsExpected, int formatFlagsReal)
+{
if (formatFlagsExpected == formatFlagsReal)
return 0;
int score = 1;
// we wanted alpha, but we didn't get it
- if ((formatFlagsExpected&GLO_FF_ALPHA_MASK) <
- (formatFlagsReal&GLO_FF_ALPHA_MASK))
+ if ((formatFlagsExpected & GLO_FF_ALPHA_MASK) <
+ (formatFlagsReal & GLO_FF_ALPHA_MASK))
score++;
// less bits than we expected
- if ((formatFlagsExpected&GLO_FF_BITS_MASK) <
- !(formatFlagsReal&GLO_FF_BITS_MASK))
+ if ((formatFlagsExpected & GLO_FF_BITS_MASK) <
+ !(formatFlagsReal & GLO_FF_BITS_MASK))
score++;
// less depth bits than we expected
- if ((formatFlagsExpected&GLO_FF_DEPTH_MASK) <
- !(formatFlagsReal&GLO_FF_DEPTH_MASK))
+ if ((formatFlagsExpected & GLO_FF_DEPTH_MASK) <
+ !(formatFlagsReal & GLO_FF_DEPTH_MASK))
score++;
// less stencil bits than we expected
- if ((formatFlagsExpected&GLO_FF_STENCIL_MASK) <
- !(formatFlagsReal&GLO_FF_STENCIL_MASK))
+ if ((formatFlagsExpected & GLO_FF_STENCIL_MASK) <
+ !(formatFlagsReal & GLO_FF_STENCIL_MASK))
score++;
return score;
}
#else
-int glo_flags_score(int formatFlagsExpected, int formatFlagsReal) {
+int glo_flags_score(int formatFlagsExpected, int formatFlagsReal)
+{
if (formatFlagsExpected == formatFlagsReal)
return 0;
// we wanted alpha, but we didn't get it
if ((formatFlagsReal & GLO_FF_ALPHA_MASK) <
- (formatFlagsExpected & GLO_FF_ALPHA_MASK))
+ (formatFlagsExpected & GLO_FF_ALPHA_MASK))
score++;
// less bits than we expected
if ((formatFlagsReal & GLO_FF_BITS_MASK) <
}
#endif
-int glo_flags_get_from_glx(const int *fbConfig, int assumeBooleans) {
+int glo_flags_get_from_glx(const int *fbConfig, int assumeBooleans)
+{
int bufferSize = 0;
int depthSize = 0;
int stencilSize = 0;
- int rgbaSize[] = {0,0,0,0};
+ int rgbaSize[] = { 0, 0, 0, 0 };
int flags = 0;
while (*fbConfig) {
int isSingle = 0;
switch (*fbConfig) {
- case GLX_USE_GL:
- isSingle = 1;
- break;
- case GLX_BUFFER_SIZE:
- bufferSize = fbConfig[1];
- break;
- case GLX_LEVEL:
- break;
- case GLX_RGBA:
- flags |= GLO_FF_ALPHA;
- break;
- case GLX_DOUBLEBUFFER:
- isSingle = 1;
- break;
- case GLX_STEREO:
- isSingle = 1;
- break;
- case GLX_AUX_BUFFERS:
- break;
- case GLX_RED_SIZE:
- rgbaSize[0] = fbConfig[1];
- break;
- case GLX_GREEN_SIZE:
- rgbaSize[1] = fbConfig[1];
- break;
- case GLX_BLUE_SIZE:
- rgbaSize[2] = fbConfig[1];
- break;
- case GLX_ALPHA_SIZE:
- rgbaSize[3] = fbConfig[1];
- break;
- case GLX_DEPTH_SIZE:
- depthSize = fbConfig[1];
- break;
- case GLX_STENCIL_SIZE:
- stencilSize = fbConfig[1];
- break;
- case GLX_ACCUM_RED_SIZE:
- case GLX_ACCUM_GREEN_SIZE:
- case GLX_ACCUM_BLUE_SIZE:
- case GLX_ACCUM_ALPHA_SIZE:
- break;
- default:
- break;
+ case GLX_USE_GL:
+ isSingle = 1;
+ break;
+ case GLX_BUFFER_SIZE:
+ bufferSize = fbConfig[1];
+ break;
+ case GLX_LEVEL:
+ break;
+ case GLX_RGBA:
+ flags |= GLO_FF_ALPHA;
+ break;
+ case GLX_DOUBLEBUFFER:
+ isSingle = 1;
+ break;
+ case GLX_STEREO:
+ isSingle = 1;
+ break;
+ case GLX_AUX_BUFFERS:
+ break;
+ case GLX_RED_SIZE:
+ rgbaSize[0] = fbConfig[1];
+ break;
+ case GLX_GREEN_SIZE:
+ rgbaSize[1] = fbConfig[1];
+ break;
+ case GLX_BLUE_SIZE:
+ rgbaSize[2] = fbConfig[1];
+ break;
+ case GLX_ALPHA_SIZE:
+ rgbaSize[3] = fbConfig[1];
+ break;
+ case GLX_DEPTH_SIZE:
+ depthSize = fbConfig[1];
+ break;
+ case GLX_STENCIL_SIZE:
+ stencilSize = fbConfig[1];
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ case GLX_ACCUM_GREEN_SIZE:
+ case GLX_ACCUM_BLUE_SIZE:
+ case GLX_ACCUM_ALPHA_SIZE:
+ break;
+ default:
+ break;
}
// go to next
if (isSingle && assumeBooleans)
fbConfig++;
else
- fbConfig+=2;
+ fbConfig += 2;
}
if (rgbaSize[3])
flags |= GLO_FF_ALPHA;
// ensure we have room for *some* alpha
- if ((flags & GLO_FF_ALPHA) && (rgbaSize[3]==0))
+ if ((flags & GLO_FF_ALPHA) && (rgbaSize[3] == 0))
rgbaSize[3] = 1;
// Buffer size flag
- if (bufferSize==0)
- bufferSize = rgbaSize[0]+rgbaSize[1]+rgbaSize[2]+rgbaSize[3];
- if (bufferSize==0)
+ if (bufferSize == 0)
+ bufferSize = rgbaSize[0] + rgbaSize[1] + rgbaSize[2] + rgbaSize[3];
+ if (bufferSize == 0)
bufferSize = (flags & GLO_FF_ALPHA) ? 32 : 24;
- if (bufferSize<=16)
+ if (bufferSize <= 16)
flags |= GLO_FF_BITS_16;
- else if (bufferSize<=24)
+ else if (bufferSize <= 24)
flags |= GLO_FF_BITS_24;
else
flags |= GLO_FF_BITS_32;
// Depth
- if (depthSize<=16)
+ if (depthSize <= 16)
flags |= GLO_FF_DEPTH_16;
- else if (depthSize<=24)
+ else if (depthSize <= 24)
flags |= GLO_FF_DEPTH_24;
else
flags |= GLO_FF_DEPTH_32;
// Stencil
- if (stencilSize>0)
+ if (stencilSize > 0)
flags |= GLO_FF_STENCIL_8;
return flags;
}
-void glo_geometry_get_from_glx(const int* attrib_list, int* width, int* height)
+void glo_geometry_get_from_glx(const int *attrib_list, int *width, int *height)
{
- while ( *attrib_list )
- {
- switch (*attrib_list)
- {
- case GLX_WIDTH:
- *width = attrib_list[1];
- break;
- case GLX_HEIGHT:
- *height = attrib_list[1];
- break;
- default:
- fprintf(stderr, "Should not pass any attribs except for width and height for glXCreiatePixmap. \n");
+ while (*attrib_list) {
+ switch (*attrib_list) {
+ case GLX_WIDTH:
+ *width = attrib_list[1];
+ break;
+ case GLX_HEIGHT:
+ *height = attrib_list[1];
+ break;
+ default:
+ fprintf(stderr,
+ "Should not pass any attribs except for width and height for glXCreiatePixmap. \n");
}
attrib_list += 2;
}
}
void glo_surface_getcontents_readpixels(int formatFlags, int stride, int bpp,
- int width, int height, void *data, int noflip) {
+ int width, int height, void *data,
+ int noflip)
+{
int glFormat, glType, rl, pa;
static int once;
glo_flags_get_readpixel_type(formatFlags, &glFormat, &glType);
- switch(bpp) {
- case 24:
- if(glFormat != GL_BGR) {
- if(!once) {
- fprintf(stderr, "Warning: compressing alpha\n");
- once = 1;
- }
- glFormat = GL_BGR;
- }
- break;
- case 32:
- if(glFormat != GL_BGRA) {
- fprintf(stderr, "Warning: expanding alpha!\n");
- glFormat = GL_BGRA;
+ switch (bpp) {
+ case 24:
+ if (glFormat != GL_BGR) {
+ if (!once) {
+ fprintf(stderr, "Warning: compressing alpha\n");
+ once = 1;
}
- break;
- default:
- fprintf(stderr, "Warning: unsupported colourdepth\n");
- break;
+ glFormat = GL_BGR;
+ }
+ break;
+ case 32:
+ if (glFormat != GL_BGRA) {
+ fprintf(stderr, "Warning: expanding alpha!\n");
+ glFormat = GL_BGRA;
+ }
+ break;
+ default:
+ fprintf(stderr, "Warning: unsupported colourdepth\n");
+ break;
}
// Save guest processes GL state before we ReadPixels()
glPixelStorei(GL_PACK_ALIGNMENT, 4);
#ifdef GETCONTENTS_INDIVIDUAL
- GLubyte *b = (GLubyte *)data;
+ GLubyte *b = (GLubyte *) data;
int irow;
- for(irow = height-1 ; irow >= 0 ; irow--) {
+ for (irow = height - 1; irow >= 0; irow--) {
glReadPixels(0, irow, width, 1, glFormat, glType, b);
b += stride;
}
#else
// Faster buffer flip
- GLubyte *b = (GLubyte *)data;
- GLubyte *c = &((GLubyte *)data)[stride*(height-1)];
- GLubyte *tmp = (GLubyte*)g_malloc(stride);
+ GLubyte *b = (GLubyte *) data;
+ GLubyte *c = &((GLubyte *) data)[stride * (height - 1)];
+ GLubyte *tmp = (GLubyte *) g_malloc(stride);
int irow;
glReadPixels(0, 0, width, height, glFormat, glType, data);
if (noflip == 0) {
- for(irow = 0; irow < height/2; irow++) {
+ for (irow = 0; irow < height / 2; irow++) {
memcpy(tmp, b, stride);
memcpy(b, c, stride);
memcpy(c, tmp, stride);
glPixelStorei(GL_PACK_ALIGNMENT, pa);
}
-int glo_get_glx_from_flags(int formatFlags, int glxEnum) {
+int glo_get_glx_from_flags(int formatFlags, int glxEnum)
+{
int rgba[4];
glo_flags_get_rgba_bits(formatFlags, rgba);
switch (glxEnum) {
- case GLX_USE_GL: return 1;
- case GLX_BUFFER_SIZE:
- return glo_flags_get_bytes_per_pixel(formatFlags)*8;
- case GLX_LEVEL: return 0;
- case GLX_RGBA: return formatFlags & GLO_FF_ALPHA;
- case GLX_DOUBLEBUFFER: return 1;
- case GLX_STEREO: return 0;
- case GLX_AUX_BUFFERS: return 0;
- case GLX_RED_SIZE: return rgba[0];
- case GLX_GREEN_SIZE: return rgba[1];
- case GLX_BLUE_SIZE: return rgba[2];
- case GLX_ALPHA_SIZE: return rgba[3];
- case GLX_DEPTH_SIZE: return glo_flags_get_depth_bits(formatFlags);
- case GLX_STENCIL_SIZE: return glo_flags_get_stencil_bits(formatFlags);
- case GLX_ACCUM_RED_SIZE:
- case GLX_ACCUM_GREEN_SIZE:
- case GLX_ACCUM_BLUE_SIZE:
- case GLX_ACCUM_ALPHA_SIZE:
- return 0;
+ case GLX_USE_GL:
+ return 1;
+ case GLX_BUFFER_SIZE:
+ return glo_flags_get_bytes_per_pixel(formatFlags) * 8;
+ case GLX_LEVEL:
+ return 0;
+ case GLX_RGBA:
+ return formatFlags & GLO_FF_ALPHA;
+ case GLX_DOUBLEBUFFER:
+ return 1;
+ case GLX_STEREO:
+ return 0;
+ case GLX_AUX_BUFFERS:
+ return 0;
+ case GLX_RED_SIZE:
+ return rgba[0];
+ case GLX_GREEN_SIZE:
+ return rgba[1];
+ case GLX_BLUE_SIZE:
+ return rgba[2];
+ case GLX_ALPHA_SIZE:
+ return rgba[3];
+ case GLX_DEPTH_SIZE:
+ return glo_flags_get_depth_bits(formatFlags);
+ case GLX_STENCIL_SIZE:
+ return glo_flags_get_stencil_bits(formatFlags);
+ case GLX_ACCUM_RED_SIZE:
+ case GLX_ACCUM_GREEN_SIZE:
+ case GLX_ACCUM_BLUE_SIZE:
+ case GLX_ACCUM_ALPHA_SIZE:
+ return 0;
//the attributes for glXGetFBConfigAttrib
- case GLX_FBCONFIG_ID: return 0;
- case GLX_RENDER_TYPE: return GLX_RGBA_BIT;
- case GLX_DRAWABLE_TYPE: return GLX_WINDOW_BIT;
- case GLX_X_RENDERABLE: return 1;
- case GLX_VISUAL_ID:
- case GLX_X_VISUAL_TYPE:
- // the real value is obtained in client side.
- return 0;
- case GLX_CONFIG_CAVEAT: return GLX_NONE;
- case GLX_TRANSPARENT_TYPE: return GLX_NONE;
- case GLX_TRANSPARENT_INDEX_VALUE:
- case GLX_TRANSPARENT_RED_VALUE:
- case GLX_TRANSPARENT_GREEN_VALUE:
- case GLX_TRANSPARENT_BLUE_VALUE:
- case GLX_TRANSPARENT_ALPHA_VALUE:
- return 0;
- case GLX_MAX_PBUFFER_WIDTH:
- case GLX_MAX_PBUFFER_HEIGHT:
- case GLX_MAX_PBUFFER_PIXELS:
- return 0;
- default:
- return 0;
+ case GLX_FBCONFIG_ID:
+ return 0;
+ case GLX_RENDER_TYPE:
+ return GLX_RGBA_BIT;
+ case GLX_DRAWABLE_TYPE:
+ return GLX_WINDOW_BIT;
+ case GLX_X_RENDERABLE:
+ return 1;
+ case GLX_VISUAL_ID:
+ case GLX_X_VISUAL_TYPE:
+ // the real value is obtained in client side.
+ return 0;
+ case GLX_CONFIG_CAVEAT:
+ return GLX_NONE;
+ case GLX_TRANSPARENT_TYPE:
+ return GLX_NONE;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ case GLX_TRANSPARENT_RED_VALUE:
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ return 0;
+ case GLX_MAX_PBUFFER_WIDTH:
+ case GLX_MAX_PBUFFER_HEIGHT:
+ case GLX_MAX_PBUFFER_PIXELS:
+ return 0;
+ default:
+ return 0;
}
return 0;
}
-
#endif
struct GloMain {
- Display *dpy;
- int use_ximage;
+ Display *dpy;
+ int use_ximage;
};
struct GloMain glo;
int glo_inited = 0;
struct _GloContext {
- GLuint formatFlags;
+ GLuint formatFlags;
- GLXFBConfig fbConfig;
- GLXContext context;
+ GLXFBConfig fbConfig;
+ GLXContext context;
};
struct _GloSurface {
- GLuint width;
- GLuint height;
+ GLuint width;
+ GLuint height;
- GloContext *context;
- Pixmap xPixmap;
- GLXPixmap glxPixmap;
+ GloContext *context;
+ Pixmap xPixmap;
+ GLXPixmap glxPixmap;
- // For use by the 'fast' copy code.
- XImage *image;
- XShmSegmentInfo shminfo;
+ // For use by the 'fast' copy code.
+ XImage *image;
+ XShmSegmentInfo shminfo;
};
extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
- int bpp, int width, int height, void *data, int noflip);
+ int bpp, int width, int height,
+ void *data, int noflip);
static void glo_test_readback_methods(void);
/* ------------------------------------------------------------------------ */
-int glo_initialised(void) {
- return glo_inited;
+int glo_initialised(void)
+{
+ return glo_inited;
}
/* Initialise gloffscreen */
-int glo_init(void) {
+int glo_init(void)
+{
if (glo_inited) {
- printf( "gloffscreen already inited\n" );
+ printf("gloffscreen already inited\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
/* Open a connection to the X server */
- glo.dpy = XOpenDisplay( NULL );
- if ( glo.dpy == NULL ) {
- printf( "Unable to open a connection to the X server\n" );
+ glo.dpy = XOpenDisplay(NULL);
+ if (glo.dpy == NULL) {
+ printf("Unable to open a connection to the X server\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
glo_inited = 1;
glo_test_readback_methods();
- return 0;
+ return 0;
}
/* Uninitialise gloffscreen */
-void glo_kill(void) {
+void glo_kill(void)
+{
XCloseDisplay(glo.dpy);
glo.dpy = NULL;
}
-
/* Like wglGetProcAddress/glxGetProcAddress */
-void *glo_getprocaddress(const char *procName) {
+void *glo_getprocaddress(const char *procName)
+{
if (!glo_inited)
- glo_init();
- return glXGetProcAddressARB((const GLubyte *) procName);
+ glo_init();
+ return glXGetProcAddressARB((const GLubyte *)procName);
}
/* ------------------------------------------------------------------------ */
/* Create a light-weight context just for creating surface */
-GloContext *__glo_context_create(int formatFlags) {
-
- GLXFBConfig *fbConfigs;
- int numReturned;
- GloContext *context;
- int rgbaBits[4];
- int bufferAttributes[] = {
- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 0,
- GLX_STENCIL_SIZE, 0,
- None
- };
-
- if (!glo_inited)
- glo_init();
-
- // set up the surface format from the flags we were given
- glo_flags_get_rgba_bits(formatFlags, rgbaBits);
- bufferAttributes[5] = rgbaBits[0];
- bufferAttributes[7] = rgbaBits[1];
- bufferAttributes[9] = rgbaBits[2];
- bufferAttributes[11] = rgbaBits[3];
- bufferAttributes[13] = glo_flags_get_depth_bits(formatFlags);
- bufferAttributes[15] = glo_flags_get_stencil_bits(formatFlags);
-
- //printf("Got R%d, G%d, B%d, A%d\n", rgbaBits[0], rgbaBits[1], rgbaBits[2], rgbaBits[3]);
-
- fbConfigs = glXChooseFBConfig( glo.dpy, DefaultScreen(glo.dpy),
- bufferAttributes, &numReturned );
- if (numReturned==0) {
- printf( "No matching configs found.\n" );
- //exit( EXIT_FAILURE );
- return NULL;
- }
- context = (GloContext*)qemu_malloc(sizeof(GloContext));
- memset(context, 0, sizeof(GloContext));
- context->formatFlags = formatFlags;
- context->fbConfig = fbConfigs[0];
-
- return context;
+GloContext *__glo_context_create(int formatFlags)
+{
+
+ GLXFBConfig *fbConfigs;
+ int numReturned;
+ GloContext *context;
+ int rgbaBits[4];
+ int bufferAttributes[] = {
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 0,
+ GLX_STENCIL_SIZE, 0,
+ None
+ };
+
+ if (!glo_inited)
+ glo_init();
+
+ // set up the surface format from the flags we were given
+ glo_flags_get_rgba_bits(formatFlags, rgbaBits);
+ bufferAttributes[5] = rgbaBits[0];
+ bufferAttributes[7] = rgbaBits[1];
+ bufferAttributes[9] = rgbaBits[2];
+ bufferAttributes[11] = rgbaBits[3];
+ bufferAttributes[13] = glo_flags_get_depth_bits(formatFlags);
+ bufferAttributes[15] = glo_flags_get_stencil_bits(formatFlags);
+
+ //printf("Got R%d, G%d, B%d, A%d\n", rgbaBits[0], rgbaBits[1], rgbaBits[2], rgbaBits[3]);
+
+ fbConfigs = glXChooseFBConfig(glo.dpy, DefaultScreen(glo.dpy),
+ bufferAttributes, &numReturned);
+ if (numReturned == 0) {
+ printf("No matching configs found.\n");
+ //exit( EXIT_FAILURE );
+ return NULL;
+ }
+ context = (GloContext *) qemu_malloc(sizeof(GloContext));
+ memset(context, 0, sizeof(GloContext));
+ context->formatFlags = formatFlags;
+ context->fbConfig = fbConfigs[0];
+
+ return context;
}
/* Create an OpenGL context for a certain pixel format. formatflags are from the GLO_ constants */
-GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
+GloContext *glo_context_create(int formatFlags, GloContext * shareLists)
+{
- GloContext *context = __glo_context_create(formatFlags);
+ GloContext *context = __glo_context_create(formatFlags);
- if (!context) {
- return NULL;
- }
+ if (!context) {
+ return NULL;
+ }
- /* Create a GLX context for OpenGL rendering */
- context->context = glXCreateNewContext(glo.dpy, context->fbConfig,
- GLX_RGBA_TYPE,
- shareLists ? shareLists->context: NULL,
- True );
+ /* Create a GLX context for OpenGL rendering */
+ context->context = glXCreateNewContext(glo.dpy, context->fbConfig,
+ GLX_RGBA_TYPE,
+ shareLists ? shareLists->
+ context : NULL, True);
- if (!context->context) {
- printf( "glXCreateNewContext failed\n" );
- //exit( EXIT_FAILURE );
- return NULL;
- }
+ if (!context->context) {
+ printf("glXCreateNewContext failed\n");
+ //exit( EXIT_FAILURE );
+ return NULL;
+ }
- return context;
+ return context;
}
/* Destroy a previouslu created OpenGL context */
-void glo_context_destroy(GloContext *context) {
- if (!context) return;
- // TODO: check for GloSurfaces using this?
- glXDestroyContext( glo.dpy, context->context);
- qemu_free(context);
+void glo_context_destroy(GloContext * context)
+{
+ if (!context)
+ return;
+ // TODO: check for GloSurfaces using this?
+ glXDestroyContext(glo.dpy, context->context);
+ qemu_free(context);
}
-static void glo_surface_free_xshm_image(GloSurface *surface) {
- XShmDetach(glo.dpy, &surface->shminfo);
- surface->image->data = NULL;
- XDestroyImage(surface->image);
- shmdt(surface->shminfo.shmaddr);
- shmctl(surface->shminfo.shmid, IPC_RMID, NULL);
+static void glo_surface_free_xshm_image(GloSurface * surface)
+{
+ XShmDetach(glo.dpy, &surface->shminfo);
+ surface->image->data = NULL;
+ XDestroyImage(surface->image);
+ shmdt(surface->shminfo.shmaddr);
+ shmctl(surface->shminfo.shmid, IPC_RMID, NULL);
}
-//FIXMEIM - handle failure to allocate.
-static void glo_surface_try_alloc_xshm_image(GloSurface *surface) {
- if(surface->image)
- glo_surface_free_xshm_image(surface);
+static int glo_surface_try_alloc_xshm_image(GloSurface * surface)
+{
+ if (surface->image)
+ glo_surface_free_xshm_image(surface);
surface->image =
- XShmCreateImage(glo.dpy, DefaultVisual(glo.dpy, 0), 24, ZPixmap, NULL,
- &surface->shminfo, surface->width, surface->height);
+ XShmCreateImage(glo.dpy, DefaultVisual(glo.dpy, 0), 24, ZPixmap, NULL,
+ &surface->shminfo, surface->width, surface->height);
+ if (!surface->image)
+ return -1;
+
surface->shminfo.shmid = shmget(IPC_PRIVATE,
surface->image->bytes_per_line *
- surface->height,
- IPC_CREAT | 0777);
+ surface->height, IPC_CREAT | 0777);
+ if (surface->shminfo.shmid < 0)
+ return -1;
+
surface->shminfo.shmaddr = shmat(surface->shminfo.shmid, NULL, 0);
+ if (surface->shminfo.shmaddr == (void *)-1)
+ return -1;
+
surface->image->data = surface->shminfo.shmaddr;
surface->shminfo.readOnly = False;
XShmAttach(glo.dpy, &surface->shminfo);
+
+ return 0;
}
/* ------------------------------------------------------------------------ */
/* Update the context in surface and handle previous context */
-int glo_surface_update_context(GloSurface *surface, GloContext *context)
- {
+int glo_surface_update_context(GloSurface * surface, GloContext * context)
+{
/* If previous context is light-weight context, just free it. If previous
* context is valid one binded with surface via MakeCurrent, we need unbind
* from original glstate */
int prev_context_valid = 0;
- if ( surface->context )
- {
+ if (surface->context) {
prev_context_valid = (surface->context->context != 0);
- if ( !prev_context_valid ) /* light-weight context */
+ if (!prev_context_valid) /* light-weight context */
g_free(surface->context);
}
surface->context = context;
return prev_context_valid;
}
-
/* Create a surface with given width and height, formatflags are from the
* GLO_ constants */
-GloSurface *glo_surface_create(int width, int height, GloContext *context) {
- GloSurface *surface;
+GloSurface *glo_surface_create(int width, int height, GloContext * context)
+{
+ GloSurface *surface;
- if (!context) return 0;
+ if (!context)
+ return 0;
- surface = (GloSurface*)qemu_malloc(sizeof(GloSurface));
+ surface = (GloSurface *) qemu_malloc(sizeof(GloSurface));
memset(surface, 0, sizeof(GloSurface));
surface->width = width;
surface->height = height;
surface->context = context;
- surface->xPixmap = XCreatePixmap( glo.dpy, DefaultRootWindow(glo.dpy),
- width, height,
- glo_flags_get_bytes_per_pixel(context->formatFlags)*8);
+ surface->xPixmap = XCreatePixmap(glo.dpy, DefaultRootWindow(glo.dpy),
+ width, height,
+ glo_flags_get_bytes_per_pixel(context->
+ formatFlags)
+ * 8);
if (!surface->xPixmap) {
- printf( "XCreatePixmap failed\n" );
- //exit( EXIT_FAILURE );
- return NULL;
+ printf("XCreatePixmap failed\n");
+ qemu_free(surface);
+ return NULL;
}
/* Create a GLX window to associate the frame buffer configuration
- ** with the created X window */
- surface->glxPixmap = glXCreatePixmap( glo.dpy, context->fbConfig, surface->xPixmap, NULL );
+ ** with the created X window */
+ surface->glxPixmap =
+ glXCreatePixmap(glo.dpy, context->fbConfig, surface->xPixmap, NULL);
if (!surface->glxPixmap) {
- printf( "glXCreatePixmap failed\n" );
- //exit( EXIT_FAILURE );
- return NULL;
+ printf("glXCreatePixmap failed\n");
+ XFreePixmap(glo.dpy, surface->xPixmap);
+ qemu_free(surface);
+ return NULL;
}
-
// If we're using XImages to pull the data from the graphics card...
- glo_surface_try_alloc_xshm_image(surface);
+ if (glo_surface_try_alloc_xshm_image(surface) < 0) {
+ printf("Failed to allocate shm image\n");
+ glXDestroyPixmap(glo.dpy, surface->glxPixmap);
+ XFreePixmap(glo.dpy, surface->xPixmap);
+ qemu_free(surface);
+ return NULL;
+ }
return surface;
}
/* Destroy the given surface */
-void glo_surface_destroy(GloSurface *surface) {
- glXDestroyPixmap( glo.dpy, surface->glxPixmap);
- XFreePixmap( glo.dpy, surface->xPixmap);
- if(surface->image)
- glo_surface_free_xshm_image(surface);
+void glo_surface_destroy(GloSurface * surface)
+{
+ glXDestroyPixmap(glo.dpy, surface->glxPixmap);
+ XFreePixmap(glo.dpy, surface->xPixmap);
+ if (surface->image)
+ glo_surface_free_xshm_image(surface);
qemu_free(surface);
}
/* Make the given surface current */
-int glo_surface_makecurrent(GloSurface *surface) {
+int glo_surface_makecurrent(GloSurface * surface)
+{
int ret;
if (!glo_inited)
- glo_init();
+ glo_init();
if (surface) {
- ret = glXMakeCurrent(glo.dpy, surface->glxPixmap, surface->context->context);
+ ret =
+ glXMakeCurrent(glo.dpy, surface->glxPixmap,
+ surface->context->context);
} else {
- ret = glXMakeCurrent(glo.dpy, 0, NULL);
+ ret = glXMakeCurrent(glo.dpy, 0, NULL);
}
return ret;
*/
/* Get the contents of the given surface */
-void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *data) {
+void glo_surface_getcontents(GloSurface * surface, int stride, int bpp,
+ void *data)
+{
static int once;
XImage *img;
if (!surface)
- return;
-
- if(glo.use_ximage) {
- glXWaitGL();
-
- if(surface->image) {
- XShmGetImage (glo.dpy, surface->xPixmap, surface->image, 0, 0, AllPlanes);
- img = surface->image;
- }
- else {
- img = XGetImage(glo.dpy, surface->xPixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
- }
-
- if (img) {
- if(bpp != 32 && bpp != 24 && !once) {
- fprintf(stderr, "Warning: unsupported colourdepth\n");
- once = 1;
+ return;
+
+ if (glo.use_ximage) {
+ glXWaitGL();
+
+ if (surface->image) {
+ XShmGetImage(glo.dpy, surface->xPixmap, surface->image, 0, 0,
+ AllPlanes);
+ img = surface->image;
+ } else {
+ img =
+ XGetImage(glo.dpy, surface->xPixmap, 0, 0, surface->width,
+ surface->height, AllPlanes, ZPixmap);
}
- if(bpp == img->bits_per_pixel && stride == img->bytes_per_line)
- {
- memcpy(data, img->data, stride * surface->height);
- }
- else
- {
- int x, y;
- for(y = 0 ; y < surface->height ; y++) {
- for(x = 0 ; x < surface->width ; x++) {
- char *src = ((char*)img->data) + (x*(img->bits_per_pixel/8)) + (y*img->bytes_per_line);
- char *dst = ((char*)data) + x*(bpp/8) + (y*stride);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- if(bpp == 32)
- dst[3] = 0xff; // if guest is 32 bit and host is 24
+ if (img) {
+ if (bpp != 32 && bpp != 24 && !once) {
+ fprintf(stderr, "Warning: unsupported colourdepth\n");
+ once = 1;
}
- }
+
+ if (bpp == img->bits_per_pixel && stride == img->bytes_per_line) {
+ memcpy(data, img->data, stride * surface->height);
+ } else {
+ int x, y;
+ for (y = 0; y < surface->height; y++) {
+ for (x = 0; x < surface->width; x++) {
+ char *src =
+ ((char *)img->data) +
+ (x * (img->bits_per_pixel / 8)) +
+ (y * img->bytes_per_line);
+ char *dst =
+ ((char *)data) + x * (bpp / 8) + (y * stride);
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ if (bpp == 32)
+ dst[3] = 0xff; // if guest is 32 bit and host is 24
+ }
+ }
+ }
+
+ // If we're not using Shm
+ if (!surface->image)
+ XDestroyImage(img);
+
+ return; // We're done.
}
-
- // If we're not using Shm
- if(!surface->image)
- XDestroyImage(img);
-
- return; // We're done.
- }
- // Uh oh... better fallback. Perhaps get glo.use_ximage to 0?
- }
-
- // Compatible / fallback method.
- glo_surface_getcontents_readpixels(surface->context->formatFlags,
- stride, bpp, surface->width,
- surface->height, data, 0);
+ // Uh oh... better fallback. Perhaps get glo.use_ximage to 0?
+ }
+ // Compatible / fallback method.
+ glo_surface_getcontents_readpixels(surface->context->formatFlags,
+ stride, bpp, surface->width,
+ surface->height, data, 0);
}
// while(0) {
// }
/* Return the width and height of the given surface */
-void glo_surface_get_size(GloSurface *surface, int *width, int *height) {
+void glo_surface_get_size(GloSurface * surface, int *width, int *height)
+{
if (width)
- *width = surface->width;
+ *width = surface->width;
if (height)
- *height = surface->height;
+ *height = surface->height;
}
/* Abstract glXQueryExtensionString() */
-const char *glo_glXQueryExtensionsString(void) {
- return glXQueryExtensionsString(glo.dpy, 0);
+const char *glo_glXQueryExtensionsString(void)
+{
+ return glXQueryExtensionsString(glo.dpy, 0);
}
-
#define TX (17)
#define TY (16)
-static int glo_can_readback(void) {
+static int glo_can_readback(void)
+{
GloContext *context;
GloSurface *surface;
- unsigned char *datain = (unsigned char *)qemu_malloc(4*TX*TY);
- unsigned char *datain_flip = (unsigned char *)qemu_malloc(4*TX*TY); // flipped input data (for GL)
- unsigned char *dataout = (unsigned char *)qemu_malloc(4*TX*TY);
+ unsigned char *datain = (unsigned char *)qemu_malloc(4 * TX * TY);
+ unsigned char *datain_flip = (unsigned char *)qemu_malloc(4 * TX * TY); // flipped input data (for GL)
+ unsigned char *dataout = (unsigned char *)qemu_malloc(4 * TX * TY);
unsigned char *p;
- int x,y;
+ int x, y;
const int bufferAttributes[] = {
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 0,
- GLX_STENCIL_SIZE, 0,
- 0,
- };
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 0,
+ GLX_STENCIL_SIZE, 0,
+ 0,
+ };
int bufferFlags = glo_flags_get_from_glx(bufferAttributes, 0);
int bpp = glo_flags_get_bytes_per_pixel(bufferFlags);
int glFormat, glType;
- memset(datain_flip, 0, TX*TY*4);
- memset(datain, 0, TX*TY*4);
+ memset(datain_flip, 0, TX * TY * 4);
+ memset(datain, 0, TX * TY * 4);
p = datain;
- for (y=0;y<TY;y++) {
- for (x=0;x<TX;x++) {
- p[0] = x;
- p[1] = y;
- //if (y&1) { p[0]=0; p[1]=0; }
- if (bpp>2) p[2] = 0;
- if (bpp>3) p[3] = 0xFF;
- p+=bpp;
- }
- memcpy(&datain_flip[((TY-1)-y)*bpp*TX], &datain[y*bpp*TX], bpp*TX);
+ for (y = 0; y < TY; y++) {
+ for (x = 0; x < TX; x++) {
+ p[0] = x;
+ p[1] = y;
+ //if (y&1) { p[0]=0; p[1]=0; }
+ if (bpp > 2)
+ p[2] = 0;
+ if (bpp > 3)
+ p[3] = 0xFF;
+ p += bpp;
+ }
+ memcpy(&datain_flip[((TY - 1) - y) * bpp * TX], &datain[y * bpp * TX],
+ bpp * TX);
}
context = glo_context_create(bufferFlags, 0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0,TX, 0,TY, 0, 1);
+ glOrtho(0, TX, 0, TY, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glRasterPos2f(0,0);
+ glRasterPos2f(0, 0);
glo_flags_get_readpixel_type(bufferFlags, &glFormat, &glType);
- glDrawPixels(TX,TY,glFormat, glType, datain_flip);
+ glDrawPixels(TX, TY, glFormat, glType, datain_flip);
glFlush();
- memset(dataout, 0, bpp*TX*TY);
+ memset(dataout, 0, bpp * TX * TY);
- glo_surface_getcontents(surface, TX*4, bpp*8, dataout);
+ glo_surface_getcontents(surface, TX * 4, bpp * 8, dataout);
glo_surface_destroy(surface);
glo_context_destroy(context);
- if (memcmp(datain, dataout, bpp*TX*TY)==0)
+ if (memcmp(datain, dataout, bpp * TX * TY) == 0)
return 1;
return 0;
}
-static void glo_test_readback_methods(void) {
+static void glo_test_readback_methods(void)
+{
glo.use_ximage = 1;
- if(!glo_can_readback())
- glo.use_ximage = 0;
+ if (!glo_can_readback())
+ glo.use_ximage = 0;
- fprintf(stderr, "VM GL: Using %s readback\n", glo.use_ximage?"XImage":"glReadPixels");
+ fprintf(stderr, "VM GL: Using %s readback\n",
+ glo.use_ximage ? "XImage" : "glReadPixels");
}
#endif
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
-#elif __APPLE__
+#elif defined __APPLE__
#include <OpenGL/gl.h>
#include <sys/time.h>
#else
#define CHECK_SUCCESS 0
#define CHECK_FAIL 1
-int gl_acceleration_capability_check (void) {
+int gl_acceleration_capability_check(void)
+{
//int test_failure = 0;
GloContext *context;
GloSurface *surface;
unsigned char *datain_flip;
unsigned char *dataout;
unsigned char *p;
- int x,y;
+ int x, y;
const int bufferAttributes[] = {
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 0,
- GLX_STENCIL_SIZE, 0,
- 0,
- };
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 0,
+ GLX_STENCIL_SIZE, 0,
+ 0,
+ };
#ifdef MANGLE_OPENGL_SYMBOLS
if (mgl_load_symbols("libGL.so.1")) {
- return CHECK_FAIL;
+ return CHECK_FAIL;
}
#endif
// test failed.
return 1;
}
-*/
- datain = (unsigned char *)malloc(4*TX*TY);
- datain_flip = (unsigned char *)malloc(4*TX*TY);
+*/
+ datain = (unsigned char *)malloc(4 * TX * TY);
+ datain_flip = (unsigned char *)malloc(4 * TX * TY);
- memset(datain, 0, TX*TY*4);
- memset(datain_flip, 0, TX*TY*4);
+ memset(datain, 0, TX * TY * 4);
+ memset(datain_flip, 0, TX * TY * 4);
p = datain;
- for (y=0;y<TY;y++) {
- for (x=0;x<TX;x++) {
- p[0] = x;
- p[1] = y;
- //if (y&1) { p[0]=0; p[1]=0; }
- if (bpp>2) p[2] = 0;
- if (bpp>3) p[3] = 0xFF;
- p+=bpp;
- }
- memcpy(&datain_flip[((TY-1)-y)*bpp*TX], &datain[y*bpp*TX], bpp*TX);
+ for (y = 0; y < TY; y++) {
+ for (x = 0; x < TX; x++) {
+ p[0] = x;
+ p[1] = y;
+ //if (y&1) { p[0]=0; p[1]=0; }
+ if (bpp > 2)
+ p[2] = 0;
+ if (bpp > 3)
+ p[3] = 0xFF;
+ p += bpp;
+ }
+ memcpy(&datain_flip[((TY - 1) - y) * bpp * TX], &datain[y * bpp * TX],
+ bpp * TX);
}
if (glo_init() != 0) {
- printf ("Host does not have GL hardware acceleration!(glo_init() failed)\n");
- free (datain);
- free (datain_flip);
- return CHECK_FAIL;
+ printf
+ ("Host does not have GL hardware acceleration!(glo_init() failed)\n");
+ free(datain);
+ free(datain_flip);
+ return CHECK_FAIL;
}
-
// new surface
context = glo_context_create(bufferFlags, 0);
- if (context == NULL) {
- printf ("Host does not have GL hardware acceleration!(context_create() failed)\n");
- free (datain);
- free (datain_flip);
- return CHECK_FAIL;
+ if (context == NULL) {
+ printf
+ ("Host does not have GL hardware acceleration!(context_create() failed)\n");
+ free(datain);
+ free(datain_flip);
+ return CHECK_FAIL;
}
surface = glo_surface_create(TX, TY, context);
- if (surface == NULL) {
- printf ("Host does not have GL hardware acceleration!(surface_create() failed)\n");
- free (datain);
- free (datain_flip);
- return CHECK_FAIL;
+ if (surface == NULL) {
+ printf
+ ("Host does not have GL hardware acceleration!(surface_create() failed)\n");
+ free(datain);
+ free(datain_flip);
+ return CHECK_FAIL;
}
glo_surface_makecurrent(surface);
printf("GL VERSION %s\n", glGetString(GL_VERSION));
//printf("GLSL VERSION %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
- if (strstr((const char*)glGetString(GL_RENDERER), "Software")) {
- printf ("Host does not have GL hardware acceleration!(No host gl driver)\n");
- free (datain);
- free (datain_flip);
- return CHECK_FAIL;
+ if (strstr((const char *)glGetString(GL_RENDERER), "Software")) {
+ printf
+ ("Host does not have GL hardware acceleration!(No host gl driver)\n");
+ free(datain);
+ free(datain_flip);
+ return CHECK_FAIL;
}
-
// fill with stuff (in correctly ordered way)
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0,TX, 0,TY, 0, 1);
+ glOrtho(0, TX, 0, TY, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glRasterPos2f(0,0);
+ glRasterPos2f(0, 0);
glo_flags_get_readpixel_type(bufferFlags, &glFormat, &glType);
printf("glFormat: 0x%08X glType: 0x%08X\n", glFormat, glType);
- glDrawPixels(TX,TY,glFormat, glType, datain_flip);
+ glDrawPixels(TX, TY, glFormat, glType, datain_flip);
glFlush();
-
- dataout = (unsigned char *)malloc(4*TX*TY);
- memset(dataout, 0, bpp*TX*TY);
- glo_surface_getcontents(surface, TX*bpp, bpp*8, dataout);
+ dataout = (unsigned char *)malloc(4 * TX * TY);
+ memset(dataout, 0, bpp * TX * TY);
+
+ glo_surface_getcontents(surface, TX * bpp, bpp * 8, dataout);
// destroy surface
glo_surface_destroy(surface);
glo_context_destroy(context);
// compare
- if (memcmp(datain, dataout, bpp*TX*TY)!=0) {
- printf ("Host does not have GL hardware acceleration!(datain != dataout)\n");
- free (datain);
- free (datain_flip);
- free (dataout);
- return CHECK_FAIL;
+ if (memcmp(datain, dataout, bpp * TX * TY) != 0) {
+ printf
+ ("Host does not have GL hardware acceleration!(datain != dataout)\n");
+ free(datain);
+ free(datain_flip);
+ free(dataout);
+ return CHECK_FAIL;
}
-
//glo_kill();
//printf ("Testing %s\n", (test_failure ? "FAILED" : "PASSED"));
- free (datain);
- free (datain_flip);
- free (dataout);
+ free(datain);
+ free(datain_flip);
+ free(dataout);
- return CHECK_SUCCESS;
+ return CHECK_SUCCESS;
}
int gl_acceleration_capability_check(void);
-#endif /* __GLOFFSCREEN_TEST_H__ */
+#endif /* __GLOFFSCREEN_TEST_H__ */
#include <windows.h>
#include <wingdi.h>
+#include <glib.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include "GL/wglext.h"
-#define MAX_ATTRIBS 12 /*Max attributes of pixel format we need*/
+#define MAX_ATTRIBS 12 /*Max attributes of pixel format we need */
#ifdef MANGLE_OPENGL_SYMBOLS
#include "gl_mangled.h"
*/
struct GloMain {
- HINSTANCE hInstance;
- HDC hDC;
- HWND hWnd; /* Our hidden window */
- HGLRC hContext;
+ HINSTANCE hInstance;
+ HDC hDC;
+ HWND hWnd; /* Our hidden window */
+ HGLRC hContext;
};
struct GloMain glo;
int glo_inited = 0;
int Render_texture_support = 0;
struct _GloContext {
- int formatFlags;
+ int formatFlags;
/* Pixel format returned by wglChoosePixelFormat */
- int wglPixelFormat;
+ int wglPixelFormat;
/* We need a pbuffer to make a context of the right pixelformat :( */
- HPBUFFERARB hPBuffer;
- HDC hDC;
- HGLRC hContext;
+ HPBUFFERARB hPBuffer;
+ HDC hDC;
+ HGLRC hContext;
};
struct _GloSurface {
- GLuint width;
- GLuint height;
+ GLuint width;
+ GLuint height;
- GloContext *context;
- HPBUFFERARB hPBuffer;
- HDC hDC;
+ GloContext *context;
+ HPBUFFERARB hPBuffer;
+ HDC hDC;
};
#define GLO_WINDOW_CLASS "QEmuGLClass"
/* ------------------------------------------------------------------------ */
-extern const char *glo_glXQueryExtensionsString(void);
-
extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
- int bpp, int width, int height, void *data, int noflip);
+ int bpp, int width, int height,
+ void *data, int noflip);
/* ------------------------------------------------------------------------ */
-int glo_initialised(void) {
+int glo_initialised(void)
+{
return glo_inited;
}
+#if 0
/* Sanity test of the host GL capabilities to see whether the gl offscreen
* could be well supported
*/
-int glo_sanity_test (void) {
+int glo_sanity_test(void)
+{
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
- wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
- wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
- wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
- wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB");
- wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
- if (!wglChoosePixelFormatARB ||
- !wglGetPbufferDCARB ||
- !wglReleasePbufferDCARB ||
- !wglCreatePbufferARB ||
- !wglDestroyPbufferARB) {
- fprintf (stderr, "Unable to load the required WGL extensions\n");
+ wglChoosePixelFormatARB =
+ (PFNWGLCHOOSEPIXELFORMATARBPROC)
+ wglGetProcAddress("wglChoosePixelFormatARB");
+ wglGetPbufferDCARB =
+ (PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");
+ wglReleasePbufferDCARB =
+ (PFNWGLRELEASEPBUFFERDCARBPROC)
+ wglGetProcAddress("wglReleasePbufferDCARB");
+ wglCreatePbufferARB =
+ (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
+ wglDestroyPbufferARB =
+ (PFNWGLDESTROYPBUFFERARBPROC) wglGetProcAddress("wglDestroyPbufferARB");
+ if (!wglChoosePixelFormatARB || !wglGetPbufferDCARB
+ || !wglReleasePbufferDCARB || !wglCreatePbufferARB
+ || !wglDestroyPbufferARB) {
+ fprintf(stderr, "Unable to load the required WGL extensions\n");
return 1;
}
// check the shader support. It is for mcompositor to run.
if (!wglGetProcAddress("glShaderSource")) {
- fprintf (stderr, "Unable to find shader support\n");
+ fprintf(stderr, "Unable to find shader support\n");
return 1;
}
return 0;
}
+#endif
/* Initialise gloffscreen */
-int glo_init(void) {
+int glo_init(void)
+{
WNDCLASSEX wcx;
PIXELFORMATDESCRIPTOR pfd;
- char *ext_str;
+ const char *ext_str;
if (glo_inited) {
- printf( "gloffscreen already inited\n" );
+ printf("gloffscreen already inited\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
- glo.hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
+ glo.hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
wcx.cbSize = sizeof(wcx);
wcx.style = 0;
wcx.hIcon = NULL;
wcx.hCursor = NULL;
wcx.hbrBackground = NULL;
- wcx.lpszMenuName = NULL;
+ wcx.lpszMenuName = NULL;
wcx.lpszClassName = GLO_WINDOW_CLASS;
wcx.hIconSm = NULL;
RegisterClassEx(&wcx);
- glo.hWnd = CreateWindow(
- GLO_WINDOW_CLASS,
- "QEmuGL",
- 0,0,0,0,0,
- (HWND)NULL, (HMENU)NULL,
- glo.hInstance,
- (LPVOID) NULL);
+ glo.hWnd = CreateWindow(GLO_WINDOW_CLASS,
+ "QEmuGL",
+ 0, 0, 0, 0, 0,
+ (HWND) NULL, (HMENU) NULL,
+ glo.hInstance, (LPVOID) NULL);
if (!glo.hWnd) {
- printf( "Unable to create window\n" );
+ printf("Unable to create window\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
glo.hDC = GetDC(glo.hWnd);
pfd.cColorBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE;
unsigned int pixelFormat = ChoosePixelFormat(glo.hDC, &pfd);
- DescribePixelFormat(glo.hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ DescribePixelFormat(glo.hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR),
+ &pfd);
if (!SetPixelFormat(glo.hDC, pixelFormat, &pfd))
return 1;
glo.hContext = wglCreateContext(glo.hDC);
if (glo.hContext == NULL) {
- printf( "Unable to create GL context\n" );
+ printf("Unable to create GL context\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
wglMakeCurrent(glo.hDC, glo.hContext);
// Need to share lists AND copy state
// load in the extensions we need
- //const char *ext = wglGetExtensionsStringARB(hdc);
+ //const char *ext = wglGetExtensionsStringARB(hdc);
//"WGL_ARB_pixel_format" "WGL_ARB_pbuffer"
- wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
- wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
- wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
- wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB");
- wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
- wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB");
- wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
- wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
+ wglChoosePixelFormatARB =
+ (PFNWGLCHOOSEPIXELFORMATARBPROC)
+ wglGetProcAddress("wglChoosePixelFormatARB");
+ wglGetPbufferDCARB =
+ (PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");
+ wglReleasePbufferDCARB =
+ (PFNWGLRELEASEPBUFFERDCARBPROC)
+ wglGetProcAddress("wglReleasePbufferDCARB");
+ wglCreatePbufferARB =
+ (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
+ wglDestroyPbufferARB =
+ (PFNWGLDESTROYPBUFFERARBPROC) wglGetProcAddress("wglDestroyPbufferARB");
+ wglBindTexImageARB =
+ (PFNWGLBINDTEXIMAGEARBPROC) wglGetProcAddress("wglBindTexImageARB");
+ wglReleaseTexImageARB =
+ (PFNWGLRELEASETEXIMAGEARBPROC)
+ wglGetProcAddress("wglReleaseTexImageARB");
+ wglGetExtensionsStringARB =
+ (PFNWGLGETEXTENSIONSSTRINGARBPROC)
+ wglGetProcAddress("wglGetExtensionsStringARB");
if (!wglChoosePixelFormatARB ||
!wglGetPbufferDCARB ||
!wglReleasePbufferDCARB ||
!wglCreatePbufferARB ||
- !wglDestroyPbufferARB ||
- !wglGetExtensionsStringARB ) {
- printf( "Unable to load the required WGL extensions\n" );
+ !wglDestroyPbufferARB || !wglGetExtensionsStringARB) {
+ printf("Unable to load the required WGL extensions\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
+ }
+
+ if (wglGetExtensionsStringARB) {
+ ext_str = wglGetExtensionsStringARB(wglGetCurrentDC());
+ if (ext_str == NULL) {
+ fprintf(stderr, "Failed tp get extensions string!\n");
+ Render_texture_support = 0;
+ } else {
+ if (strstr(ext_str, "WGL_ARB_render_texture") != NULL) {
+ fprintf(stdout, "WGL_ARB_render_texture supported!\n");
+ Render_texture_support = 1;
+ } else {
+ fprintf(stderr, "WGL_ARB_render_texture not supported!\n");
+ Render_texture_support = 0;
+ }
+ }
}
- if(wglGetExtensionsStringARB)
- {
- ext_str = wglGetExtensionsStringARB(wglGetCurrentDC());
- if(ext_str == NULL)
- {
- fprintf(stderr, "Failed tp get extensions string!\n");
- Render_texture_support = 0;
- }
- else
- {
- if(strstr(ext_str, "WGL_ARB_render_texture") != NULL)
- {
- fprintf(stdout, "WGL_ARB_render_texture supported!\n");
- Render_texture_support = 1;
- }
- else
- {
- fprintf(stderr, "WGL_ARB_render_texture not supported!\n");
- Render_texture_support = 0;
- }
- }
- }
-
-
- if ( !wglBindTexImageARB ||
- !wglReleaseTexImageARB )
- fprintf (stderr, "Warning: no [Bind|Release]TexImageARB extensions.\n");
+ if (!wglBindTexImageARB || !wglReleaseTexImageARB)
+ fprintf(stderr, "Warning: no [Bind|Release]TexImageARB extensions.\n");
glo_inited = 1;
- return 0;
+ return 0;
}
/* Uninitialise gloffscreen */
-void glo_kill(void) {
+void glo_kill(void)
+{
if (glo.hContext) {
wglMakeCurrent(NULL, NULL);
wglDeleteContext(glo.hContext);
UnregisterClass(GLO_WINDOW_CLASS, glo.hInstance);
}
-const char *glo_glXQueryExtensionsString(void) {
+const char *glo_glXQueryExtensionsString(void)
+{
return "";
}
-
-static const char *STANDARD_GL_FUNCTIONS ={
+static const char *STANDARD_GL_FUNCTIONS = {
/* Miscellaneous */
-"glClearIndex\0"
-"glClearColor\0"
-"glClear\0"
-"glIndexMask\0"
-"glColorMask\0"
-"glAlphaFunc\0"
-"glBlendFunc\0"
-"glLogicOp\0"
-"glCullFace\0"
-"glFrontFace\0"
-"glPointSize\0"
-"glLineWidth\0"
-"glLineStipple\0"
-"glPolygonMode\0"
-"glPolygonOffset\0"
-"glPolygonStipple\0"
-"glGetPolygonStipple\0"
-"glEdgeFlag\0"
-"glEdgeFlagv\0"
-"glScissor\0"
-"glClipPlane\0"
-"glGetClipPlane\0"
-"glDrawBuffer\0"
-"glReadBuffer\0"
-"glEnable\0"
-"glDisable\0"
-"glIsEnabled\0"
-"glEnableClientState\0"
-"glDisableClientState\0"
-"glGetBooleanv\0"
-"glGetDoublev\0"
-"glGetFloatv\0"
-"glGetIntegerv\0"
-"glPushAttrib\0"
-"glPopAttrib\0"
-"glPushClientAttrib\0"
-"glPopClientAttrib\0"
-"glRenderMode\0"
-"glGetError\0"
-"glGetString\0"
-"glFinish\0"
-"glFlush\0"
-"glHint\0"
+ "glClearIndex\0"
+ "glClearColor\0"
+ "glClear\0"
+ "glIndexMask\0"
+ "glColorMask\0"
+ "glAlphaFunc\0"
+ "glBlendFunc\0"
+ "glLogicOp\0"
+ "glCullFace\0"
+ "glFrontFace\0"
+ "glPointSize\0"
+ "glLineWidth\0"
+ "glLineStipple\0"
+ "glPolygonMode\0"
+ "glPolygonOffset\0"
+ "glPolygonStipple\0"
+ "glGetPolygonStipple\0"
+ "glEdgeFlag\0"
+ "glEdgeFlagv\0"
+ "glScissor\0"
+ "glClipPlane\0"
+ "glGetClipPlane\0"
+ "glDrawBuffer\0"
+ "glReadBuffer\0"
+ "glEnable\0"
+ "glDisable\0"
+ "glIsEnabled\0"
+ "glEnableClientState\0"
+ "glDisableClientState\0"
+ "glGetBooleanv\0"
+ "glGetDoublev\0"
+ "glGetFloatv\0"
+ "glGetIntegerv\0"
+ "glPushAttrib\0"
+ "glPopAttrib\0"
+ "glPushClientAttrib\0"
+ "glPopClientAttrib\0"
+ "glRenderMode\0"
+ "glGetError\0" "glGetString\0" "glFinish\0" "glFlush\0" "glHint\0"
/* Depth Buffer */
-"glClearDepth\0"
-"glDepthFunc\0"
-"glDepthMask\0"
-"glDepthRange\0"
+ "glClearDepth\0" "glDepthFunc\0" "glDepthMask\0" "glDepthRange\0"
/* Accumulation Buffer */
-"glClearAccum\0"
-"glAccum\0"
+ "glClearAccum\0" "glAccum\0"
/* Transformation */
-"glMatrixMode\0"
-"glOrtho\0"
-"glFrustum\0"
-"glViewport\0"
-"glPushMatrix\0"
-"glPopMatrix\0"
-"glLoadIdentity\0"
-"glLoadMatrixd\0"
-"glLoadMatrixf\0"
-"glMultMatrixd\0"
-"glMultMatrixf\0"
-"glRotated\0"
-"glRotatef\0"
-"glScaled\0"
-"glScalef\0"
-"glTranslated\0"
-"glTranslatef\0"
+ "glMatrixMode\0"
+ "glOrtho\0"
+ "glFrustum\0"
+ "glViewport\0"
+ "glPushMatrix\0"
+ "glPopMatrix\0"
+ "glLoadIdentity\0"
+ "glLoadMatrixd\0"
+ "glLoadMatrixf\0"
+ "glMultMatrixd\0"
+ "glMultMatrixf\0"
+ "glRotated\0"
+ "glRotatef\0"
+ "glScaled\0" "glScalef\0" "glTranslated\0" "glTranslatef\0"
/* Display Lists */
-"glIsList\0"
-"glDeleteLists\0"
-"glGenLists\0"
-"glNewList\0"
-"glEndList\0"
-"glCallList\0"
-"glCallLists\0"
-"glListBase\0"
+ "glIsList\0"
+ "glDeleteLists\0"
+ "glGenLists\0"
+ "glNewList\0"
+ "glEndList\0" "glCallList\0" "glCallLists\0" "glListBase\0"
/* Drawing Functions */
-"glBegin\0"
-"glEnd\0"
-"glVertex2d\0"
-"glVertex2f\0"
-"glVertex2i\0"
-"glVertex2s\0"
-"glVertex3d\0"
-"glVertex3f\0"
-"glVertex3i\0"
-"glVertex3s\0"
-"glVertex4d\0"
-"glVertex4f\0"
-"glVertex4i\0"
-"glVertex4s\0"
-"glVertex2dv\0"
-"glVertex2fv\0"
-"glVertex2iv\0"
-"glVertex2sv\0"
-"glVertex3dv\0"
-"glVertex3fv\0"
-"glVertex3iv\0"
-"glVertex3sv\0"
-"glVertex4dv\0"
-"glVertex4fv\0"
-"glVertex4iv\0"
-"glVertex4sv\0"
-"glNormal3b\0"
-"glNormal3d\0"
-"glNormal3f\0"
-"glNormal3i\0"
-"glNormal3s\0"
-"glNormal3bv\0"
-"glNormal3dv\0"
-"glNormal3fv\0"
-"glNormal3iv\0"
-"glNormal3sv\0"
-"glIndexd\0"
-"glIndexf\0"
-"glIndexi\0"
-"glIndexs\0"
-"glIndexub\0"
-"glIndexdv\0"
-"glIndexfv\0"
-"glIndexiv\0"
-"glIndexsv\0"
-"glIndexubv\0"
-"glColor3b\0"
-"glColor3d\0"
-"glColor3f\0"
-"glColor3i\0"
-"glColor3s\0"
-"glColor3ub\0"
-"glColor3ui\0"
-"glColor3us\0"
-"glColor4b\0"
-"glColor4d\0"
-"glColor4f\0"
-"glColor4i\0"
-"glColor4s\0"
-"glColor4ub\0"
-"glColor4ui\0"
-"glColor4us\0"
-"glColor3bv\0"
-"glColor3dv\0"
-"glColor3fv\0"
-"glColor3iv\0"
-"glColor3sv\0"
-"glColor3ubv\0"
-"glColor3uiv\0"
-"glColor3usv\0"
-"glColor4bv\0"
-"glColor4dv\0"
-"glColor4fv\0"
-"glColor4iv\0"
-"glColor4sv\0"
-"glColor4ubv\0"
-"glColor4uiv\0"
-"glColor4usv\0"
-"glTexCoord1d\0"
-"glTexCoord1f\0"
-"glTexCoord1i\0"
-"glTexCoord1s\0"
-"glTexCoord2d\0"
-"glTexCoord2f\0"
-"glTexCoord2i\0"
-"glTexCoord2s\0"
-"glTexCoord3d\0"
-"glTexCoord3f\0"
-"glTexCoord3i\0"
-"glTexCoord3s\0"
-"glTexCoord4d\0"
-"glTexCoord4f\0"
-"glTexCoord4i\0"
-"glTexCoord4s\0"
-"glTexCoord1dv\0"
-"glTexCoord1fv\0"
-"glTexCoord1iv\0"
-"glTexCoord1sv\0"
-"glTexCoord2dv\0"
-"glTexCoord2fv\0"
-"glTexCoord2iv\0"
-"glTexCoord2sv\0"
-"glTexCoord3dv\0"
-"glTexCoord3fv\0"
-"glTexCoord3iv\0"
-"glTexCoord3sv\0"
-"glTexCoord4dv\0"
-"glTexCoord4fv\0"
-"glTexCoord4iv\0"
-"glTexCoord4sv\0"
-"glRasterPos2d\0"
-"glRasterPos2f\0"
-"glRasterPos2i\0"
-"glRasterPos2s\0"
-"glRasterPos3d\0"
-"glRasterPos3f\0"
-"glRasterPos3i\0"
-"glRasterPos3s\0"
-"glRasterPos4d\0"
-"glRasterPos4f\0"
-"glRasterPos4i\0"
-"glRasterPos4s\0"
-"glRasterPos2dv\0"
-"glRasterPos2fv\0"
-"glRasterPos2iv\0"
-"glRasterPos2sv\0"
-"glRasterPos3dv\0"
-"glRasterPos3fv\0"
-"glRasterPos3iv\0"
-"glRasterPos3sv\0"
-"glRasterPos4dv\0"
-"glRasterPos4fv\0"
-"glRasterPos4iv\0"
-"glRasterPos4sv\0"
-"glRectd\0"
-"glRectf\0"
-"glRecti\0"
-"glRects\0"
-"glRectdv\0"
-"glRectfv\0"
-"glRectiv\0"
-"glRectsv\0"
+ "glBegin\0"
+ "glEnd\0"
+ "glVertex2d\0"
+ "glVertex2f\0"
+ "glVertex2i\0"
+ "glVertex2s\0"
+ "glVertex3d\0"
+ "glVertex3f\0"
+ "glVertex3i\0"
+ "glVertex3s\0"
+ "glVertex4d\0"
+ "glVertex4f\0"
+ "glVertex4i\0"
+ "glVertex4s\0"
+ "glVertex2dv\0"
+ "glVertex2fv\0"
+ "glVertex2iv\0"
+ "glVertex2sv\0"
+ "glVertex3dv\0"
+ "glVertex3fv\0"
+ "glVertex3iv\0"
+ "glVertex3sv\0"
+ "glVertex4dv\0"
+ "glVertex4fv\0"
+ "glVertex4iv\0"
+ "glVertex4sv\0"
+ "glNormal3b\0"
+ "glNormal3d\0"
+ "glNormal3f\0"
+ "glNormal3i\0"
+ "glNormal3s\0"
+ "glNormal3bv\0"
+ "glNormal3dv\0"
+ "glNormal3fv\0"
+ "glNormal3iv\0"
+ "glNormal3sv\0"
+ "glIndexd\0"
+ "glIndexf\0"
+ "glIndexi\0"
+ "glIndexs\0"
+ "glIndexub\0"
+ "glIndexdv\0"
+ "glIndexfv\0"
+ "glIndexiv\0"
+ "glIndexsv\0"
+ "glIndexubv\0"
+ "glColor3b\0"
+ "glColor3d\0"
+ "glColor3f\0"
+ "glColor3i\0"
+ "glColor3s\0"
+ "glColor3ub\0"
+ "glColor3ui\0"
+ "glColor3us\0"
+ "glColor4b\0"
+ "glColor4d\0"
+ "glColor4f\0"
+ "glColor4i\0"
+ "glColor4s\0"
+ "glColor4ub\0"
+ "glColor4ui\0"
+ "glColor4us\0"
+ "glColor3bv\0"
+ "glColor3dv\0"
+ "glColor3fv\0"
+ "glColor3iv\0"
+ "glColor3sv\0"
+ "glColor3ubv\0"
+ "glColor3uiv\0"
+ "glColor3usv\0"
+ "glColor4bv\0"
+ "glColor4dv\0"
+ "glColor4fv\0"
+ "glColor4iv\0"
+ "glColor4sv\0"
+ "glColor4ubv\0"
+ "glColor4uiv\0"
+ "glColor4usv\0"
+ "glTexCoord1d\0"
+ "glTexCoord1f\0"
+ "glTexCoord1i\0"
+ "glTexCoord1s\0"
+ "glTexCoord2d\0"
+ "glTexCoord2f\0"
+ "glTexCoord2i\0"
+ "glTexCoord2s\0"
+ "glTexCoord3d\0"
+ "glTexCoord3f\0"
+ "glTexCoord3i\0"
+ "glTexCoord3s\0"
+ "glTexCoord4d\0"
+ "glTexCoord4f\0"
+ "glTexCoord4i\0"
+ "glTexCoord4s\0"
+ "glTexCoord1dv\0"
+ "glTexCoord1fv\0"
+ "glTexCoord1iv\0"
+ "glTexCoord1sv\0"
+ "glTexCoord2dv\0"
+ "glTexCoord2fv\0"
+ "glTexCoord2iv\0"
+ "glTexCoord2sv\0"
+ "glTexCoord3dv\0"
+ "glTexCoord3fv\0"
+ "glTexCoord3iv\0"
+ "glTexCoord3sv\0"
+ "glTexCoord4dv\0"
+ "glTexCoord4fv\0"
+ "glTexCoord4iv\0"
+ "glTexCoord4sv\0"
+ "glRasterPos2d\0"
+ "glRasterPos2f\0"
+ "glRasterPos2i\0"
+ "glRasterPos2s\0"
+ "glRasterPos3d\0"
+ "glRasterPos3f\0"
+ "glRasterPos3i\0"
+ "glRasterPos3s\0"
+ "glRasterPos4d\0"
+ "glRasterPos4f\0"
+ "glRasterPos4i\0"
+ "glRasterPos4s\0"
+ "glRasterPos2dv\0"
+ "glRasterPos2fv\0"
+ "glRasterPos2iv\0"
+ "glRasterPos2sv\0"
+ "glRasterPos3dv\0"
+ "glRasterPos3fv\0"
+ "glRasterPos3iv\0"
+ "glRasterPos3sv\0"
+ "glRasterPos4dv\0"
+ "glRasterPos4fv\0"
+ "glRasterPos4iv\0"
+ "glRasterPos4sv\0"
+ "glRectd\0"
+ "glRectf\0"
+ "glRecti\0"
+ "glRects\0" "glRectdv\0" "glRectfv\0" "glRectiv\0" "glRectsv\0"
/* Lighting */
-"glShadeModel\0"
-"glLightf\0"
-"glLighti\0"
-"glLightfv\0"
-"glLightiv\0"
-"glGetLightfv\0"
-"glGetLightiv\0"
-"glLightModelf\0"
-"glLightModeli\0"
-"glLightModelfv\0"
-"glLightModeliv\0"
-"glMaterialf\0"
-"glMateriali\0"
-"glMaterialfv\0"
-"glMaterialiv\0"
-"glGetMaterialfv\0"
-"glGetMaterialiv\0"
-"glColorMaterial\0"
+ "glShadeModel\0"
+ "glLightf\0"
+ "glLighti\0"
+ "glLightfv\0"
+ "glLightiv\0"
+ "glGetLightfv\0"
+ "glGetLightiv\0"
+ "glLightModelf\0"
+ "glLightModeli\0"
+ "glLightModelfv\0"
+ "glLightModeliv\0"
+ "glMaterialf\0"
+ "glMateriali\0"
+ "glMaterialfv\0"
+ "glMaterialiv\0"
+ "glGetMaterialfv\0" "glGetMaterialiv\0" "glColorMaterial\0"
/* Raster functions */
-"glPixelZoom\0"
-"glPixelStoref\0"
-"glPixelStorei\0"
-"glPixelTransferf\0"
-"glPixelTransferi\0"
-"glPixelMapfv\0"
-"glPixelMapuiv\0"
-"glPixelMapusv\0"
-"glGetPixelMapfv\0"
-"glGetPixelMapuiv\0"
-"glGetPixelMapusv\0"
-"glBitmap\0"
-"glReadPixels\0"
-"glDrawPixels\0"
-"glCopyPixels\0"
+ "glPixelZoom\0"
+ "glPixelStoref\0"
+ "glPixelStorei\0"
+ "glPixelTransferf\0"
+ "glPixelTransferi\0"
+ "glPixelMapfv\0"
+ "glPixelMapuiv\0"
+ "glPixelMapusv\0"
+ "glGetPixelMapfv\0"
+ "glGetPixelMapuiv\0"
+ "glGetPixelMapusv\0"
+ "glBitmap\0" "glReadPixels\0" "glDrawPixels\0" "glCopyPixels\0"
/* Stenciling */
-"glStencilFunc\0"
-"glStencilMask\0"
-"glStencilOp\0"
-"glClearStencil\0"
+ "glStencilFunc\0" "glStencilMask\0" "glStencilOp\0" "glClearStencil\0"
/* Texture mapping */
-"glTexGend\0"
-"glTexGenf\0"
-"glTexGeni\0"
-"glTexGendv\0"
-"glTexGenfv\0"
-"glTexGeniv\0"
-"glGetTexGendv\0"
-"glGetTexGenfv\0"
-"glGetTexGeniv\0"
-"glTexEnvf\0"
-"glTexEnvi\0"
-"glTexEnvfv\0"
-"glTexEnviv\0"
-"glGetTexEnvfv\0"
-"glGetTexEnviv\0"
-"glTexParameterf\0"
-"glTexParameteri\0"
-"glTexParameterfv\0"
-"glTexParameteriv\0"
-"glGetTexParameterfv\0"
-"glGetTexParameteriv\0"
-"glGetTexLevelParameterfv\0"
-"glGetTexLevelParameteriv\0"
-"glTexImage1D\0"
-"glTexImage2D\0"
-"glGetTexImage\0"
+ "glTexGend\0"
+ "glTexGenf\0"
+ "glTexGeni\0"
+ "glTexGendv\0"
+ "glTexGenfv\0"
+ "glTexGeniv\0"
+ "glGetTexGendv\0"
+ "glGetTexGenfv\0"
+ "glGetTexGeniv\0"
+ "glTexEnvf\0"
+ "glTexEnvi\0"
+ "glTexEnvfv\0"
+ "glTexEnviv\0"
+ "glGetTexEnvfv\0"
+ "glGetTexEnviv\0"
+ "glTexParameterf\0"
+ "glTexParameteri\0"
+ "glTexParameterfv\0"
+ "glTexParameteriv\0"
+ "glGetTexParameterfv\0"
+ "glGetTexParameteriv\0"
+ "glGetTexLevelParameterfv\0"
+ "glGetTexLevelParameteriv\0"
+ "glTexImage1D\0" "glTexImage2D\0" "glGetTexImage\0"
/* Evaluators */
-"glMap1d\0"
-"glMap1f\0"
-"glMap2d\0"
-"glMap2f\0"
-"glGetMapdv\0"
-"glGetMapfv\0"
-"glGetMapiv\0"
-"glEvalCoord1d\0"
-"glEvalCoord1f\0"
-"glEvalCoord1dv\0"
-"glEvalCoord1fv\0"
-"glEvalCoord2d\0"
-"glEvalCoord2f\0"
-"glEvalCoord2dv\0"
-"glEvalCoord2fv\0"
-"glMapGrid1d\0"
-"glMapGrid1f\0"
-"glMapGrid2d\0"
-"glMapGrid2f\0"
-"glEvalPoint1\0"
-"glEvalPoint2\0"
-"glEvalMesh1\0"
-"glEvalMesh2\0"
+ "glMap1d\0"
+ "glMap1f\0"
+ "glMap2d\0"
+ "glMap2f\0"
+ "glGetMapdv\0"
+ "glGetMapfv\0"
+ "glGetMapiv\0"
+ "glEvalCoord1d\0"
+ "glEvalCoord1f\0"
+ "glEvalCoord1dv\0"
+ "glEvalCoord1fv\0"
+ "glEvalCoord2d\0"
+ "glEvalCoord2f\0"
+ "glEvalCoord2dv\0"
+ "glEvalCoord2fv\0"
+ "glMapGrid1d\0"
+ "glMapGrid1f\0"
+ "glMapGrid2d\0"
+ "glMapGrid2f\0"
+ "glEvalPoint1\0" "glEvalPoint2\0" "glEvalMesh1\0" "glEvalMesh2\0"
/* Fog */
-"glFogf\0"
-"glFogi\0"
-"glFogfv\0"
-"glFogiv\0"
+ "glFogf\0" "glFogi\0" "glFogfv\0" "glFogiv\0"
/* Selection and Feedback */
-"glFeedbackBuffer\0"
-"glPassThrough\0"
-"glSelectBuffer\0"
-"glInitNames\0"
-"glLoadName\0"
-"glPushName\0"
-"glPopName\0"
+ "glFeedbackBuffer\0"
+ "glPassThrough\0"
+ "glSelectBuffer\0"
+ "glInitNames\0" "glLoadName\0" "glPushName\0" "glPopName\0"
/* 1.1 functions */
/* texture objects */
-"glGenTextures\0"
-"glDeleteTextures\0"
-"glBindTexture\0"
-"glPrioritizeTextures\0"
-"glAreTexturesResident\0"
-"glIsTexture\0"
+ "glGenTextures\0"
+ "glDeleteTextures\0"
+ "glBindTexture\0"
+ "glPrioritizeTextures\0" "glAreTexturesResident\0" "glIsTexture\0"
/* texture mapping */
-"glTexSubImage1D\0"
-"glTexSubImage2D\0"
-"glCopyTexImage1D\0"
-"glCopyTexImage2D\0"
-"glCopyTexSubImage1D\0"
-"glCopyTexSubImage2D\0"
+ "glTexSubImage1D\0"
+ "glTexSubImage2D\0"
+ "glCopyTexImage1D\0"
+ "glCopyTexImage2D\0" "glCopyTexSubImage1D\0" "glCopyTexSubImage2D\0"
/* vertex arrays */
-"glVertexPointer\0"
-"glNormalPointer\0"
-"glColorPointer\0"
-"glIndexPointer\0"
-"glTexCoordPointer\0"
-"glEdgeFlagPointer\0"
-"glGetPointerv\0"
-"glArrayElement\0"
-"glDrawArrays\0"
-"glDrawElements\0"
-"glInterleavedArrays\0"
+ "glVertexPointer\0"
+ "glNormalPointer\0"
+ "glColorPointer\0"
+ "glIndexPointer\0"
+ "glTexCoordPointer\0"
+ "glEdgeFlagPointer\0"
+ "glGetPointerv\0"
+ "glArrayElement\0"
+ "glDrawArrays\0" "glDrawElements\0" "glInterleavedArrays\0"
/* GLX */
-"glXChooseVisual\0"
-"glXQueryExtensionsString\0"
-"glXQueryServerString\0"
-"glXGetClientString\0"
-"glXCreateContext\0"
-"glXCreateNewContext\0"
-"glXCopyContext\0"
-"glXDestroyContext\0"
-"glXQueryVersion\0"
-"glXMakeCurrent\0"
-"glXSwapBuffers\0"
-"glXGetConfig\0"
-"glXQueryExtension\0"
-"glXChooseFBConfig\0"
-"glXGetFBConfigs\0"
-"glXGetFBConfigAttrib\0"
-"glXQueryContext\0"
-"glXQueryDrawable\0"
-"glXGetVisualFromFBConfig\0"
-"glXIsDirect\0"
-"glXCreatePixmap\0"
-"glXDestroyPixmap\0"
-"glXCreatePbuffer\0"
-"glXDestroyPbuffer\0"
-"\0"
+ "glXChooseVisual\0"
+ "glXQueryExtensionsString\0"
+ "glXQueryServerString\0"
+ "glXGetClientString\0"
+ "glXCreateContext\0"
+ "glXCreateNewContext\0"
+ "glXCopyContext\0"
+ "glXDestroyContext\0"
+ "glXQueryVersion\0"
+ "glXMakeCurrent\0"
+ "glXSwapBuffers\0"
+ "glXGetConfig\0"
+ "glXQueryExtension\0"
+ "glXChooseFBConfig\0"
+ "glXGetFBConfigs\0"
+ "glXGetFBConfigAttrib\0"
+ "glXQueryContext\0"
+ "glXQueryDrawable\0"
+ "glXGetVisualFromFBConfig\0"
+ "glXIsDirect\0"
+ "glXCreatePixmap\0"
+ "glXDestroyPixmap\0" "glXCreatePbuffer\0" "glXDestroyPbuffer\0" "\0"
};
/* Like wglGetProcAddress/glxGetProcAddress */
-void *glo_getprocaddress(const char *procName) {
+void *glo_getprocaddress(const char *procName)
+{
HGLRC oldCtx;
HDC oldDC;
if (!glo_inited)
oldCtx = wglGetCurrentContext();
oldDC = wglGetCurrentDC();
- if (oldDC!=glo.hDC || oldCtx!=glo.hContext)
+ if (oldDC != glo.hDC || oldCtx != glo.hContext)
wglMakeCurrent(glo.hDC, glo.hContext);
void *procAddr = wglGetProcAddress(procName);
- if (oldDC!=glo.hDC || oldCtx!=glo.hContext)
+ if (oldDC != glo.hDC || oldCtx != glo.hContext)
wglMakeCurrent(oldDC, oldCtx);
/* wgl doesn't know about the glx functions - but
- we never call these anyway (they're implemented in
- opengl_exec), so all we need to do is return a nunzero value...
-
- But we also have to check for 'standard' GL function names
- too as wgl doesn't return those either! */
- /* Caller in opengl_exec.c may query some base GL API, then call them
- * directly. On windows, wglGetProcAddress usually return NULL in such
- * case, then we return 1, which casue segfault when accessing (void*)1. We
- * should call base GL API directly instead of GET_EXT_PTR + ptr_func_*.
- * TODO: add LoadLibrary + GetProcAddress as call back.
- */
- if (procAddr==0) {
+ we never call these anyway (they're implemented in
+ opengl_exec), so all we need to do is return a nunzero value...
+
+ But we also have to check for 'standard' GL function names
+ too as wgl doesn't return those either! */
+ /* Caller in opengl_exec.c may query some base GL API, then call them
+ * directly. On windows, wglGetProcAddress usually return NULL in such
+ * case, then we return 1, which casue segfault when accessing (void*)1. We
+ * should call base GL API directly instead of GET_EXT_PTR + ptr_func_*.
+ * TODO: add LoadLibrary + GetProcAddress as call back.
+ */
+ if (procAddr == 0) {
const char *p = STANDARD_GL_FUNCTIONS;
while (*p) {
if (!strcmp(procName, p)) {
- procAddr = (void*)1;
+ procAddr = (void *)1;
break;
}
// skip to the next '0' and then just over it
- while (*p) p++;
+ while (*p)
+ p++;
p++;
}
}
/*printf("wglGetProcAddress '%s' -> %p\n", procName, procAddr);
- fflush(stdout);*/
+ fflush(stdout); */
return procAddr;
}
-void glo_surface_updatecontents(GloSurface *surface) {
- /* NOT IMPLEMENTED YET. */
- printf("glo_surface_updatecontents() is not implemented for windows. \n");
+
+void glo_surface_updatecontents(GloSurface * surface)
+{
+ /* NOT IMPLEMENTED YET. */
+ printf("glo_surface_updatecontents() is not implemented for windows. \n");
}
/* ------------------------------------------------------------------------ */
/* Create a light-weight context just for creating surface */
-GloContext *__glo_context_create(int formatFlags) {
+GloContext *__glo_context_create(int formatFlags)
+{
GloContext *context;
// pixel format attributes
- int pf_attri[2*MAX_ATTRIBS];
- float pf_attrf[] = {0, 0};
+ int pf_attri[2 * MAX_ATTRIBS];
+ float pf_attrf[] = { 0, 0 };
unsigned int numReturned = 0;
- int pb_attr[] = { 0 };
- int rgbaBits[4];
- int index = 0;
-
- /*Initlized array because it needs to be terminated by 0*/
- for(index = 0; index < 2*MAX_ATTRIBS; index ++)
- pf_attri[index] = 0;
-
- index = 0;
- pf_attri[2*index] = WGL_SUPPORT_OPENGL_ARB;
- pf_attri[2*index +1 ] = TRUE;
- index ++;
-
- pf_attri[2*index] = WGL_DRAW_TO_PBUFFER_ARB;
- pf_attri[2*index +1 ] = TRUE;
- index ++;
-
- pf_attri[2*index] = WGL_RED_BITS_ARB;
- pf_attri[2*index +1 ] = 8;
- index ++;
-
- pf_attri[2*index] = WGL_GREEN_BITS_ARB;
- pf_attri[2*index +1 ] = 8;
- index ++;
-
- pf_attri[2*index] = WGL_BLUE_BITS_ARB;
- pf_attri[2*index +1 ] = 8;
- index ++;
-
- pf_attri[2*index] = WGL_ALPHA_BITS_ARB;
- pf_attri[2*index +1 ] = 8;
- index ++;
-
- pf_attri[2*index] = WGL_DEPTH_BITS_ARB;
- pf_attri[2*index +1 ] = 0;
- index ++;
-
- pf_attri[2*index] = WGL_STENCIL_BITS_ARB;
- pf_attri[2*index +1 ] = 0;
- index ++;
-
- pf_attri[2*index] = WGL_DOUBLE_BUFFER_ARB;
- pf_attri[2*index +1 ] = FALSE;
- index ++;
-
- if(Render_texture_support)
- {
- fprintf(stdout, "Render to texture supported, add attributes in array!\n");
- pf_attri[2*index] = WGL_DRAW_TO_PBUFFER_ARB;
- pf_attri[2*index +1 ] = TRUE;
- index ++;
-
- pf_attri[2*index] = WGL_BIND_TO_TEXTURE_RGBA_ARB;
- pf_attri[2*index +1 ] = TRUE;
-
- } else {
- fprintf(stderr, "Render to Texture not supported, disable attributes in array!\n");
- }
-
-
+ int pb_attr[] = { 0 };
+ int rgbaBits[4];
+ int index = 0;
+
+ /*Initlized array because it needs to be terminated by 0 */
+ for (index = 0; index < 2 * MAX_ATTRIBS; index++)
+ pf_attri[index] = 0;
+
+ index = 0;
+ pf_attri[2 * index] = WGL_SUPPORT_OPENGL_ARB;
+ pf_attri[2 * index + 1] = TRUE;
+ index++;
+
+ pf_attri[2 * index] = WGL_DRAW_TO_PBUFFER_ARB;
+ pf_attri[2 * index + 1] = TRUE;
+ index++;
+
+ pf_attri[2 * index] = WGL_RED_BITS_ARB;
+ pf_attri[2 * index + 1] = 8;
+ index++;
+
+ pf_attri[2 * index] = WGL_GREEN_BITS_ARB;
+ pf_attri[2 * index + 1] = 8;
+ index++;
+
+ pf_attri[2 * index] = WGL_BLUE_BITS_ARB;
+ pf_attri[2 * index + 1] = 8;
+ index++;
+
+ pf_attri[2 * index] = WGL_ALPHA_BITS_ARB;
+ pf_attri[2 * index + 1] = 8;
+ index++;
+
+ pf_attri[2 * index] = WGL_DEPTH_BITS_ARB;
+ pf_attri[2 * index + 1] = 0;
+ index++;
+
+ pf_attri[2 * index] = WGL_STENCIL_BITS_ARB;
+ pf_attri[2 * index + 1] = 0;
+ index++;
+
+ pf_attri[2 * index] = WGL_DOUBLE_BUFFER_ARB;
+ pf_attri[2 * index + 1] = FALSE;
+ index++;
+
+ if (Render_texture_support) {
+ fprintf(stdout,
+ "Render to texture supported, add attributes in array!\n");
+ pf_attri[2 * index] = WGL_DRAW_TO_PBUFFER_ARB;
+ pf_attri[2 * index + 1] = TRUE;
+ index++;
+
+ pf_attri[2 * index] = WGL_BIND_TO_TEXTURE_RGBA_ARB;
+ pf_attri[2 * index + 1] = TRUE;
+
+ } else {
+ fprintf(stderr,
+ "Render to Texture not supported, disable attributes in array!\n");
+ }
if (!glo_inited)
glo_init();
- context = (GloContext*)malloc(sizeof(GloContext));
+ context = (GloContext *) malloc(sizeof(GloContext));
memset(context, 0, sizeof(GloContext));
context->formatFlags = formatFlags;
// set up the surface format from the flags we were given
glo_flags_get_rgba_bits(context->formatFlags, rgbaBits);
- pf_attri[5] = rgbaBits[0];
- pf_attri[7] = rgbaBits[1];
- pf_attri[9] = rgbaBits[2];
+ pf_attri[5] = rgbaBits[0];
+ pf_attri[7] = rgbaBits[1];
+ pf_attri[9] = rgbaBits[2];
pf_attri[11] = rgbaBits[3];
pf_attri[13] = glo_flags_get_depth_bits(context->formatFlags);
pf_attri[15] = glo_flags_get_stencil_bits(context->formatFlags);
// find out what pixel format to use
- wglChoosePixelFormatARB( glo.hDC, pf_attri, pf_attrf, 1, &context->wglPixelFormat, &numReturned);
- if( numReturned == 0 ) {
- printf( "No matching configs found.\n" );
+ wglChoosePixelFormatARB(glo.hDC, pf_attri, pf_attrf, 1,
+ &context->wglPixelFormat, &numReturned);
+ if (numReturned == 0) {
+ printf("No matching configs found.\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
-
// We create a tiny pbuffer - just so we can make a context of the right pixel format
- context->hPBuffer = wglCreatePbufferARB( glo.hDC, context->wglPixelFormat,
- 16, 16, pb_attr );
- if( !context->hPBuffer ) {
- printf( "Couldn't create the PBuffer\n" );
+ context->hPBuffer = wglCreatePbufferARB(glo.hDC, context->wglPixelFormat,
+ 16, 16, pb_attr);
+ if (!context->hPBuffer) {
+ printf("Couldn't create the PBuffer\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
- context->hDC = wglGetPbufferDCARB( context->hPBuffer );
- if( !context->hDC ) {
- printf( "Couldn't create the DC\n" );
+ context->hDC = wglGetPbufferDCARB(context->hPBuffer);
+ if (!context->hDC) {
+ printf("Couldn't create the DC\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
- return context;
+ return context;
}
/* Create an OpenGL context for a certain pixel format. formatflags are from the GLO_ constants */
-GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
+GloContext *glo_context_create(int formatFlags, GloContext * shareLists)
+{
GloContext *context = __glo_context_create(formatFlags);
- if (!context) {
- return NULL;
- }
+ if (!context) {
+ return NULL;
+ }
context->hContext = wglCreateContext(context->hDC);
if (context->hContext == NULL) {
- printf( "Unable to create GL context\n" );
+ printf("Unable to create GL context\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
if (shareLists) {
}
/* Destroy a previouslu created OpenGL context */
-void glo_context_destroy(GloContext *context) {
- if (!context) return;
+void glo_context_destroy(GloContext * context)
+{
+ if (!context)
+ return;
if (context->hContext) {
wglDeleteContext(context->hContext);
/* ------------------------------------------------------------------------ */
/* Update the context in surface and handle previous context */
-void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags)
+void glo_surface_update_context(GloSurface * surface, GloContext * context,
+ int free_flags)
{
/* If previous context is light-weight context, just free it. If previous
* context is valid one binded with surface via MakeCurrent, we need unbind
* from original glstate */
- if ( surface->context )
- {
- if ( free_flags ) /* light-weight context */
+ if (surface->context) {
+ if (free_flags) /* light-weight context */
g_free(surface->context);
}
surface->context = context;
/* Create a surface with given width and height, formatflags are from the
* GLO_ constants */
-GloSurface *glo_surface_create(int width, int height, GloContext *context) {
- GloSurface *surface;
- int pb_attr[] = {
+GloSurface *glo_surface_create(int width, int height, GloContext * context)
+{
+ GloSurface *surface;
+ int pb_attr[] = {
/* Need following 2 to support surface as texture */
- WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
- WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
+ WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
+ WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
0
};
-
+
// Create the p-buffer...
- surface = (GloSurface*)malloc(sizeof(GloSurface));
+ surface = (GloSurface *) malloc(sizeof(GloSurface));
memset(surface, 0, sizeof(GloSurface));
surface->width = width;
surface->height = height;
surface->context = context;
- surface->hPBuffer = wglCreatePbufferARB( glo.hDC, context->wglPixelFormat,
- surface->width, surface->height, pb_attr );
- if( !surface->hPBuffer ) {
- printf( "Couldn't create the PBuffer\n" );
+ surface->hPBuffer = wglCreatePbufferARB(glo.hDC, context->wglPixelFormat,
+ surface->width, surface->height,
+ pb_attr);
+ if (!surface->hPBuffer) {
+ printf("Couldn't create the PBuffer\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
- surface->hDC = wglGetPbufferDCARB( surface->hPBuffer );
- if( !surface->hDC ) {
- printf( "Couldn't create the DC\n" );
+ surface->hDC = wglGetPbufferDCARB(surface->hPBuffer);
+ if (!surface->hDC) {
+ printf("Couldn't create the DC\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
return surface;
}
/* Destroy the given surface */
-void glo_surface_destroy(GloSurface *surface) {
- if (!surface) return;
+void glo_surface_destroy(GloSurface * surface)
+{
+ if (!surface)
+ return;
- if( surface->hPBuffer != NULL ) {
- wglReleasePbufferDCARB( surface->hPBuffer, surface->hDC );
- wglDestroyPbufferARB( surface->hPBuffer );
+ if (surface->hPBuffer != NULL) {
+ wglReleasePbufferDCARB(surface->hPBuffer, surface->hDC);
+ wglDestroyPbufferARB(surface->hPBuffer);
}
- if( surface->hDC != NULL ) {
- ReleaseDC( glo.hWnd, surface->hDC );
+ if (surface->hDC != NULL) {
+ ReleaseDC(glo.hWnd, surface->hDC);
}
free(surface);
}
/* Make the given surface current */
-int glo_surface_makecurrent(GloSurface *surface) {
- if (surface) {
- return wglMakeCurrent( surface->hDC, surface->context->hContext );
- } else {
- return wglMakeCurrent( NULL, NULL );
- }
+int glo_surface_makecurrent(GloSurface * surface)
+{
+ if (surface) {
+ return wglMakeCurrent(surface->hDC, surface->context->hContext);
+ } else {
+ return wglMakeCurrent(NULL, NULL);
+ }
}
/* Get the contents of the given surface */
-void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *data) {
-
- if (!surface)
- return;
- // Compatible / fallback method.
- glo_surface_getcontents_readpixels(surface->context->formatFlags,
- stride, bpp, surface->width,
- surface->height, data, 0);
+void glo_surface_getcontents(GloSurface * surface, int stride, int bpp,
+ void *data)
+{
+
+ if (!surface)
+ return;
+ // Compatible / fallback method.
+ glo_surface_getcontents_readpixels(surface->context->formatFlags,
+ stride, bpp, surface->width,
+ surface->height, data, 0);
}
/* Return the width and height of the given surface */
-void glo_surface_get_size(GloSurface *surface, int *width, int *height) {
+void glo_surface_get_size(GloSurface * surface, int *width, int *height)
+{
if (width)
*width = surface->width;
if (height)
}
/* Bind the surface as texture */
-void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface, int surface_type)
+void glo_surface_as_texture(GloContext * ctxt, GloSurface * surface,
+ int surface_type)
{
int glFormat, glType;
int bpp = 4;
oldDC = wglGetCurrentDC();
glo_surface_makecurrent(surface);
glo_surface_updatecontents(surface);
- glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat, &glType);
+ glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat,
+ &glType);
// Make sure we do not flip pbuffer surfaces on Windows
glo_surface_getcontents_readpixels(surface->context->formatFlags,
- stride, bpp *8, surface->width,
- surface->height, data, (surface_type == SURFACE_PBUFFER));
+ stride, bpp * 8, surface->width,
+ surface->height, data,
+ (surface_type == SURFACE_PBUFFER));
/* Restore previous context for setting texture */
wglMakeCurrent(oldDC, oldCtx);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, data);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0,
+ glFormat, glType, data);
free(data);
}
-void glo_surface_release_texture(GloSurface *surface)
+void glo_surface_release_texture(GloSurface * surface)
{
- if(!Render_texture_support)
- return ;
+ if (!Render_texture_support)
+ return;
- if (!wglReleaseTexImageARB)
- {
- fprintf (stderr, "wglReleaseTexImageARB not supported! Can't emulate glEGLImageTargetTexture2DOES!\n");
+ if (!wglReleaseTexImageARB) {
+ fprintf(stderr,
+ "wglReleaseTexImageARB not supported! Can't emulate glEGLImageTargetTexture2DOES!\n");
return;
}
- if ( !wglReleaseTexImageARB(surface->hPBuffer, WGL_FRONT_LEFT_ARB) )
- {
+ if (!wglReleaseTexImageARB(surface->hPBuffer, WGL_FRONT_LEFT_ARB)) {
fprintf(stderr, "wglBindTexImageARBr error=%d.\n", glGetError());
}
#include "gl_mangled.h"
#endif
-enum{
+enum {
SURFACE_WINDOW,
SURFACE_PIXMAP,
SURFACE_PBUFFER,
int glo_inited = 0;
struct _GloContext {
- GLuint formatFlags;
+ GLuint formatFlags;
- GLXFBConfig fbConfig;
- GLXContext context;
+ GLXFBConfig fbConfig;
+ GLXContext context;
};
struct _GloSurface {
- GLuint width;
- GLuint height;
+ GLuint width;
+ GLuint height;
- GloContext *context;
- Window window;
+ GloContext *context;
+ Window window;
// For use by the 'fast' copy code.
- Pixmap pixmap;
- XImage *image;
- XShmSegmentInfo shminfo;
- GLXPixmap glxPixmap;
+ Pixmap pixmap;
+ XImage *image;
+ XShmSegmentInfo shminfo;
+ GLXPixmap glxPixmap;
};
extern void glo_surface_getcontents_readpixels(int formatFlags, int stride,
- int bpp, int width, int height, void *data, int noflip);
+ int bpp, int width, int height,
+ void *data, int noflip);
static void glo_test_readback_methods(void);
/* ------------------------------------------------------------------------ */
-int glo_initialised(void) {
+int glo_initialised(void)
+{
return glo_inited;
}
* so it is reasonable to redirect error handler here.
*
*/
-static int x_errhandler(Display *dpy, XErrorEvent *e)
+static int x_errhandler(Display * dpy, XErrorEvent * e)
{
//fprintf (stderr, "X Error Happened!\n");
return 0;
}
+#if 0
/* Sanity test of the host GL capabilities to see whether the gl offscreen
* could be well supported
*/
-int glo_sanity_test (void) {
+int glo_sanity_test(void)
+{
return 0;
}
+#endif
/* Initialise gloffscreen */
-int glo_init(void) {
+int glo_init(void)
+{
if (glo_inited) {
- printf( "gloffscreen already inited\n" );
+ printf("gloffscreen already inited\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
/* Open a connection to the X server */
- glo.dpy = XOpenDisplay( NULL );
- if ( glo.dpy == NULL ) {
- printf( "Unable to open a connection to the X server\n" );
+ glo.dpy = XOpenDisplay(NULL);
+ if (glo.dpy == NULL) {
+ printf("Unable to open a connection to the X server\n");
//exit( EXIT_FAILURE );
- return 1;
+ return 1;
}
- glo_inited = 1; // safe because we are single threaded. Otherwise we cause
- // recursion on the next call.
+ glo_inited = 1; // safe because we are single threaded. Otherwise we cause
+ // recursion on the next call.
// set the X error handler.
- XSetErrorHandler (x_errhandler);
+ XSetErrorHandler(x_errhandler);
glo_test_readback_methods();
- return 0;
+ return 0;
}
/* Uninitialise gloffscreen */
-void glo_kill(void) {
+void glo_kill(void)
+{
XCloseDisplay(glo.dpy);
glo.dpy = NULL;
}
-
/* Like wglGetProcAddress/glxGetProcAddress */
-void *glo_getprocaddress(const char *procName) {
+void *glo_getprocaddress(const char *procName)
+{
if (!glo_inited)
glo_init();
- return glXGetProcAddressARB((const GLubyte *) procName);
+ return glXGetProcAddressARB((const GLubyte *)procName);
}
/* ------------------------------------------------------------------------ */
/* Create a light-weight context just for creating surface */
-GloContext *__glo_context_create(int formatFlags) {
+GloContext *__glo_context_create(int formatFlags)
+{
- GLXFBConfig *fbConfigs;
- int numReturned;
- GloContext *context;
- int rgbaBits[4];
- int bufferAttributes[] = {
+ GLXFBConfig *fbConfigs;
+ int numReturned;
+ GloContext *context;
+ int rgbaBits[4];
+ int bufferAttributes[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 0,
- GLX_STENCIL_SIZE, 0,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 0,
+ GLX_STENCIL_SIZE, 0,
None
};
// set up the surface format from the flags we were given
glo_flags_get_rgba_bits(formatFlags, rgbaBits);
- bufferAttributes[5] = rgbaBits[0];
- bufferAttributes[7] = rgbaBits[1];
- bufferAttributes[9] = rgbaBits[2];
+ bufferAttributes[5] = rgbaBits[0];
+ bufferAttributes[7] = rgbaBits[1];
+ bufferAttributes[9] = rgbaBits[2];
bufferAttributes[11] = rgbaBits[3];
bufferAttributes[13] = glo_flags_get_depth_bits(formatFlags);
bufferAttributes[15] = glo_flags_get_stencil_bits(formatFlags);
- fbConfigs = glXChooseFBConfig( glo.dpy, DefaultScreen(glo.dpy),
- bufferAttributes, &numReturned );
- if (numReturned==0) {
- printf( "No matching configs found.\n" );
+ fbConfigs = glXChooseFBConfig(glo.dpy, DefaultScreen(glo.dpy),
+ bufferAttributes, &numReturned);
+ if (numReturned == 0) {
+ printf("No matching configs found.\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
- context = (GloContext*)g_malloc(sizeof(GloContext));
+ context = (GloContext *) g_malloc(sizeof(GloContext));
memset(context, 0, sizeof(GloContext));
context->formatFlags = formatFlags;
context->fbConfig = fbConfigs[0];
- return context;
+ return context;
}
/* Create an OpenGL context for a certain pixel format.
formatflags are from the GLO_ constants */
-GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
+GloContext *glo_context_create(int formatFlags, GloContext * shareLists)
+{
- GloContext *context = __glo_context_create(formatFlags);
+ GloContext *context = __glo_context_create(formatFlags);
- if (!context) {
- return NULL;
- }
+ if (!context) {
+ return NULL;
+ }
/* Create a GLX context for OpenGL rendering */
context->context = glXCreateNewContext(glo.dpy, context->fbConfig,
- GLX_RGBA_TYPE,
- shareLists ? shareLists->context: NULL,
- True );
+ GLX_RGBA_TYPE,
+ shareLists ? shareLists->
+ context : NULL, True);
if (!context->context) {
- printf( "glXCreateNewContext failed\n" );
+ printf("glXCreateNewContext failed\n");
//exit( EXIT_FAILURE );
- return NULL;
+ return NULL;
}
return context;
}
/* Destroy a previously created OpenGL context */
-void glo_context_destroy(GloContext *context) {
- if (!context) return;
+void glo_context_destroy(GloContext * context)
+{
+ if (!context)
+ return;
// TODO: check for GloSurfaces using this?
- glXDestroyContext( glo.dpy, context->context);
+ glXDestroyContext(glo.dpy, context->context);
g_free(context);
}
-static void glo_surface_free_xshm_image(GloSurface *surface) {
+static void glo_surface_free_xshm_image(GloSurface * surface)
+{
XShmDetach(glo.dpy, &surface->shminfo);
surface->image->data = NULL;
XDestroyImage(surface->image);
shmctl(surface->shminfo.shmid, IPC_RMID, NULL);
}
-//FIXMEIM - handle failure to allocate.
-static void glo_surface_try_alloc_xshm_image(GloSurface *surface) {
-
- if(surface->image)
+static int glo_surface_try_alloc_xshm_image(GloSurface * surface)
+{
+ if (surface->image)
glo_surface_free_xshm_image(surface);
surface->image =
XShmCreateImage(glo.dpy, DefaultVisual(glo.dpy, 0), 24, ZPixmap, NULL,
&surface->shminfo, surface->width, surface->height);
+ if (!surface->image)
+ return -1;
surface->shminfo.shmid = shmget(IPC_PRIVATE,
surface->image->bytes_per_line *
- surface->height,
- IPC_CREAT | 0777);
+ surface->height, IPC_CREAT | 0777);
+ if (surface->shminfo.shmid < 0)
+ return -1;
+
surface->shminfo.shmaddr = shmat(surface->shminfo.shmid, NULL, 0);
+ if (surface->shminfo.shmaddr == (void *)-1)
+ return -1;
+
surface->image->data = surface->shminfo.shmaddr;
surface->shminfo.readOnly = False;
XShmAttach(glo.dpy, &surface->shminfo);
+
+ return 0;
}
/* ------------------------------------------------------------------------ */
/* Update the context in surface and handle previous context */
-void glo_surface_update_context(GloSurface *surface, GloContext *context, int free_flags)
- {
+void glo_surface_update_context(GloSurface * surface, GloContext * context,
+ int free_flags)
+{
/* If previous context is light-weight context, just free it. If previous
* context is valid one binded with surface via MakeCurrent, we need unbind
* from original glstate */
- if ( surface->context )
- {
- if (free_flags) /* light-weight context */
+ if (surface->context) {
+ if (free_flags) /* light-weight context */
g_free(surface->context);
}
surface->context = context;
/* Create a surface with given width and height, formatflags are from the
* GLO_ constants */
-GloSurface *glo_surface_create(int width, int height, GloContext *context) {
- GloSurface *surface;
+GloSurface *glo_surface_create(int width, int height, GloContext * context)
+{
+ GloSurface *surface;
XSetWindowAttributes attr = { 0 };
unsigned long mask;
XVisualInfo *vis;
if (!context)
- return 0;
+ return NULL;
+
+ surface = (GloSurface *) g_malloc(sizeof(GloSurface));
+ if (!surface)
+ return NULL;
- surface = (GloSurface*)g_malloc(sizeof(GloSurface));
memset(surface, 0, sizeof(GloSurface));
surface->width = width;
surface->height = height;
surface->context = context;
- vis = glXGetVisualFromFBConfig(glo.dpy, ((struct _GloContext*)context)->fbConfig);
+ vis =
+ glXGetVisualFromFBConfig(glo.dpy,
+ ((struct _GloContext *)context)->fbConfig);
attr.background_pixel = 0xff000000;
attr.border_pixel = 0;
attr.override_redirect = True;
attr.cursor = None;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask |
- CWOverrideRedirect | CWSaveUnder;
+ CWOverrideRedirect | CWSaveUnder;
- surface->window = XCreateWindow(glo.dpy, DefaultRootWindow(glo.dpy), 0, 3000, width, height, 0, vis->depth, InputOutput, vis->visual, mask, &attr);
+ surface->window =
+ XCreateWindow(glo.dpy, DefaultRootWindow(glo.dpy), 0, 3000, width,
+ height, 0, vis->depth, InputOutput, vis->visual, mask,
+ &attr);
if (!surface->window) {
- printf( "XCreateWindow failed\n" );
- //exit( EXIT_FAILURE );
- return NULL;
+ printf("XCreateWindow failed\n");
+ glo_surface_destroy(surface);
+ return NULL;
}
XMapWindow(glo.dpy, surface->window);
- XCompositeRedirectWindow (glo.dpy, surface->window, CompositeRedirectAutomatic);
+ XCompositeRedirectWindow(glo.dpy, surface->window,
+ CompositeRedirectAutomatic);
- if(glo.use_ximage) {
+ if (glo.use_ximage) {
surface->pixmap = XCompositeNameWindowPixmap(glo.dpy, surface->window);
} else {
- surface->pixmap = XCreatePixmap( glo.dpy, DefaultRootWindow(glo.dpy),
- width, height,
- glo_flags_get_bytes_per_pixel(context->formatFlags)*8);
+ surface->pixmap = XCreatePixmap(glo.dpy, DefaultRootWindow(glo.dpy),
+ width, height,
+ glo_flags_get_bytes_per_pixel(context->
+ formatFlags)
+ * 8);
}
- if(surface->pixmap == 0) {
+ if (surface->pixmap == 0) {
fprintf(stderr, "Failed to allocate pixmap!\n");
- //exit(EXIT_FAILURE);
- return NULL;
+ glo_surface_destroy(surface);
+ return NULL;
}
/* Create a GLX pixmap to associate the frame buffer configuration with the
* created X window */
/*XXX: need attribute_list? */
- surface->glxPixmap = glXCreatePixmap( glo.dpy, context->fbConfig, surface->pixmap, NULL );
+ surface->glxPixmap =
+ glXCreatePixmap(glo.dpy, context->fbConfig, surface->pixmap, NULL);
if (!surface->glxPixmap) {
- printf( "glXCreatePixmap failed\n" );
- //exit( EXIT_FAILURE );
- return NULL;
+ printf("glXCreatePixmap failed\n");
+ glo_surface_destroy(surface);
+ return NULL;
}
XSync(glo.dpy, 0);
sizehints.flags = USSize | USPosition;
XSetWMNormalHints(glo.dpy, surface->window, &sizehints);
XSetStandardProperties(glo.dpy, surface->window, "", "", None,
- (char **) NULL, 0, &sizehints);
+ (char **)NULL, 0, &sizehints);
}
XSync(glo.dpy, 0);
// If we're using XImages to pull the data from the graphics card...
- glo_surface_try_alloc_xshm_image(surface);
+ if (glo_surface_try_alloc_xshm_image(surface) < 0) {
+ printf("Failed to allocate shm image\n");
+ glo_surface_destroy(surface);
+ return NULL;
+ }
return surface;
}
/* Destroy the given surface */
-void glo_surface_destroy(GloSurface *surface) {
+void glo_surface_destroy(GloSurface * surface)
+{
- if(surface->pixmap)
- XFreePixmap( glo.dpy, surface->pixmap);
+ if (surface->pixmap)
+ XFreePixmap(glo.dpy, surface->pixmap);
- if(surface->glxPixmap)
- glXDestroyPixmap( glo.dpy, surface->glxPixmap);
+ if (surface->glxPixmap)
+ glXDestroyPixmap(glo.dpy, surface->glxPixmap);
- XDestroyWindow( glo.dpy, surface->window);
- if(surface->image)
+ if (surface->window)
+ XDestroyWindow(glo.dpy, surface->window);
+
+ if (surface->image)
glo_surface_free_xshm_image(surface);
- g_free(surface);
+ g_free(surface);
}
/* Make the given surface current */
-int glo_surface_makecurrent(GloSurface *surface) {
+int glo_surface_makecurrent(GloSurface * surface)
+{
int ret;
if (!glo_inited)
return ret;
}
-void glo_surface_updatecontents(GloSurface *surface) {
+void glo_surface_updatecontents(GloSurface * surface)
+{
if (!surface)
return;
- if(glo.use_ximage) {
+ if (glo.use_ximage) {
glXWaitGL();
- if(surface->image) {
- XShmGetImage (glo.dpy, surface->pixmap, surface->image, 0, 0, AllPlanes);
- }
- else {
- XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
+ if (surface->image) {
+ XShmGetImage(glo.dpy, surface->pixmap, surface->image, 0, 0,
+ AllPlanes);
+ } else {
+ XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width,
+ surface->height, AllPlanes, ZPixmap);
}
}
}
/* Get the contents of the given surface */
-void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *data) {
+void glo_surface_getcontents(GloSurface * surface, int stride, int bpp,
+ void *data)
+{
static int once;
XImage *img;
if (!surface)
return;
- if(glo.use_ximage) {
+ if (glo.use_ximage) {
glXWaitGL();
-
- if(surface->image) {
- XShmGetImage (glo.dpy, surface->pixmap, surface->image, 0, 0, AllPlanes);
+
+ if (surface->image) {
+ XShmGetImage(glo.dpy, surface->pixmap, surface->image, 0, 0,
+ AllPlanes);
img = surface->image;
- }
- else {
- img = XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
+ } else {
+ img =
+ XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width,
+ surface->height, AllPlanes, ZPixmap);
}
if (img) {
- if(bpp != 32 && bpp != 24 && !once) {
+ if (bpp != 32 && bpp != 24 && !once) {
fprintf(stderr, "Warning: unsupported colourdepth\n");
once = 1;
}
- if(bpp == img->bits_per_pixel && stride == img->bytes_per_line)
- {
- memcpy(data, img->data, stride * surface->height);
- }
- else
- {
+ if (bpp == img->bits_per_pixel && stride == img->bytes_per_line) {
+ memcpy(data, img->data, stride * surface->height);
+ } else {
int x, y;
- for(y = 0 ; y < surface->height ; y++) {
- for(x = 0 ; x < surface->width ; x++) {
- char *src = ((char*)img->data) +
- (x*(img->bits_per_pixel/8)) +
- (y*img->bytes_per_line);
- char *dst = ((char*)data) + x*(bpp/8) + (y*stride);
+ for (y = 0; y < surface->height; y++) {
+ for (x = 0; x < surface->width; x++) {
+ char *src = ((char *)img->data) +
+ (x * (img->bits_per_pixel / 8)) +
+ (y * img->bytes_per_line);
+ char *dst =
+ ((char *)data) + x * (bpp / 8) + (y * stride);
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
- if(bpp == 32)
- dst[3] = 0xff; // if guest is 32 bit and host is 24
+ if (bpp == 32)
+ dst[3] = 0xff; // if guest is 32 bit and host is 24
}
}
}
-
+
// If we're not using Shm
- if(!surface->image)
+ if (!surface->image)
XDestroyImage(img);
- return; // We're done.
- }
- // Uh oh... better fallback. Perhaps get glo.use_ximage to 0?
+ return; // We're done.
+ }
+ // Uh oh... better fallback. Perhaps get glo.use_ximage to 0?
}
-
// Compatible / fallback method.
glo_surface_getcontents_readpixels(surface->context->formatFlags,
stride, bpp, surface->width,
}
/* Return the width and height of the given surface */
-void glo_surface_get_size(GloSurface *surface, int *width, int *height) {
+void glo_surface_get_size(GloSurface * surface, int *width, int *height)
+{
if (width)
*width = surface->width;
if (height)
}
/* Bind the surface as texture */
-void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface, int surface_type)
+void glo_surface_as_texture(GloContext * ctxt, GloSurface * surface,
+ int surface_type)
{
#if 0
- void (*ptr_func_glXBindTexImageEXT) (Display *dpy, GLXDrawable draw, int buffer, int *attrib_list);
+ void (*ptr_func_glXBindTexImageEXT) (Display * dpy, GLXDrawable draw,
+ int buffer, int *attrib_list);
ptr_func_glXBindTexImageEXT =
- (void(*)(Display*, GLXDrawable, int, int*))glo_getprocaddress((const char*)"glXBindTexImageEXT");
+ (void (*)(Display *, GLXDrawable, int, int *))
+ glo_getprocaddress((const char *)"glXBindTexImageEXT");
- /*XXX: When to call the glXReleaseTexImageEXT?*/
- if (!ptr_func_glXBindTexImageEXT)
- {
- fprintf (stderr, "glXBindTexImageEXT not supported! Can't emulate glEGLImageTargetTexture2DOES!\n");
+ /*XXX: When to call the glXReleaseTexImageEXT? */
+ if (!ptr_func_glXBindTexImageEXT) {
+ fprintf(stderr,
+ "glXBindTexImageEXT not supported! Can't emulate glEGLImageTargetTexture2DOES!\n");
}
fprintf(stderr, "surface_as_texture:error=%d.\n", glGetError());
- ptr_func_glXBindTexImageEXT(glo.dpy, surface->glxPixmap, GLX_FRONT_LEFT_EXT, NULL);
+ ptr_func_glXBindTexImageEXT(glo.dpy, surface->glxPixmap, GLX_FRONT_LEFT_EXT,
+ NULL);
fprintf(stderr, "surface_as_texture:2:error=%d.\n", glGetError());
#else
- int glFormat, glType;
+ int glFormat, glType;
glo_surface_updatecontents(surface);
- /*XXX: changet the fixed target: GL_TEXTURE_2D*/
- glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat, &glType);
+ /*XXX: changet the fixed target: GL_TEXTURE_2D */
+ glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat,
+ &glType);
/* fprintf(stderr, "surface_as_texture:teximage:width=%d,height=%d, glFormat=0x%x, glType=0x%x.\n", surface->width, surface->height, glFormat, glType);*/
/* glTexImage2D use different RGB order than the contexts in the pixmap surface */
/* glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->image->data);*/
- if(surface_type == SURFACE_PBUFFER)
- {
- if ((glFormat == GL_RGBA || glFormat == GL_BGRA) && glType == GL_UNSIGNED_BYTE) {
- GLubyte *b = (GLubyte *)surface->image->data;
- int stride = surface->width * 4;
- GLubyte *c = &((GLubyte *)surface->image->data)[stride*(surface->height-1)];
- GLubyte *tmp = (GLubyte*)g_malloc(stride);
- int irow;
-
- for(irow = 0; irow < surface->height / 2; irow++) {
- memcpy(tmp, b, stride);
- memcpy(b, c, stride);
- memcpy(c, tmp, stride);
- b += stride;
- c -= stride;
+ if (surface_type == SURFACE_PBUFFER) {
+ if ((glFormat == GL_RGBA || glFormat == GL_BGRA)
+ && glType == GL_UNSIGNED_BYTE) {
+ GLubyte *b = (GLubyte *) surface->image->data;
+ int stride = surface->width * 4;
+ GLubyte *c =
+ &((GLubyte *) surface->image->data)[stride *
+ (surface->height - 1)];
+ GLubyte *tmp = (GLubyte *) g_malloc(stride);
+ int irow;
+
+ for (irow = 0; irow < surface->height / 2; irow++) {
+ memcpy(tmp, b, stride);
+ memcpy(b, c, stride);
+ memcpy(c, tmp, stride);
+ b += stride;
+ c -= stride;
+ }
+ g_free(tmp);
}
- g_free(tmp);
}
- }
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, surface->image->data);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0,
+ glFormat, glType, surface->image->data);
#endif
}
-void glo_surface_release_texture(GloSurface *surface)
+void glo_surface_release_texture(GloSurface * surface)
{
}
/* Abstract glXQueryExtensionString() */
-const char *glo_glXQueryExtensionsString(void) {
+const char *glo_glXQueryExtensionsString(void)
+{
return glXQueryExtensionsString(glo.dpy, 0);
}
-
#define TX (17)
#define TY (16)
-static int glo_can_readback(void) {
+static int glo_can_readback(void)
+{
GloContext *context;
GloSurface *surface;
- unsigned char *datain = (unsigned char *)g_malloc(4*TX*TY);
- unsigned char *datain_flip = (unsigned char *)g_malloc(4*TX*TY); // flipped input data (for GL)
+ unsigned char *datain = (unsigned char *)g_malloc(4 * TX * TY);
+ unsigned char *datain_flip = (unsigned char *)g_malloc(4 * TX * TY); // flipped input data (for GL)
unsigned char *dataout;
unsigned char *p;
- int x,y;
+ int x, y;
const int bufferAttributes[] = {
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 0,
- GLX_STENCIL_SIZE, 0,
- 0,
- };
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 0,
+ GLX_STENCIL_SIZE, 0,
+ 0,
+ };
int bufferFlags = glo_flags_get_from_glx(bufferAttributes, 0);
int bpp = glo_flags_get_bytes_per_pixel(bufferFlags);
int glFormat, glType;
- memset(datain_flip, 0, TX*TY*4);
- memset(datain, 0, TX*TY*4);
+ memset(datain_flip, 0, TX * TY * 4);
+ memset(datain, 0, TX * TY * 4);
p = datain;
- for (y=0;y<TY;y++) {
- for (x=0;x<TX;x++) {
+ for (y = 0; y < TY; y++) {
+ for (x = 0; x < TX; x++) {
p[0] = x;
p[1] = y;
- if (bpp>2) p[2] = 0;
- if (bpp>3) p[3] = 0xFF;
- p+=bpp;
+ if (bpp > 2)
+ p[2] = 0;
+ if (bpp > 3)
+ p[3] = 0xFF;
+ p += bpp;
}
- memcpy(&datain_flip[((TY-1)-y)*bpp*TX], &datain[y*bpp*TX], bpp*TX);
+ memcpy(&datain_flip[((TY - 1) - y) * bpp * TX], &datain[y * bpp * TX],
+ bpp * TX);
}
context = glo_context_create(bufferFlags, 0);
- if (context == NULL) {
- g_free(datain);
- g_free(datain_flip);
- return 1;
- }
+ if (context == NULL) {
+ g_free(datain);
+ g_free(datain_flip);
+ return 1;
+ }
surface = glo_surface_create(TX, TY, context);
- if (surface == NULL) {
- g_free(datain);
- g_free(datain_flip);
- return 1;
- }
+ if (surface == NULL) {
+ g_free(datain);
+ g_free(datain_flip);
+ return 1;
+ }
glo_surface_makecurrent(surface);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0,TX, 0,TY, 0, 1);
+ glOrtho(0, TX, 0, TY, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glRasterPos2f(0,0);
+ glRasterPos2f(0, 0);
glo_flags_get_readpixel_type(bufferFlags, &glFormat, &glType);
- glDrawPixels(TX,TY,glFormat, glType, datain_flip);
+ glDrawPixels(TX, TY, glFormat, glType, datain_flip);
glFlush();
- dataout = (unsigned char *)g_malloc(4*TX*TY);
- memset(dataout, 0, bpp*TX*TY);
+ dataout = (unsigned char *)g_malloc(4 * TX * TY);
+ memset(dataout, 0, bpp * TX * TY);
- glo_surface_getcontents(surface, TX*4, bpp*8, dataout);
+ glo_surface_getcontents(surface, TX * 4, bpp * 8, dataout);
glo_surface_destroy(surface);
glo_context_destroy(context);
- if (memcmp(datain, dataout, bpp*TX*TY)==0) {
- g_free(datain);
- g_free(datain_flip);
- g_free(dataout);
+ if (memcmp(datain, dataout, bpp * TX * TY) == 0) {
+ g_free(datain);
+ g_free(datain_flip);
+ g_free(dataout);
return 1;
- }
+ }
- g_free(datain);
- g_free(datain_flip);
- g_free(dataout);
+ g_free(datain);
+ g_free(datain_flip);
+ g_free(dataout);
return 0;
}
-static void glo_test_readback_methods(void) {
+static void glo_test_readback_methods(void)
+{
glo.use_ximage = 1;
- if(!glo_can_readback())
+ if (!glo_can_readback())
glo.use_ximage = 0;
//fprintf(stderr, "VM GL: Using %s readback\n", glo.use_ximage?"XImage":"glReadPixels");
#include "opengl_func.h"
#include "opengl_process.h"
#include "opengl_exec.h"
+#include "helper_opengl.h"
#include "tizen/src/debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, opengl);
#ifdef _WIN32
#define DEBUGF(...) printf(__VA_ARGS__)
#else
-extern struct FILE *stderr; /* Standard error output stream. */
+extern struct FILE *stderr; /* Standard error output stream. */
#define DEBUGF(...) fprintf(stderr, __VA_ARGS__)
#endif
#endif
typedef unsigned long host_ptr;
-static inline int do_decode_call_int(ProcessStruct *process, void *args_in, int args_len, char *r_buffer)
+static inline int do_decode_call_int(ProcessStruct * process, void *args_in,
+ int args_len, char *r_buffer)
{
Signature *signature;
int i, ret;
- char *argptr, *tmp;
- static void* args[50];
+ char *argptr;
+ static host_ptr args[50];
int func_number;
#ifdef __APPLE__
char temp4mac[256];
#endif
- if(!args_len)
- return 0;
+ if (!args_len)
+ return 0;
argptr = args_in;
- while((char*)argptr < (char*)args_in + args_len) {
- func_number = *(short*)argptr;
+ while ((char *)argptr < (char *)args_in + args_len) {
+ func_number = *(short *)argptr;
argptr += 2;
- if(func_number >= GL_N_CALLS) {
+ if (func_number >= GL_N_CALLS) {
DEBUGF("Bad function number or corrupt command queue\n");
return 0;
}
signature = (Signature *) tab_opengl_calls[func_number];
- tmp = argptr;
-
for (i = 0; i < signature->nb_args; i++) {
- int args_size = *(int*)argptr;
- argptr+=4;
+ int args_size = *(int *)argptr;
+ argptr += 4;
switch (signature->args_type[i]) {
- case TYPE_UNSIGNED_INT:
- case TYPE_INT:
- case TYPE_UNSIGNED_CHAR:
- case TYPE_CHAR:
- case TYPE_UNSIGNED_SHORT:
- case TYPE_SHORT:
- case TYPE_FLOAT:
- args[i] = *(int*)argptr;
+ case TYPE_UNSIGNED_INT:
+ case TYPE_INT:
+ case TYPE_UNSIGNED_CHAR:
+ case TYPE_CHAR:
+ case TYPE_UNSIGNED_SHORT:
+ case TYPE_SHORT:
+ case TYPE_FLOAT:
+ args[i] = *(int *)argptr;
break;
- case TYPE_NULL_TERMINATED_STRING:
- CASE_IN_UNKNOWN_SIZE_POINTERS:
+ case TYPE_NULL_TERMINATED_STRING:
+ CASE_IN_UNKNOWN_SIZE_POINTERS:
{
- if(*(int*)argptr)
- args[i] = (host_ptr)argptr+4;
+ if (*(int *)argptr)
+ args[i] = (host_ptr) argptr + 4;
else
- args[i] = (host_ptr)NULL;
+ args[i] = (host_ptr) NULL;
if ((args[i] == 0 && args_size == 0 &&
- !IS_NULL_POINTER_OK_FOR_FUNC(func_number)) ||
+ !IS_NULL_POINTER_OK_FOR_FUNC(func_number)) ||
(args[i] == 0 && args_size != 0))
- return 0;
+ return 0;
argptr += 4;
break;
}
- CASE_IN_LENGTH_DEPENDING_ON_PREVIOUS_ARGS:
+ CASE_IN_LENGTH_DEPENDING_ON_PREVIOUS_ARGS:
{
- if(*(int*)argptr)
- args[i] = (host_ptr)argptr+4;
+ if (*(int *)argptr)
+ args[i] = (host_ptr) argptr + 4;
else
- args[i] = (host_ptr)NULL;
+ args[i] = (host_ptr) NULL;
if (args[i] == 0 && args_size != 0)
return 0;
break;
}
- CASE_OUT_POINTERS:
+ CASE_OUT_POINTERS:
{
- /* NULL pointer is used as output pointer
- since the argument size is zero. */
- if (args_size == 0) {
- *(int*)r_buffer = 0;
- r_buffer += 4;
+ /* NULL pointer is used as output pointer
+ since the argument size is zero. */
+ if (args_size == 0) {
+ *(int *)r_buffer = 0;
+ r_buffer += 4;
#ifdef __APPLE__
/*On MAC OS, GL call glGetProgramInfoLog and glGetShaderInfoLog will crash if ouput pointer is NULL*/
- args[i] = temp4mac;
+ args[i] = (host_ptr) temp4mac;
#else
- args[i] = NULL;
+ args[i] = (host_ptr) NULL;
#endif
- } else if(*(int*)argptr) {
- *(int*)r_buffer = args_size;
- r_buffer+=4;
- args[i] = (host_ptr)r_buffer;
+ } else if (*(int *)argptr) {
+ *(int *)r_buffer = args_size;
+ r_buffer += 4;
+ args[i] = (host_ptr) r_buffer;
r_buffer += args_size;
- }
- else {
+ } else {
args[i] = 0;
}
argptr += 4;
args_size = 0;
break;
- }
+ }
- case TYPE_DOUBLE:
- CASE_IN_KNOWN_SIZE_POINTERS:
+ case TYPE_DOUBLE:
+ CASE_IN_KNOWN_SIZE_POINTERS:
{
- if(*(int*)argptr)
- args[i] = (host_ptr)argptr+4;
+ if (*(int *)argptr)
+ args[i] = (host_ptr) argptr + 4;
else
- args[i] = (host_ptr)NULL;
+ args[i] = (host_ptr) NULL;
if (args[i] == 0 && args_size != 0)
return 0;
break;
}
- case TYPE_IN_IGNORED_POINTER:
- args[i] = 0;
- break;
+ case TYPE_IN_IGNORED_POINTER:
+ args[i] = 0;
+ break;
- default:
- DEBUGF( "Oops : call %s arg %d pid=%d\n",
- tab_opengl_calls_name[func_number], i,
- process->process_id);
- return 0;
+ default:
+ DEBUGF("Oops : call %s arg %d pid=%d\n",
+ tab_opengl_calls_name[func_number], i,
+ process->process_id);
+ return 0;
}
argptr += args_size;
}
- if((char*)argptr > (char*)args_in + args_len) {
+ if ((char *)argptr > (char *)args_in + args_len) {
DEBUGF("Client bug: malformed command, killing process\n");
return 0;
}
if (signature->ret_type == TYPE_CONST_CHAR)
- r_buffer[0] = 0; // In case high bits are set.
+ r_buffer[0] = 0; // In case high bits are set.
ret = do_function_call(process, func_number, args, r_buffer);
- switch(signature->ret_type) {
+ switch (signature->ret_type) {
case TYPE_INT:
case TYPE_UNSIGNED_INT:
memcpy(r_buffer, &ret, sizeof(int));
case TYPE_NONE:
break;
default:
- DEBUGF("Unsupported GL API return type %i!\n", signature->ret_type);
- exit (-1);
+ DEBUGF("Unsupported GL API return type %i!\n", signature->ret_type);
+ exit(-1);
}
- } // endwhile
+ } // endwhile
/*
switch(signature->ret_type) {
case TYPE_INT:
*/
return 1;
}
+
#define GL_PASSINGTHROUGH_ABI 1
#define GLINIT_FAIL_ABI 3
#define GLINIT_QUEUE 2
#define GLINIT_NOQUEUE 1
-int decode_call_int(ProcessStruct *process, char *in_args, int args_len, char *r_buffer)
+int decode_call_int(ProcessStruct * process, char *in_args, int args_len,
+ char *r_buffer)
{
- static ProcessStruct *cur_process = NULL;
- int ret;
- int first_func = *(short*)in_args;
-
- /* Select the appropriate context for this pid if it isnt already active
- * Note: if we're about to execute glXMakeCurrent() then we tell the
- * renderer not to waste its time switching contexts
- */
-
- if (cur_process != process) {
- cur_process = process;
- vmgl_context_switch(cur_process, (first_func == glXMakeCurrent_func)?0:1);
- }
-
- if(unlikely(first_func == _init32_func || first_func == _init64_func)) {
- if(!cur_process->wordsize) {
- int *version = (int*)(in_args+2);
- cur_process->wordsize = first_func == _init32_func?4:8;
-
- if((version[0] != 1) || (version[1] < GL_PASSINGTHROUGH_ABI)) {
- *(int*)r_buffer = GLINIT_FAIL_ABI; // ABI check FAIL
- TRACE("Error! The GL passing through package in the image does not match the version of QEMUGL. Please update the image!\n");
- exit (1);
- } else if(version[1] > GL_PASSINGTHROUGH_ABI) {
- *(int*)r_buffer = GLINIT_FAIL_ABI; // ABI check FAIL
- TRACE("Error! The GL passing through package in the image does not match the version of QEMUGL. Please update the QEMUGL!\n");
- exit (1);
- }
- else
- *(int*)r_buffer = GLINIT_QUEUE; // Indicate that we can buffer commands
-
- return 1; // Initialisation done
- }
- else {
- DEBUGF("Attempt to init twice. Continuing regardless.\n");
- return 1;
- }
- }
-
- if(unlikely(first_func == -1 || !cur_process->wordsize)) {
- if(!cur_process->wordsize && first_func != -1)
- DEBUGF("commands submitted before process init.\n");
- ret = 0;
- }
- else {
- ret = do_decode_call_int(cur_process, in_args, args_len, r_buffer);
- }
-
- if(!ret)
- cur_process = NULL;
-
- return ret;
+ static ProcessStruct *cur_process = NULL;
+ int ret;
+ int first_func = *(short *)in_args;
+
+ /* Select the appropriate context for this pid if it isnt already active
+ * Note: if we're about to execute glXMakeCurrent() then we tell the
+ * renderer not to waste its time switching contexts
+ */
+
+ if (cur_process != process) {
+ cur_process = process;
+ vmgl_context_switch(cur_process,
+ (first_func == glXMakeCurrent_func) ? 0 : 1);
+ }
+
+ if (unlikely(first_func == _init32_func || first_func == _init64_func)) {
+ if (!cur_process->wordsize) {
+ int *version = (int *)(in_args + 2);
+ cur_process->wordsize = first_func == _init32_func ? 4 : 8;
+
+ if ((version[0] != 1) || (version[1] < GL_PASSINGTHROUGH_ABI)) {
+ *(int *)r_buffer = GLINIT_FAIL_ABI; // ABI check FAIL
+ TRACE
+ ("Error! The GL passing through package in the image does not match the version of QEMUGL. Please update the image!\n");
+ exit(1);
+ } else if (version[1] > GL_PASSINGTHROUGH_ABI) {
+ *(int *)r_buffer = GLINIT_FAIL_ABI; // ABI check FAIL
+ TRACE
+ ("Error! The GL passing through package in the image does not match the version of QEMUGL. Please update the QEMUGL!\n");
+ exit(1);
+ } else
+ *(int *)r_buffer = GLINIT_QUEUE; // Indicate that we can buffer commands
+
+ return 1; // Initialisation done
+ } else {
+ DEBUGF("Attempt to init twice. Continuing regardless.\n");
+ return 1;
+ }
+ }
+
+ if (unlikely(first_func == -1 || !cur_process->wordsize)) {
+ if (!cur_process->wordsize && first_func != -1)
+ DEBUGF("commands submitted before process init.\n");
+ ret = 0;
+ } else {
+ ret = do_decode_call_int(cur_process, in_args, args_len, r_buffer);
+ }
+
+ if (!ret)
+ cur_process = NULL;
+
+ return ret;
}
--- /dev/null
+/*
+ * Host-side implementation of GL/GLX API
+ *
+ * Copyright (c) 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "opengl_process.h"
+
+int decode_call_int(ProcessStruct * p, char *in_args, int args_len,
+ char *r_buffer);
* SungMin Ha <sungmin82.ha@samsung.com>
* MunKyu Im <munkyu.im@samsung.com>
* JiHye Kim <jihye1128.kim@samsung.com>
- * GiWoong Kim <giwoong.kim@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
* DongKyun Yun
* DoHyung Hong
* Hyunjun Son
#include "maru_pm.h"
int codec_init(PCIBus *bus);
-
+int maru_brill_codec_pci_device_init(PCIBus *bus);
#define MAX_IDE_BUS 2
// maru specialized device init...
if (pci_enabled) {
- codec_init(pci_bus);
+// codec_init(pci_bus);
+ maru_brill_codec_pci_device_init(pci_bus);
}
#ifdef CONFIG_YAGL
pci_create_simple(pci_bus, -1, "yagl");
--- /dev/null
+/*
+ * Virtual Codec Device
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Kitae Kim <kt920.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "maru_brill_codec.h"
+
+/* define debug channel */
+MULTI_DEBUG_CHANNEL(qemu, brillcodec);
+
+// device
+#define CODEC_DEVICE_NAME "brilcodec"
+#define CODEC_VERSION 1
+
+// device memory
+#define CODEC_META_DATA_SIZE (256)
+
+#define CODEC_MEM_SIZE (32 * 1024 * 1024)
+#define CODEC_REG_SIZE (256)
+
+// libav
+#define GEN_MASK(x) ((1 << (x)) - 1)
+#define ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
+#define ROUND_UP_2(x) ROUND_UP_X(x, 1)
+#define ROUND_UP_4(x) ROUND_UP_X(x, 2)
+#define ROUND_UP_8(x) ROUND_UP_X(x, 3)
+#define DIV_ROUND_UP_X(v, x) (((v) + GEN_MASK(x)) >> (x))
+
+#define DEFAULT_VIDEO_GOP_SIZE 15
+
+
+// define a queue to manage ioparam, context data
+typedef struct DeviceMemEntry {
+ uint8_t *buf;
+ uint32_t buf_size;
+ uint32_t buf_id;
+ uint32_t ctx_id;
+
+ QTAILQ_ENTRY(DeviceMemEntry) node;
+} DeviceMemEntry;
+
+typedef struct CodecDataStg {
+ CodecParam *param_buf;
+ DeviceMemEntry *data_buf;
+
+ QTAILQ_ENTRY(CodecDataStg) node;
+} CodecDataStg;
+
+// define two queue to store input and output buffers.
+static QTAILQ_HEAD(codec_wq, DeviceMemEntry) codec_wq =
+ QTAILQ_HEAD_INITIALIZER(codec_wq);
+
+static QTAILQ_HEAD(codec_rq, CodecDataStg) codec_rq =
+ QTAILQ_HEAD_INITIALIZER(codec_rq);
+
+static DeviceMemEntry *entry[CODEC_CONTEXT_MAX];
+
+// pixel info
+typedef struct PixFmtInfo {
+ uint8_t x_chroma_shift;
+ uint8_t y_chroma_shift;
+} PixFmtInfo;
+
+static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
+
+// thread
+static int worker_thread_cnt = 0;
+static int idle_thread_cnt = 0;
+#define DEFAULT_WORKER_THREAD_CNT 8
+
+static void *maru_brill_codec_threads(void *opaque);
+
+// irq
+static int irq_raised = 0;
+
+// static void maru_brill_codec_reset_parser_info(MaruBrillCodecState *s, int32_t ctx_index);
+static int maru_brill_codec_query_list(MaruBrillCodecState *s);
+static void maru_brill_codec_release_context(MaruBrillCodecState *s, int32_t value);
+
+// codec functions
+static bool codec_init(MaruBrillCodecState *, int, int, void *);
+static bool codec_deinit(MaruBrillCodecState *, int, int, void *);
+static bool codec_decode_video(MaruBrillCodecState *, int, int, void *);
+static bool codec_encode_video(MaruBrillCodecState *, int, int, void *);
+static bool codec_decode_audio(MaruBrillCodecState *, int, int, void *);
+static bool codec_encode_audio(MaruBrillCodecState *, int , int, void *);
+static bool codec_picture_copy(MaruBrillCodecState *, int , int, void *);
+static bool codec_flush_buffers(MaruBrillCodecState *, int , int, void *);
+
+typedef bool (*CodecFuncEntry)(MaruBrillCodecState *, int, int, void *);
+static CodecFuncEntry codec_func_handler[] = {
+ codec_init,
+ codec_decode_video,
+ codec_encode_video,
+ codec_decode_audio,
+ codec_encode_audio,
+ codec_picture_copy,
+ codec_deinit,
+ codec_flush_buffers,
+};
+
+static AVCodecParserContext *maru_brill_codec_parser_init(AVCodecContext *avctx);
+#if 0
+static int maru_brill_codec_parser_parse (AVCodecParserContext *pctx, AVCodecContext *avctx,
+ uint8_t *inbuf, int inbuf_size,
+ int64_t pts, int64_t dts, int64_t pos);
+#endif
+
+static void maru_brill_codec_pop_writequeue(MaruBrillCodecState *s, int32_t f_id);
+static void maru_brill_codec_push_readqueue(MaruBrillCodecState *s, CodecParam *ioparam);
+static void maru_brill_codec_push_writequeue(MaruBrillCodecState *s, void* buf,
+ uint32_t buf_size, int ctx_id, int f_id);
+
+static void *maru_brill_codec_store_inbuf(uint8_t *mem_base_offset, CodecParam *ioparam);
+
+static void maru_brill_codec_get_cpu_cores(void)
+{
+ worker_thread_cnt = get_number_of_processors();
+ if (worker_thread_cnt < DEFAULT_WORKER_THREAD_CNT) {
+ worker_thread_cnt = DEFAULT_WORKER_THREAD_CNT;
+ }
+
+ TRACE("number of threads: %d\n", worker_thread_cnt);
+}
+
+static void maru_brill_codec_threads_create(MaruBrillCodecState *s)
+{
+ int index;
+ QemuThread *pthread = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ pthread = g_malloc(sizeof(QemuThread) * worker_thread_cnt);
+ if (!pthread) {
+ ERR("failed to allocate threadpool memory.\n");
+ return;
+ }
+
+ qemu_cond_init(&s->threadpool.cond);
+ qemu_mutex_init(&s->threadpool.mutex);
+
+ s->is_thread_running = 1;
+
+ for (index = 0; index < worker_thread_cnt; index++) {
+ qemu_thread_create(&pthread[index],
+ maru_brill_codec_threads, (void *)s, QEMU_THREAD_JOINABLE);
+ }
+
+ s->threadpool.threads = pthread;
+
+ TRACE("leave: %s\n", __func__);
+}
+
+static void maru_brill_codec_thread_exit(MaruBrillCodecState *s)
+{
+ int index;
+
+ TRACE("enter: %s\n", __func__);
+
+ /* stop to run dedicated threads. */
+ s->is_thread_running = 0;
+
+ for (index = 0; index < worker_thread_cnt; index++) {
+ qemu_thread_join(&s->threadpool.threads[index]);
+ }
+
+ TRACE("destroy mutex and conditional.\n");
+ qemu_mutex_destroy(&s->threadpool.mutex);
+ qemu_cond_destroy(&s->threadpool.cond);
+
+ if (s->threadpool.threads) {
+ g_free(s->threadpool.threads);
+ s->threadpool.threads = NULL;
+ }
+
+ TRACE("leave: %s\n", __func__);
+}
+
+static void maru_brill_codec_wakeup_threads(MaruBrillCodecState *s, int api_index)
+{
+ CodecParam *ioparam = NULL;
+
+ ioparam = g_malloc0(sizeof(CodecParam));
+ memcpy(ioparam, &s->ioparam, sizeof(CodecParam));
+
+ TRACE("wakeup thread. ctx_id: %u, api_id: %u, mem_offset: 0x%x\n",
+ ioparam->ctx_index, ioparam->api_index, ioparam->mem_offset);
+
+ maru_brill_codec_push_readqueue(s, ioparam);
+
+ qemu_mutex_lock(&s->context_mutex);
+ // W/A for threads starvation.
+ while (idle_thread_cnt == 0) {
+ qemu_mutex_unlock(&s->context_mutex);
+ TRACE("Worker threads are exhausted\n");
+ usleep(2000); // wait 2ms.
+ qemu_mutex_lock(&s->context_mutex);
+ }
+ qemu_cond_signal(&s->threadpool.cond);
+ qemu_mutex_unlock(&s->context_mutex);
+
+ TRACE("after sending conditional signal\n");
+}
+
+static void *maru_brill_codec_threads(void *opaque)
+{
+ MaruBrillCodecState *s = (MaruBrillCodecState *)opaque;
+
+ TRACE("enter: %s\n", __func__);
+
+ while (s->is_thread_running) {
+ int ctx_id, f_id, api_id;
+ CodecDataStg *elem = NULL;
+ DeviceMemEntry *indata_buf = NULL;
+
+ qemu_mutex_lock(&s->context_mutex);
+ ++idle_thread_cnt; // protected under mutex.
+ qemu_cond_wait(&s->threadpool.cond, &s->context_mutex);
+ --idle_thread_cnt; // protected under mutex.
+ qemu_mutex_unlock(&s->context_mutex);
+
+ qemu_mutex_lock(&s->ioparam_queue_mutex);
+ elem = QTAILQ_FIRST(&codec_rq);
+ if (elem) {
+ QTAILQ_REMOVE(&codec_rq, elem, node);
+ qemu_mutex_unlock(&s->ioparam_queue_mutex);
+ } else {
+ qemu_mutex_unlock(&s->ioparam_queue_mutex);
+ continue;
+ }
+
+ api_id = elem->param_buf->api_index;
+ ctx_id = elem->param_buf->ctx_index;
+ f_id = elem->param_buf->file_index;
+ indata_buf = elem->data_buf;
+
+ TRACE("api_id: %d ctx_id: %d f_id: %x\n", api_id, ctx_id, f_id);
+
+ if (!codec_func_handler[api_id](s, ctx_id, f_id, indata_buf)) {
+ ERR("codec_func failure.\n");
+ continue;
+ }
+
+ if (elem) {
+ TRACE("release an element of CodecDataStg\n");
+
+ if (elem->param_buf) {
+ TRACE("release a buffer of CodecParam\n");
+ g_free(elem->param_buf);
+ }
+
+ if (elem->data_buf) {
+
+ if (elem->data_buf->buf) {
+ TRACE("release inbuf\n");
+ g_free(elem->data_buf->buf);
+ }
+
+ TRACE("release a buffer indata_buf\n");
+ g_free(elem->data_buf);
+ }
+
+ g_free(elem);
+ }
+
+ if (api_id == CODEC_DEINIT) {
+ TRACE("deinit doesn't need to raise interrupt.\n");
+ } else {
+ TRACE("switch context to raise interrupt.\n");
+ qemu_bh_schedule(s->codec_bh);
+ }
+ }
+
+ maru_brill_codec_thread_exit(s);
+
+ TRACE("leave: %s\n", __func__);
+ return NULL;
+}
+
+// queue
+static void maru_brill_codec_push_readqueue(MaruBrillCodecState *s,
+ CodecParam *ioparam)
+{
+ CodecDataStg *elem = NULL;
+ DeviceMemEntry *data_buf = NULL;
+
+ elem = g_malloc0(sizeof(CodecDataStg));
+ if (!elem) {
+ ERR("failed to allocate ioparam_queue. %d\n", sizeof(CodecDataStg));
+ return;
+ }
+
+ elem->param_buf = ioparam;
+
+ switch(ioparam->api_index) {
+ case CODEC_DECODE_VIDEO ... CODEC_ENCODE_AUDIO:
+ data_buf = maru_brill_codec_store_inbuf((uint8_t *)s->vaddr, ioparam);
+ break;
+ default:
+ TRACE("no buffer from guest\n");
+ break;
+ }
+
+ elem->data_buf = data_buf;
+
+ qemu_mutex_lock(&s->ioparam_queue_mutex);
+ QTAILQ_INSERT_TAIL(&codec_rq, elem, node);
+ qemu_mutex_unlock(&s->ioparam_queue_mutex);
+}
+
+static void *maru_brill_codec_store_inbuf(uint8_t *mem_base_offset,
+ CodecParam *ioparam)
+{
+ DeviceMemEntry *elem = NULL;
+ int readbuf_size, size = 0;
+ uint8_t *readbuf = NULL;
+ uint8_t *device_mem = NULL;
+
+ device_mem = mem_base_offset + ioparam->mem_offset;
+ if (!device_mem) {
+ ERR("[%d] device memory region is null\n");
+ return NULL;
+ }
+
+ elem = g_malloc0(sizeof(DeviceMemEntry));
+ if (!elem) {
+ ERR("failed to allocate readqueue node. size: %d\n",
+ sizeof(DeviceMemEntry));
+ return NULL;
+ }
+
+ memcpy(&readbuf_size, device_mem, sizeof(readbuf_size));
+ size = sizeof(readbuf_size);
+
+ TRACE("readbuf size: %d\n", readbuf_size);
+ if (readbuf_size <= 0) {
+ TRACE("inbuf size is zero. api_id: %d, ctx_id: %d, mem_offset: %x\n",
+ readbuf_size, ioparam->api_index, ioparam->ctx_index, ioparam->mem_offset);
+ } else {
+ readbuf = g_malloc0(readbuf_size);
+ if (!readbuf) {
+ ERR("failed to allocate a read buffer. size: %d\n", readbuf_size);
+ } else {
+ TRACE("copy input buffer from guest. ctx_id: %d, mem_offset: %x\n",
+ ioparam->ctx_index, ioparam->mem_offset);
+ memcpy(readbuf, device_mem + size, readbuf_size);
+ }
+ }
+ memset(device_mem, 0x00, sizeof(readbuf_size));
+
+ elem->buf = readbuf;
+ elem->buf_size = readbuf_size;
+ elem->buf_id = ioparam->file_index;
+ elem->ctx_id = ioparam->ctx_index;
+
+ return elem;
+}
+
+static void maru_brill_codec_push_writequeue(MaruBrillCodecState *s, void* buf,
+ uint32_t buf_size, int ctx_id, int f_id)
+{
+ DeviceMemEntry *elem = NULL;
+ elem = g_malloc0(sizeof(DeviceMemEntry));
+
+ elem->buf = buf;
+ elem->buf_size = buf_size;
+ elem->buf_id = f_id;
+ elem->ctx_id = ctx_id;
+
+ qemu_mutex_lock(&s->context_queue_mutex);
+ QTAILQ_INSERT_TAIL(&codec_wq, elem, node);
+ qemu_mutex_unlock(&s->context_queue_mutex);
+}
+
+static void maru_brill_codec_pop_writequeue(MaruBrillCodecState *s, int32_t file_index)
+{
+ DeviceMemEntry *elem = NULL;
+ uint32_t mem_offset = 0, ctx_idx;
+
+ TRACE("enter: %s\n", __func__);
+
+ for (ctx_idx = 1; ctx_idx < CODEC_CONTEXT_MAX; ctx_idx++) {
+ if (s->context[ctx_idx].file_index == file_index) {
+ break;
+ }
+ }
+
+ if (ctx_idx == CODEC_CONTEXT_MAX) {
+ ERR("failed to find a proper entry via file_index. %x\n", file_index);
+ return;
+ }
+
+ TRACE("pop_writeqeue. context index: %d\n", ctx_idx);
+
+ elem = entry[ctx_idx];
+ if (elem) {
+ mem_offset = s->ioparam.mem_offset;
+
+ // check corrupted mem_offset
+ if (mem_offset < CODEC_MEM_SIZE) {
+ if (elem->buf) {
+ TRACE("write data %d to guest. mem_offset: 0x%x\n",
+ elem->buf_size, mem_offset);
+ memcpy(s->vaddr + mem_offset, elem->buf, elem->buf_size);
+
+ TRACE("release output buffer: %p\n", elem->buf);
+ g_free(elem->buf);
+ }
+ } else {
+ TRACE("mem_offset is corrupted!!\n");
+ }
+
+ TRACE("pop_writequeue. release elem: %p\n", elem);
+ g_free(elem);
+
+ entry[ctx_idx] = NULL;
+ } else {
+ TRACE("there is no buffer to copy data to guest\n");
+ }
+
+ TRACE("leave: %s\n", __func__);
+}
+
+static void serialize_video_data(const struct video_data *video,
+ AVCodecContext *avctx)
+{
+ if (video->width) {
+ avctx->width = video->width;
+ }
+ if (video->height) {
+ avctx->height = video->height;
+ }
+ if (video->fps_n) {
+ avctx->time_base.num = video->fps_n;
+ }
+ if (video->fps_d) {
+ avctx->time_base.den = video->fps_d;
+ }
+ if (video->pix_fmt > PIX_FMT_NONE) {
+ avctx->pix_fmt = video->pix_fmt;
+ }
+ if (video->par_n) {
+ avctx->sample_aspect_ratio.num = video->par_n;
+ }
+ if (video->par_d) {
+ avctx->sample_aspect_ratio.den = video->par_d;
+ }
+ if (video->bpp) {
+ avctx->bits_per_coded_sample = video->bpp;
+ }
+ if (video->ticks_per_frame) {
+ avctx->ticks_per_frame = video->ticks_per_frame;
+ }
+}
+
+static void deserialize_video_data (const AVCodecContext *avctx,
+ struct video_data *video)
+{
+ memset(video, 0x00, sizeof(struct video_data));
+
+ video->width = avctx->width;
+ video->height = avctx->height;
+ video->fps_n = avctx->time_base.num;
+ video->fps_d = avctx->time_base.den;
+ video->pix_fmt = avctx->pix_fmt;
+ video->par_n = avctx->sample_aspect_ratio.num;
+ video->par_d = avctx->sample_aspect_ratio.den;
+ video->bpp = avctx->bits_per_coded_sample;
+ video->ticks_per_frame = avctx->ticks_per_frame;
+}
+
+static void serialize_audio_data (const struct audio_data *audio,
+ AVCodecContext *avctx)
+{
+ if (audio->channels) {
+ avctx->channels = audio->channels;
+ }
+ if (audio->sample_rate) {
+ avctx->sample_rate = audio->sample_rate;
+ }
+ if (audio->block_align) {
+ avctx->block_align = audio->block_align;
+ }
+
+ if (audio->sample_fmt > AV_SAMPLE_FMT_NONE) {
+ avctx->sample_fmt = audio->sample_fmt;
+ }
+}
+
+#if 0
+static void maru_brill_codec_reset_parser_info(MaruBrillCodecState *s, int32_t ctx_index)
+{
+ s->context[ctx_index].parser_buf = NULL;
+ s->context[ctx_index].parser_use = false;
+}
+#endif
+
+static void maru_brill_codec_release_context(MaruBrillCodecState *s, int32_t file_index)
+{
+ DeviceMemEntry *wq_elem = NULL, *wnext = NULL;
+ CodecDataStg *rq_elem = NULL, *rnext = NULL;
+ int ctx_id;
+
+ TRACE("enter: %s\n", __func__);
+
+ qemu_mutex_lock(&s->threadpool.mutex);
+ for (ctx_id = 1; ctx_id < CODEC_CONTEXT_MAX; ctx_id++) {
+ if (s->context[ctx_id].file_index == file_index) {
+ TRACE("reset %d context\n", ctx_id);
+ s->context[ctx_id].occupied = false;
+ break;
+ }
+ }
+ qemu_mutex_unlock(&s->threadpool.mutex);
+
+ if (ctx_id == CODEC_CONTEXT_MAX) {
+ WARN("cannot find a context for 0x%x\n", file_index);
+ } else {
+ codec_deinit(s, ctx_id, file_index, NULL);
+
+ QTAILQ_FOREACH_SAFE(rq_elem, &codec_rq, node, rnext) {
+ if (rq_elem && rq_elem->data_buf &&
+ (rq_elem->data_buf->buf_id == file_index)) {
+ TRACE("remove unused node from codec_rq. file: %p\n", file_index);
+ qemu_mutex_lock(&s->context_queue_mutex);
+ QTAILQ_REMOVE(&codec_rq, rq_elem, node);
+ qemu_mutex_unlock(&s->context_queue_mutex);
+ if (rq_elem && rq_elem->data_buf) {
+ TRACE("release_context. release rq_buffer: %p\n",
+ rq_elem->data_buf);
+ g_free(rq_elem->data_buf);
+ }
+
+ TRACE("release rq_elem: %p\n", rq_elem);
+ g_free(rq_elem);
+ } else {
+ TRACE("remain this node in the codec_rq. %x\n",
+ rq_elem->data_buf->buf_id);
+ }
+ }
+
+ QTAILQ_FOREACH_SAFE(wq_elem, &codec_wq, node, wnext) {
+ if (wq_elem && wq_elem->buf_id == file_index) {
+ TRACE("remove nodes from codec_wq."
+ " elem: %p, buf_id: %p, ctx_id: %d\n", wq_elem, wq_elem->ctx_id, file_index);
+ qemu_mutex_lock(&s->context_queue_mutex);
+ QTAILQ_REMOVE(&codec_wq, wq_elem, node);
+ qemu_mutex_unlock(&s->context_queue_mutex);
+
+ if (wq_elem && wq_elem->buf) {
+ TRACE("release_context. release wq_buffer: %p\n", wq_elem->buf);
+ g_free(wq_elem->buf);
+ wq_elem->buf = NULL;
+ }
+
+ TRACE("release wq_elem: %p\n", wq_elem);
+ g_free(wq_elem);
+ } else {
+ TRACE("remain this node in the codec_wq. :%x\n", wq_elem->buf_id);
+ }
+ }
+// maru_brill_codec_reset_parser_info(s, ctx_id);
+ }
+
+ TRACE("leave: %s\n", __func__);
+}
+
+
+// initialize each pixel format.
+static void maru_brill_codec_pixfmt_info_init(void)
+{
+ /* YUV formats */
+ pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
+
+ pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
+ pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
+
+ pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
+ pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
+
+ pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
+
+ /* RGB formats */
+ pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
+}
+
+static int maru_brill_codec_get_picture_size(AVPicture *picture, uint8_t *ptr,
+ int pix_fmt, int width,
+ int height, bool encode)
+{
+ int size, w2, h2, size2;
+ int stride, stride2;
+ int fsize;
+ PixFmtInfo *pinfo;
+
+ pinfo = &pix_fmt_info[pix_fmt];
+
+ switch (pix_fmt) {
+ case PIX_FMT_YUV420P:
+ case PIX_FMT_YUV422P:
+ case PIX_FMT_YUV444P:
+ case PIX_FMT_YUV410P:
+ case PIX_FMT_YUV411P:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUVJ422P:
+ case PIX_FMT_YUVJ444P:
+ stride = ROUND_UP_4(width);
+ h2 = ROUND_UP_X(height, pinfo->y_chroma_shift);
+ size = stride * h2;
+ w2 = DIV_ROUND_UP_X(width, pinfo->x_chroma_shift);
+ stride2 = ROUND_UP_4(w2);
+ h2 = DIV_ROUND_UP_X(height, pinfo->y_chroma_shift);
+ size2 = stride2 * h2;
+ fsize = size + 2 * size2;
+ TRACE("stride: %d, stride2: %d, size: %d, size2: %d, fsize: %d\n",
+ stride, stride2, size, size2, fsize);
+
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = picture->data[0] + size;
+ picture->data[2] = picture->data[1] + size2;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = stride2;
+ picture->linesize[2] = stride2;
+ picture->linesize[3] = 0;
+ TRACE("planes %d %d %d\n", 0, size, size + size2);
+ TRACE("strides %d %d %d\n", 0, stride, stride2, stride2);
+ break;
+ case PIX_FMT_YUVA420P:
+ stride = ROUND_UP_4(width);
+ h2 = ROUND_UP_X(height, pinfo->y_chroma_shift);
+ size = stride * h2;
+ w2 = DIV_ROUND_UP_X(width, pinfo->x_chroma_shift);
+ stride2 = ROUND_UP_4(w2);
+ h2 = DIV_ROUND_UP_X(height, pinfo->y_chroma_shift);
+ size2 = stride2 * h2;
+ fsize = 2 * size + 2 * size2;
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = picture->data[0] + size;
+ picture->data[2] = picture->data[1] + size2;
+ picture->data[3] = picture->data[2] + size2;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = stride2;
+ picture->linesize[2] = stride2;
+ picture->linesize[3] = stride;
+ TRACE("planes %d %d %d\n", 0, size, size + size2);
+ TRACE("strides %d %d %d\n", 0, stride, stride2, stride2);
+ break;
+ case PIX_FMT_RGB24:
+ case PIX_FMT_BGR24:
+ stride = ROUND_UP_4 (width * 3);
+ fsize = stride * height;
+ TRACE("stride: %d, size: %d\n", stride, fsize);
+
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_RGB32:
+ stride = width * 4;
+ fsize = stride * height;
+ TRACE("stride: %d, size: %d\n", stride, fsize);
+
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_RGB555:
+ case PIX_FMT_RGB565:
+ stride = ROUND_UP_4 (width * 2);
+ fsize = stride * height;
+ TRACE("stride: %d, size: %d\n", stride, fsize);
+
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_PAL8:
+ stride = ROUND_UP_4(width);
+ size = stride * height;
+ fsize = size + 256 * 4;
+ TRACE("stride: %d, size: %d\n", stride, fsize);
+
+ if (!encode && !ptr) {
+ TRACE("allocate a buffer for a decoded picture.\n");
+ ptr = av_mallocz(fsize);
+ if (!ptr) {
+ ERR("[%d] failed to allocate memory.\n", __LINE__);
+ return -1;
+ }
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = ptr + size;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 4;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ default:
+ picture->data[0] = NULL;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ fsize = -1;
+ ERR("pixel format: %d was wrong.\n", pix_fmt);
+ break;
+ }
+
+ return fsize;
+}
+
+static int maru_brill_codec_query_list (MaruBrillCodecState *s)
+{
+ AVCodec *codec = NULL;
+ uint32_t size = 0, mem_size = 0;
+ uint32_t data_len = 0, length = 0;
+ int32_t codec_type, media_type;
+ int32_t codec_fmts[4], i;
+
+ /* register avcodec */
+ TRACE("register avcodec\n");
+ av_register_all();
+
+ codec = av_codec_next(NULL);
+ if (!codec) {
+ ERR("failed to get codec info.\n");
+ return -1;
+ }
+
+ // a region to store the number of codecs.
+ length = 32 + 64 + 6 * sizeof(int32_t);
+ mem_size = size = sizeof(uint32_t);
+
+ while (codec) {
+ codec_type =
+ codec->decode ? CODEC_TYPE_DECODE : CODEC_TYPE_ENCODE;
+ media_type = codec->type;
+
+ memset(codec_fmts, -1, sizeof(codec_fmts));
+ if (media_type == AVMEDIA_TYPE_VIDEO) {
+ if (codec->pix_fmts) {
+ for (i = 0; codec->pix_fmts[i] != -1; i++) {
+ codec_fmts[i] = codec->pix_fmts[i];
+ }
+ }
+ } else if (media_type == AVMEDIA_TYPE_AUDIO) {
+ if (codec->sample_fmts) {
+ for (i = 0; codec->sample_fmts[i] != -1; i++) {
+ codec_fmts[i] = codec->sample_fmts[i];
+ }
+ }
+ } else {
+ ERR("%s of media type is unknown.\n", codec->name);
+ }
+
+ memset(s->vaddr + mem_size, 0x00, length);
+ mem_size += length;
+
+ data_len += length;
+ memcpy(s->vaddr, &data_len, sizeof(data_len));
+
+ memcpy(s->vaddr + size, &codec_type, sizeof(codec_type));
+ size += sizeof(codec_type);
+ memcpy(s->vaddr + size, &media_type, sizeof(media_type));
+ size += sizeof(media_type);
+ memcpy(s->vaddr + size, codec->name, strlen(codec->name));
+ size += 32;
+ memcpy(s->vaddr + size,
+ codec->long_name, strlen(codec->long_name));
+ size += 64;
+ memcpy(s->vaddr + size, codec_fmts, sizeof(codec_fmts));
+ size += sizeof(codec_fmts);
+
+ codec = av_codec_next(codec);
+ }
+
+ return 0;
+}
+
+static int maru_brill_codec_get_context_index(MaruBrillCodecState *s)
+{
+ int index;
+
+ TRACE("enter: %s\n", __func__);
+
+ for (index = 1; index < CODEC_CONTEXT_MAX; index++) {
+ if (s->context[index].occupied == false) {
+ TRACE("get %d of codec context successfully.\n", index);
+ s->context[index].occupied = true;
+ break;
+ }
+ }
+
+ if (index == CODEC_CONTEXT_MAX) {
+ ERR("failed to get available codec context. ");
+ ERR("try to run codec again.\n");
+ index = -1;
+ }
+
+ TRACE("leave: %s\n", __func__);
+
+ return index;
+}
+
+// allocate avcontext and avframe struct.
+static AVCodecContext *maru_brill_codec_alloc_context(MaruBrillCodecState *s, int index)
+{
+ TRACE("enter: %s\n", __func__);
+
+ TRACE("allocate %d of context and frame.\n", index);
+ s->context[index].avctx = avcodec_alloc_context();
+ s->context[index].frame = avcodec_alloc_frame();
+ s->context[index].opened = false;
+
+ s->context[index].parser_buf = NULL;
+ s->context[index].parser_use = false;
+
+ TRACE("leave: %s\n", __func__);
+
+ return s->context[index].avctx;
+}
+
+static AVCodec *maru_brill_codec_find_avcodec(uint8_t *mem_buf)
+{
+ AVCodec *codec = NULL;
+ int32_t encode, size = 0;
+ char codec_name[32] = {0, };
+
+ memcpy(&encode, mem_buf, sizeof(encode));
+ size = sizeof(encode);
+ memcpy(codec_name, mem_buf + size, sizeof(codec_name));
+ size += sizeof(codec_name);
+
+ TRACE("type: %d, name: %s\n", encode, codec_name);
+
+ if (encode) {
+ codec = avcodec_find_encoder_by_name (codec_name);
+ } else {
+ codec = avcodec_find_decoder_by_name (codec_name);
+ }
+ INFO("%s!! find %s %s\n",
+ codec ? "success" : "failure",
+ codec_name, encode ? "encoder" : "decoder");
+
+ return codec;
+}
+
+static void read_codec_init_data(AVCodecContext *avctx, uint8_t *mem_buf)
+{
+ struct video_data video = { 0, };
+ struct audio_data audio = { 0, };
+ int bitrate = 0, size = 0;
+
+ memcpy(&video, mem_buf + size, sizeof(video));
+ size = sizeof(video);
+ serialize_video_data(&video, avctx);
+
+ memcpy(&audio, mem_buf + size, sizeof(int32_t) * 6);
+ size += sizeof(int32_t) * 6;
+ memcpy(&audio.bits_per_smp_fmt, mem_buf + size, sizeof(int32_t));
+ size += sizeof(int32_t);
+ memcpy(&audio.channel_layout, mem_buf + size, sizeof(int64_t));
+ size += sizeof(int64_t);
+ serialize_audio_data(&audio, avctx);
+
+ memcpy(&bitrate, mem_buf + size, sizeof(bitrate));
+ size += sizeof(bitrate);
+ if (bitrate) {
+ avctx->bit_rate = bitrate;
+ }
+ memcpy(&avctx->codec_tag, mem_buf + size, sizeof(avctx->codec_tag));
+ size += sizeof(avctx->codec_tag);
+ memcpy(&avctx->extradata_size,
+ mem_buf + size, sizeof(avctx->extradata_size));
+ size += sizeof(avctx->extradata_size);
+ if (avctx->extradata_size > 0) {
+ TRACE("extradata size: %d.\n", avctx->extradata_size);
+ avctx->extradata =
+ av_mallocz(ROUND_UP_X(avctx->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE, 4));
+ if (avctx->extradata) {
+ memcpy(avctx->extradata, mem_buf + size, avctx->extradata_size);
+ }
+ } else {
+ TRACE("no extra data.\n");
+ avctx->extradata =
+ av_mallocz(ROUND_UP_X(FF_INPUT_BUFFER_PADDING_SIZE, 4));
+ }
+}
+
+// write the result of codec_init
+static void write_codec_init_data(AVCodecContext *avctx, uint8_t *mem_buf)
+{
+ int size = 0;
+
+ if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
+ int osize = 0;
+
+ TRACE("codec_init. audio sample_fmt: %d\n", avctx->sample_fmt);
+
+ memcpy(mem_buf, &avctx->sample_fmt, sizeof(avctx->sample_fmt));
+ size = sizeof(avctx->sample_fmt);
+ memcpy(mem_buf + size,
+ &avctx->frame_size, sizeof(avctx->frame_size));
+ size += sizeof(avctx->frame_size);
+ osize = av_get_bits_per_sample(avctx->codec->id) / 8;
+ memcpy(mem_buf + size, &osize, sizeof(osize));
+ }
+}
+
+// write the result of codec_decode_video
+static void write_codec_decode_video_data(AVCodecContext *avctx, int len,
+ int got_pic_ptr, uint8_t *mem_buf)
+{
+ struct video_data video;
+ int size = 0;
+
+ memcpy(mem_buf, &len, sizeof(len));
+ size = sizeof(len);
+ memcpy(mem_buf + size, &got_pic_ptr, sizeof(got_pic_ptr));
+ size += sizeof(got_pic_ptr);
+ if (avctx) {
+ deserialize_video_data(avctx, &video);
+ memcpy(mem_buf + size, &video, sizeof(struct video_data));
+ }
+}
+
+// write the result of codec_decode_audio
+static void write_codec_decode_audio_data(int sample_rate, int channel,
+ int64_t channel_layout, int len,
+ int frame_size_ptr, uint8_t *mem_buf)
+{
+ int size = 0;
+
+ TRACE("copy decode_audio. len %d, frame_size %d\n", len, frame_size_ptr);
+
+ memcpy(mem_buf, &sample_rate, sizeof(sample_rate));
+ size = sizeof(sample_rate);
+ memcpy(mem_buf + size, &channel, sizeof(channel));
+ size += sizeof(channel);
+ memcpy(mem_buf + size, &channel_layout, sizeof(channel_layout));
+ size += sizeof(channel_layout);
+ memcpy(mem_buf + size, &len, sizeof(len));
+ size += sizeof(len);
+ memcpy(mem_buf + size, &frame_size_ptr, sizeof(frame_size_ptr));
+}
+
+// codec functions
+static bool codec_init(MaruBrillCodecState *s, int ctx_id, int f_id, void *elem)
+{
+ AVCodecContext *avctx = NULL;
+ AVCodec *codec = NULL;
+ int size = 0, ret = -1;
+ uint8_t *meta_buf = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ // assign meta_buf
+ meta_buf = s->vaddr + ((ctx_id - 1) * CODEC_META_DATA_SIZE);
+ meta_buf += 8; // skipped header.
+
+ // allocate AVCodecContext
+ avctx = maru_brill_codec_alloc_context(s, ctx_id);
+ if (!avctx) {
+ ERR("[%d] failed to allocate context.\n", __LINE__);
+ ret = -1;
+ } else {
+ s->context[ctx_id].file_index = f_id;
+
+ codec = maru_brill_codec_find_avcodec(meta_buf);
+ if (codec) {
+ size = sizeof(int32_t) + 32; // buffer size of codec_name
+ read_codec_init_data(avctx, meta_buf + size);
+
+ ret = avcodec_open(avctx, codec);
+ INFO("avcodec_open done. ctx_id: %d\n", ctx_id);
+
+ s->context[ctx_id].opened = true;
+ s->context[ctx_id].parser_ctx =
+ maru_brill_codec_parser_init(avctx);
+ } else {
+ ERR("failed to find codec. ctx_id: %d\n", ctx_id);
+ }
+ }
+
+ // return the result of avcodec_open
+ memcpy(meta_buf, &ret, sizeof(ret));
+ size = sizeof(ret);
+ if (ret < 0) {
+ ERR("failed to open codec contex.\n");
+ } else {
+ write_codec_init_data(avctx, meta_buf + size);
+ }
+
+ maru_brill_codec_push_writequeue(s, NULL, 0, ctx_id, f_id);
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+static bool codec_deinit(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx = NULL;
+ AVFrame *frame = NULL;
+ AVCodecParserContext *parserctx = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ avctx = s->context[ctx_id].avctx;
+ frame = s->context[ctx_id].frame;
+ parserctx = s->context[ctx_id].parser_ctx;
+ if (!avctx || !frame) {
+ TRACE("%d of AVCodecContext or AVFrame is NULL. "
+ " Those resources have been released before.\n", ctx_id);
+ return false;
+ } else {
+ qemu_mutex_lock(&s->threadpool.mutex);
+ if (!s->context[ctx_id].opened) {
+ TRACE("%d of context has already been closed\n", ctx_id);
+ qemu_mutex_unlock(&s->threadpool.mutex);
+ return false;
+ }
+ avcodec_close(avctx);
+ INFO("close avcontext of %d\n", ctx_id);
+ s->context[ctx_id].opened = false;
+ qemu_mutex_unlock(&s->threadpool.mutex);
+
+ if (avctx->extradata) {
+ TRACE("free context extradata\n");
+ av_free(avctx->extradata);
+ s->context[ctx_id].avctx->extradata = NULL;
+ }
+
+ if (avctx->palctrl) {
+ TRACE("free context palctrl \n");
+ av_free(avctx->palctrl);
+ s->context[ctx_id].avctx->palctrl = NULL;
+ }
+
+ if (frame) {
+ TRACE("free frame\n");
+ av_free(frame);
+ s->context[ctx_id].frame = NULL;
+ }
+
+ if (avctx) {
+ TRACE("free codec context\n");
+ av_free(avctx);
+ s->context[ctx_id].avctx = NULL;
+ }
+
+ if (parserctx) {
+ av_parser_close(parserctx);
+ s->context[ctx_id].parser_ctx = NULL;
+ }
+ }
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+//
+static bool codec_flush_buffers(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ avctx = s->context[ctx_id].avctx;
+ if (!avctx) {
+ ERR("%d of AVCodecContext is NULL.\n", ctx_id);
+ return false;
+ } else {
+ avcodec_flush_buffers(avctx);
+ TRACE("flush %d context of buffers.\n", ctx_id);
+ }
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+static bool codec_decode_video(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx = NULL;
+ AVFrame *picture = NULL;
+ AVPacket avpkt;
+ int got_pic_ptr = 0, len = 0;
+ uint8_t *inbuf = NULL;
+ int inbuf_size, idx, size = 0;
+ int64_t in_offset;
+
+ DeviceMemEntry *elem = NULL;
+ uint8_t *meta_buf = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ meta_buf = s->vaddr + ((ctx_id - 1) * CODEC_META_DATA_SIZE);
+ meta_buf += 8; // skipped header.
+
+ memcpy(&inbuf_size, meta_buf, sizeof(inbuf_size));
+ size = sizeof(inbuf_size);
+ memcpy(&idx, meta_buf + size, sizeof(idx));
+ size += sizeof(idx);
+ memcpy(&in_offset, meta_buf + size, sizeof(in_offset));
+ size += sizeof(in_offset);
+ TRACE("decode_video. input buffer size: %d\n", inbuf_size);
+
+ elem = (DeviceMemEntry *)data_buf;
+ if (elem && elem->buf) {
+ inbuf = elem->buf;
+ } else if (elem) {
+ inbuf_size = 0;
+ TRACE("decode_video. no input buffer. ctx_id: %d, %p, %d\n",
+ ctx_id, inbuf, elem->buf_size);
+ } else {
+ ERR("wrong input data\n");
+ return false;
+ }
+
+ av_init_packet(&avpkt);
+ avpkt.data = inbuf;
+ avpkt.size = inbuf_size;
+
+ avctx = s->context[ctx_id].avctx;
+ picture = s->context[ctx_id].frame;
+ if (!avctx || !picture) {
+ ERR("%d of AVCodecContext or AVFrame is NULL.\n", ctx_id);
+ len = -1;
+ } else if (!avctx->codec) {
+ ERR("%d of AVCodec is NULL.\n", ctx_id);
+ len = -1;
+ } else {
+ // in case of skipping frames
+ picture->pict_type = -1;
+
+ len = avcodec_decode_video2(avctx, picture, &got_pic_ptr, &avpkt);
+ if (len < 0) {
+ ERR("failed to decode video. ctx index: %d\n", ctx_id);
+ }
+ }
+
+ TRACE("after decoding video. len: %d, have_data: %d\n",
+ len, got_pic_ptr);
+
+ write_codec_decode_video_data(avctx, len, got_pic_ptr, meta_buf);
+ maru_brill_codec_push_writequeue(s, NULL, 0, ctx_id, f_id);
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+static bool codec_picture_copy (MaruBrillCodecState *s, int ctx_id, int f_id, void *elem)
+{
+ AVCodecContext *avctx;
+ AVPicture *src;
+ AVPicture dst;
+ uint8_t *out_buffer = NULL, *tempbuf = NULL;
+ int pict_size = 0;
+
+ TRACE("enter: %s\n", __func__);
+
+ TRACE("copy decoded image of %d context.\n", ctx_id);
+
+ avctx = s->context[ctx_id].avctx;
+ src = (AVPicture *)s->context[ctx_id].frame;
+ if (!avctx || !src) {
+ ERR("%d of AVCodecContext or AVFrame is NULL.\n", ctx_id);
+ } else if (!avctx->codec) {
+ ERR("%d of AVCodec is NULL.\n", ctx_id);
+ } else {
+ TRACE("decoded image. pix_fmt: %d width: %d, height: %d\n",
+ avctx->pix_fmt, avctx->width, avctx->height);
+
+ pict_size =
+ maru_brill_codec_get_picture_size(&dst, NULL, avctx->pix_fmt,
+ avctx->width, avctx->height, false);
+ if ((pict_size) < 0) {
+ ERR("picture size: %d\n", pict_size);
+ } else {
+ TRACE("picture size: %d\n", pict_size);
+ av_picture_copy(&dst, src, avctx->pix_fmt,
+ avctx->width, avctx->height);
+
+ tempbuf = g_malloc0(pict_size);
+ if (!tempbuf) {
+ ERR("failed to allocate a picture buffer. size: %d\n", pict_size);
+ } else {
+ out_buffer = dst.data[0];
+ memcpy(tempbuf, out_buffer, pict_size);
+ }
+ av_free(out_buffer);
+ }
+ }
+ maru_brill_codec_push_writequeue(s, tempbuf, pict_size, ctx_id, f_id);
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+static bool codec_decode_audio(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx;
+ AVPacket avpkt;
+ int16_t *samples = NULL;
+ uint8_t *inbuf = NULL;
+ int inbuf_size = 0;
+ int len = 0, frame_size_ptr = 0;
+ uint8_t *meta_buf = NULL;
+ DeviceMemEntry *elem = NULL;
+ uint8_t *tempbuf = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ meta_buf = s->vaddr + ((ctx_id - 1) * CODEC_META_DATA_SIZE);
+ meta_buf += 8; // skipped header.
+
+ memcpy(&inbuf_size, meta_buf, sizeof(inbuf_size));
+ TRACE("before decoding audio. inbuf_size: %d\n", inbuf_size);
+
+ elem = (DeviceMemEntry *)data_buf;
+ if (elem && elem->buf) {
+ inbuf = elem->buf;
+ } else if (elem) {
+ inbuf_size = 0;
+ TRACE("decode_audio. no input buffer.\n");
+ } else {
+ ERR("wrong input data\n");
+ return false;
+ }
+
+ av_init_packet(&avpkt);
+ avpkt.data = inbuf;
+ avpkt.size = inbuf_size;
+
+ avctx = s->context[ctx_id].avctx;
+ if (!avctx) {
+ ERR("[%s] %d of AVCodecContext is NULL!\n", __func__, ctx_id);
+ write_codec_decode_audio_data(0, 0, 0, -1, 0, meta_buf);
+ } else if (!avctx->codec) {
+ ERR("%d of AVCodec is NULL.\n", ctx_id);
+ write_codec_decode_audio_data(0, 0, 0, -1, 0, meta_buf);
+ } else {
+ frame_size_ptr = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ samples = av_mallocz(frame_size_ptr);
+ if (!samples) {
+ ERR("failed to allocate an outbuf of audio.\n");
+ len = -1;
+ } else {
+ len =
+ avcodec_decode_audio3(avctx, samples, &frame_size_ptr, &avpkt);
+
+ TRACE("audio. len %d, channel_layout %lld, frame_size %d\n",
+ len, avctx->channel_layout, frame_size_ptr);
+ }
+
+ write_codec_decode_audio_data(avctx->sample_rate, avctx->channels,
+ avctx->channel_layout, len,
+ frame_size_ptr, meta_buf);
+ }
+
+ if (len < 0) {
+ ERR("failed to decode audio. ctx_id: %d, len: %d\n", ctx_id, len);
+ frame_size_ptr = 0;
+ } else {
+ if (frame_size_ptr > 0) {
+ tempbuf = g_malloc0(frame_size_ptr);
+ if (!tempbuf) {
+ ERR("failed to allocate decoded audio buffer. "
+ "ctx_id: %d, outbuf_size: %d\n", ctx_id, frame_size_ptr);
+ } else {
+ memcpy(tempbuf, samples, frame_size_ptr);
+ }
+ av_free(samples);
+ }
+ }
+
+ maru_brill_codec_push_writequeue(s, tempbuf, frame_size_ptr, ctx_id, f_id);
+
+ TRACE("leave: %s\n", __func__);
+
+ return true;
+}
+
+static bool codec_encode_video(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx = NULL;
+ AVFrame *pict = NULL;
+ uint8_t *inbuf = NULL, *outbuf = NULL;
+ int inbuf_size, outbuf_size, len = 0;
+ int ret;
+ int64_t in_timestamp;
+
+ uint8_t *meta_buf = NULL;
+ DeviceMemEntry *elem = NULL;
+ uint8_t *tempbuf = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ meta_buf = s->vaddr + ((ctx_id - 1) * CODEC_META_DATA_SIZE);
+ meta_buf += 8; // skipped header.
+
+ memcpy(&inbuf_size, meta_buf, sizeof(inbuf_size));
+ memcpy(&in_timestamp, meta_buf + sizeof(inbuf_size), sizeof(in_timestamp));
+ TRACE("input buffer size: %d\n", inbuf_size);
+
+ elem = (DeviceMemEntry *)data_buf;
+ if (elem && elem->buf) {
+ inbuf = elem->buf;
+ } else if (elem) {
+ TRACE("encode_video. no input buffer.\n");
+ inbuf_size = 0;
+ } else {
+ ERR("wrong input data\n");
+ return false;
+ }
+
+ avctx = s->context[ctx_id].avctx;
+ pict = s->context[ctx_id].frame;
+ if (!avctx || !pict) {
+ ERR("%d of context or frame is NULL\n", ctx_id);
+ len = -1;
+ } else if (!avctx->codec) {
+ ERR("%d of AVCodec is NULL.\n", ctx_id);
+ len = -1;
+ } else {
+ TRACE("pixel format: %d inbuf: %p, picture data: %p\n",
+ avctx->pix_fmt, inbuf, pict->data[0]);
+
+ ret =
+ maru_brill_codec_get_picture_size((AVPicture *)pict, inbuf,
+ avctx->pix_fmt, avctx->width,
+ avctx->height, true);
+ if (ret < 0) {
+ ERR("after avpicture_fill, ret:%d\n", ret);
+ len = -1;
+ } else {
+ if (avctx->time_base.num == 0) {
+ pict->pts = AV_NOPTS_VALUE;
+ } else {
+ AVRational bq =
+ {1, (G_USEC_PER_SEC * G_GINT64_CONSTANT(1000))};
+ pict->pts = av_rescale_q(in_timestamp, bq, avctx->time_base);
+ }
+ TRACE("before encode video, ticks_per_frame:%d, pts:%lld\n",
+ avctx->ticks_per_frame, pict->pts);
+
+ outbuf_size =
+ (avctx->width * avctx->height * 6) + FF_MIN_BUFFER_SIZE;
+ outbuf = g_malloc0(outbuf_size);
+ if (!outbuf) {
+ ERR("failed to allocate a buffer of encoding video.\n");
+ len = -1;
+ } else {
+ len = avcodec_encode_video(avctx, outbuf, outbuf_size, pict);
+
+ TRACE("encode video! len:%d pts:%lld outbuf:%p outbuf size: %d\n",
+ len, pict->pts, outbuf, outbuf_size);
+ }
+ }
+ }
+
+ // write encoded video data
+ memcpy(meta_buf, &len, sizeof(len));
+ if (len < 0) {
+ ERR("failed to encode video. len: %d\n", len);
+ } else {
+ tempbuf = g_malloc0(len);
+ if (!tempbuf) {
+ ERR("failed to allocate an element of writequeue.\n");
+ } else {
+ memcpy(tempbuf, outbuf, len);
+ }
+ }
+
+ if (outbuf) {
+ TRACE("release encoded output buffer. %p\n", outbuf);
+ g_free(outbuf);
+ }
+
+ maru_brill_codec_push_writequeue(s, tempbuf, len, ctx_id, f_id);
+
+ TRACE("leave: %s\n", __func__);
+ return true;
+}
+
+static bool codec_encode_audio(MaruBrillCodecState *s, int ctx_id, int f_id, void *data_buf)
+{
+ AVCodecContext *avctx;
+ uint8_t *inbuf = NULL, *outbuf = NULL;
+ int32_t inbuf_size, max_size;
+ int len = 0;
+ uint8_t *meta_buf = NULL;
+
+ DeviceMemEntry *elem = NULL;
+ uint8_t *tempbuf = NULL;
+
+ TRACE("enter: %s\n", __func__);
+
+ meta_buf = s->vaddr + ((ctx_id - 1) * CODEC_META_DATA_SIZE);
+ meta_buf += 8; // skipped header.
+
+ memcpy(&inbuf_size, meta_buf, sizeof(inbuf_size));
+ memcpy(&max_size, meta_buf + sizeof(inbuf_size), sizeof(max_size));
+ TRACE("encoding audio. in_size: %d, max_size: %d\n", inbuf_size, max_size);
+
+ elem = (DeviceMemEntry *)data_buf;
+ if (elem && elem->buf) {
+ inbuf = elem->buf;
+ } else if (elem) {
+ TRACE("no input buffer to encode audio.\n");
+ inbuf_size = 0;
+ } else {
+ ERR("wrong input data\n");
+ return false;
+ }
+
+ avctx = s->context[ctx_id].avctx;
+ if (!avctx) {
+ ERR("[%s] %d of Context is NULL!\n", __func__, ctx_id);
+ } else if (!avctx->codec) {
+ ERR("%d of AVCodec is NULL.\n", ctx_id);
+ } else {
+ outbuf = g_malloc0(max_size + FF_MIN_BUFFER_SIZE);
+ if (!outbuf) {
+ ERR("failed to allocate a buffer of encoding audio.\n");
+ len = -1;
+ } else {
+ len =
+ avcodec_encode_audio(avctx, outbuf, max_size, (short *)inbuf);
+ TRACE("after encoding audio. len: %d\n", len);
+ }
+ }
+
+ // write encoded audio data
+ memcpy(meta_buf, &len, sizeof(len));
+ if (len < 0) {
+ ERR("failed to encode audio. ctx_id: %d len: %d\n", ctx_id, len);
+ } else {
+ tempbuf = g_malloc0(len);
+ if (!tempbuf) {
+ ERR("encode_audio. failed to allocate temporary buffer.\n");
+ } else {
+ memcpy(tempbuf, outbuf, len);
+ }
+ }
+
+ if (outbuf) {
+ av_free(outbuf);
+ }
+
+ maru_brill_codec_push_writequeue(s, tempbuf, len, ctx_id, f_id);
+
+ TRACE("[%s] leave:\n", __func__);
+ return true;
+}
+
+static AVCodecParserContext *maru_brill_codec_parser_init(AVCodecContext *avctx)
+{
+ AVCodecParserContext *parser = NULL;
+
+ if (!avctx) {
+ ERR("context is NULL\n");
+ return NULL;
+ }
+
+ switch (avctx->codec_id) {
+ case CODEC_ID_MPEG4:
+ case CODEC_ID_VC1:
+ TRACE("not using parser.\n");
+ break;
+ case CODEC_ID_H264:
+ if (avctx->extradata_size == 0) {
+ TRACE("H.264 with no extradata, creating parser.\n");
+ parser = av_parser_init (avctx->codec_id);
+ }
+ break;
+ default:
+ parser = av_parser_init (avctx->codec_id);
+ if (parser) {
+ INFO("using parser. %d\n", avctx->codec_id);
+ }
+ break;
+ }
+
+ return parser;
+}
+
+//
+static void maru_brill_codec_bh_callback(void *opaque)
+{
+ MaruBrillCodecState *s = (MaruBrillCodecState *)opaque;
+
+ TRACE("enter: %s\n", __func__);
+
+ qemu_mutex_lock(&s->context_queue_mutex);
+ if (!QTAILQ_EMPTY(&codec_wq)) {
+ qemu_mutex_unlock(&s->context_queue_mutex);
+
+ TRACE("raise irq\n");
+ qemu_irq_raise(s->dev.irq[0]);
+ irq_raised = 1;
+ } else {
+ qemu_mutex_unlock(&s->context_queue_mutex);
+ TRACE("codec_wq is empty!!\n");
+ }
+
+ TRACE("leave: %s\n", __func__);
+}
+
+/*
+ * Codec Device APIs
+ */
+static uint64_t maru_brill_codec_read(void *opaque,
+ target_phys_addr_t addr,
+ unsigned size)
+{
+ MaruBrillCodecState *s = (MaruBrillCodecState *)opaque;
+ uint64_t ret = 0;
+
+ switch (addr) {
+ case CODEC_CMD_GET_THREAD_STATE:
+#if 0
+ if (s->thread_state) {
+ s->thread_state = CODEC_TASK_START;
+
+ qemu_mutex_lock(&s->context_queue_mutex);
+ if (!QTAILQ_EMPTY(&codec_wq)) {
+ ret = CODEC_TASK_END;
+ }
+ qemu_mutex_unlock(&s->context_queue_mutex);
+ }
+#endif
+ qemu_mutex_lock(&s->context_queue_mutex);
+ if (irq_raised) {
+ ret = CODEC_TASK_END;
+ qemu_irq_lower(s->dev.irq[0]);
+ irq_raised = 0;
+ }
+ qemu_mutex_unlock(&s->context_queue_mutex);
+
+ TRACE("get thread_state. ret: %d\n", ret);
+ break;
+
+ case CODEC_CMD_GET_CTX_FROM_QUEUE:
+ {
+ DeviceMemEntry *head = NULL;
+
+ qemu_mutex_lock(&s->context_queue_mutex);
+ head = QTAILQ_FIRST(&codec_wq);
+ if (head) {
+ ret = head->ctx_id;
+ QTAILQ_REMOVE(&codec_wq, head, node);
+ entry[ret] = head;
+ TRACE("get a elem from codec_wq. 0x%x\n", head);
+ } else {
+ ret = 0;
+ }
+ qemu_mutex_unlock(&s->context_queue_mutex);
+
+ TRACE("get a head from a writequeue. head: %x\n", ret);
+ }
+ break;
+
+ case CODEC_CMD_GET_VERSION:
+ ret = CODEC_VERSION;
+ TRACE("codec version: %d\n", ret);
+ break;
+
+ case CODEC_CMD_GET_ELEMENT:
+ ret = maru_brill_codec_query_list(s);
+ break;
+
+ case CODEC_CMD_GET_CONTEXT_INDEX:
+ ret = maru_brill_codec_get_context_index(s);
+ TRACE("get context index: %d\n", ret);
+ break;
+
+ default:
+ ERR("no avaiable command for read. %d\n", addr);
+ }
+
+ return ret;
+}
+
+static void maru_brill_codec_write(void *opaque, target_phys_addr_t addr,
+ uint64_t value, unsigned size)
+{
+ MaruBrillCodecState *s = (MaruBrillCodecState *)opaque;
+
+ switch (addr) {
+ case CODEC_CMD_API_INDEX:
+ TRACE("set codec_cmd value: %d\n", value);
+ s->ioparam.api_index = value;
+ maru_brill_codec_wakeup_threads(s, value);
+ break;
+
+ case CODEC_CMD_CONTEXT_INDEX:
+ TRACE("set context_index value: %d\n", value);
+ s->ioparam.ctx_index = value;
+ break;
+
+ case CODEC_CMD_FILE_INDEX:
+ TRACE("set file_index value: 0x%x\n", value);
+ s->ioparam.file_index = value;
+ break;
+
+ case CODEC_CMD_DEVICE_MEM_OFFSET:
+ TRACE("set mem_offset value: 0x%x\n", value);
+ s->ioparam.mem_offset = value;
+ break;
+
+ case CODEC_CMD_RELEASE_CONTEXT:
+ maru_brill_codec_release_context(s, (int32_t)value);
+ break;
+
+ case CODEC_CMD_GET_DATA_FROM_QUEUE:
+ maru_brill_codec_pop_writequeue(s, (uint32_t)value);
+ break;
+
+ default:
+ ERR("no available command for write. %d\n", addr);
+ }
+}
+
+static const MemoryRegionOps maru_brill_codec_mmio_ops = {
+ .read = maru_brill_codec_read,
+ .write = maru_brill_codec_write,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ .unaligned = false
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+static int maru_brill_codec_initfn(PCIDevice *dev)
+{
+ MaruBrillCodecState *s = DO_UPCAST(MaruBrillCodecState, dev, dev);
+ uint8_t *pci_conf = s->dev.config;
+
+ INFO("device initialization.\n");
+ memset(&s->ioparam, 0, sizeof(CodecParam));
+
+ qemu_mutex_init(&s->context_mutex);
+ qemu_mutex_init(&s->context_queue_mutex);
+ qemu_mutex_init(&s->ioparam_queue_mutex);
+
+ maru_brill_codec_get_cpu_cores();
+ maru_brill_codec_threads_create(s);
+
+ maru_brill_codec_pixfmt_info_init();
+
+ // register a function to qemu bottom-halves to switch context.
+ s->codec_bh = qemu_bh_new(maru_brill_codec_bh_callback, s);
+
+ pci_config_set_interrupt_pin(pci_conf, 1);
+
+ memory_region_init_ram(&s->vram, "maru_brill_codec.vram", CODEC_MEM_SIZE);
+ s->vaddr = (uint8_t *)memory_region_get_ram_ptr(&s->vram);
+
+ memory_region_init_io(&s->mmio, &maru_brill_codec_mmio_ops, s,
+ "maru_brill_codec.mmio", CODEC_REG_SIZE);
+
+ pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
+ pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
+
+ return 0;
+}
+
+static void maru_brill_codec_exitfn(PCIDevice *dev)
+{
+ MaruBrillCodecState *s = DO_UPCAST(MaruBrillCodecState, dev, dev);
+ INFO("device exit\n");
+
+ qemu_mutex_destroy(&s->context_mutex);
+ qemu_mutex_destroy(&s->context_queue_mutex);
+ qemu_mutex_destroy(&s->ioparam_queue_mutex);
+
+ qemu_bh_delete(s->codec_bh);
+
+ memory_region_destroy(&s->vram);
+ memory_region_destroy(&s->mmio);
+}
+
+static void maru_brill_codec_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->init = maru_brill_codec_initfn;
+ k->exit = maru_brill_codec_exitfn;
+ k->vendor_id = PCI_VENDOR_ID_TIZEN;
+ k->device_id = PCI_DEVICE_ID_VIRTUAL_BRILL_CODEC;
+ k->class_id = PCI_CLASS_OTHERS;
+ dc->desc = "Virtual new codec device for Tizen emulator";
+}
+
+static TypeInfo codec_device_info = {
+ .name = CODEC_DEVICE_NAME,
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(MaruBrillCodecState),
+ .class_init = maru_brill_codec_class_init,
+};
+
+static void codec_register_types(void)
+{
+ type_register_static(&codec_device_info);
+}
+
+type_init(codec_register_types)
+
+int maru_brill_codec_pci_device_init(PCIBus *bus)
+{
+ INFO("device create.\n");
+ pci_create_simple(bus, -1, CODEC_DEVICE_NAME);
+ return 0;
+}
--- /dev/null
+/*
+ * Virtual Codec device
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Kitae Kim <kt920.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "hw.h"
+#include "kvm.h"
+#include "pci.h"
+#include "pci_ids.h"
+#include "osutil.h"
+#include "qemu-common.h"
+#include "qemu-thread.h"
+
+#include "libavformat/avformat.h"
+#include "maru_device_ids.h"
+#include "tizen/src/debug_ch.h"
+
+#define CODEC_CONTEXT_MAX 1024
+
+/*
+ * Codec Device Structures
+ */
+typedef struct CodecParam {
+ int32_t api_index;
+ int32_t ctx_index;
+ uint32_t file_index;
+ uint32_t mem_offset;
+} CodecParam;
+
+struct video_data {
+ int32_t width;
+ int32_t height;
+ int32_t fps_n;
+ int32_t fps_d;
+ int32_t par_n;
+ int32_t par_d;
+ int32_t pix_fmt;
+ int32_t bpp;
+ int32_t ticks_per_frame;
+};
+
+struct audio_data {
+ int32_t channels;
+ int32_t sample_rate;
+ int32_t block_align;
+ int32_t depth;
+ int32_t sample_fmt;
+ int32_t frame_size;
+ int32_t bits_per_smp_fmt;
+ int64_t channel_layout;
+};
+
+typedef struct CodecContext {
+ AVCodecContext *avctx;
+ AVFrame *frame;
+ AVCodecParserContext *parser_ctx;
+ uint8_t *parser_buf;
+ uint16_t parser_use;
+ uint16_t occupied;
+ uint32_t file_index;
+ bool opened;
+} CodecContext;
+
+typedef struct CodecThreadPool {
+ QemuThread *threads;
+ QemuMutex mutex;
+ QemuCond cond;
+} CodecThreadPool;
+
+
+typedef struct MaruBrillCodecState {
+ PCIDevice dev;
+
+ uint8_t *vaddr;
+ MemoryRegion vram;
+ MemoryRegion mmio;
+
+ QEMUBH *codec_bh;
+ QemuMutex context_mutex;
+ QemuMutex context_queue_mutex;
+ QemuMutex ioparam_queue_mutex;
+
+ CodecThreadPool threadpool;
+ uint32_t thread_state;
+ uint8_t is_thread_running;
+
+ CodecContext context[CODEC_CONTEXT_MAX];
+ CodecParam ioparam;
+} MaruBrillCodecState;
+
+enum codec_io_cmd {
+ CODEC_CMD_API_INDEX = 0x28,
+ CODEC_CMD_CONTEXT_INDEX = 0x2C,
+ CODEC_CMD_FILE_INDEX = 0x30,
+ CODEC_CMD_DEVICE_MEM_OFFSET = 0x34,
+ CODEC_CMD_GET_THREAD_STATE = 0x38,
+ CODEC_CMD_GET_CTX_FROM_QUEUE = 0x3C,
+ CODEC_CMD_GET_DATA_FROM_QUEUE = 0x40,
+ CODEC_CMD_RELEASE_CONTEXT = 0x44,
+ CODEC_CMD_GET_VERSION = 0x50,
+ CODEC_CMD_GET_ELEMENT = 0x54,
+ CODEC_CMD_GET_CONTEXT_INDEX = 0x58,
+};
+
+enum codec_api_type {
+ CODEC_INIT = 0,
+ CODEC_DECODE_VIDEO,
+ CODEC_ENCODE_VIDEO,
+ CODEC_DECODE_AUDIO,
+ CODEC_ENCODE_AUDIO,
+ CODEC_PICTURE_COPY,
+ CODEC_DEINIT,
+ CODEC_FLUSH_BUFFERS,
+ };
+
+enum codec_type {
+ CODEC_TYPE_UNKNOWN = -1,
+ CODEC_TYPE_DECODE,
+ CODEC_TYPE_ENCODE,
+};
+
+enum thread_state {
+ CODEC_TASK_START = 0,
+ CODEC_TASK_END = 0x1f,
+};
+
+/*
+ * Codec Device Functions
+ */
+int maru_brill_codec_pci_device_init(PCIBus *bus);
static const char *dev_name = "/dev/video0";
static int v4l2_fd;
static int convert_trial;
+static int read_trial;
static int ready_count;
static int timeout_n;
switch (errno) {
case EAGAIN:
case EINTR:
- ERR("DQBUF error, try again: %s\n", strerror(errno));
+ ERR("DQBUF error, try again(trial=%d): %s\n",
+ read_trial, strerror(errno));
+ if (--read_trial == -1) {
+ ERR("Failed trying to dequeue buffer from device\n");
+ return -1;
+ }
return 0;
case EIO:
ERR("The v4l2_read() met the EIO\n");
return 0;
}
+#define MAX_CONVERT_TRIAL 10
+#define MAX_READ_TRIAL 30
static int __v4l2_streaming(MaruCamState *state)
{
fd_set fds;
}
/* clear the skip count for select time-out */
- if (timeout_n > 0) {
- timeout_n = 0;
- }
+ timeout_n = 0;
+ /* reset the read trial */
+ read_trial = MAX_READ_TRIAL;
+ /* reset the convert trial */
+ convert_trial = MAX_CONVERT_TRIAL;
return 0;
}
break;
}
- convert_trial = 10;
+ convert_trial = MAX_CONVERT_TRIAL;
+ read_trial = MAX_READ_TRIAL;
ready_count = 0;
timeout_n = 0;
has_success_frame = 0;
ERR("Failed to set video format: format(0x%x), width:height(%d:%d), "
"errstr(%s)\n", dst_fmt.fmt.pix.pixelformat, dst_fmt.fmt.pix.width,
dst_fmt.fmt.pix.height, strerror(errno));
+ v4l2_close(v4l2_fd);
+ v4l2_fd = 0;
param->errCode = errno;
return;
}
for (ctx_idx = 0; ctx_idx < CODEC_CONTEXT_MAX; ctx_idx++) {
if (s->codec_ctx[ctx_idx].file_index == value) {
TRACE("reset %d context\n", ctx_idx);
- qemu_mutex_unlock(&s->thread_mutex);
- qemu_av_free(s, ctx_idx);
- qemu_mutex_lock(&s->thread_mutex);
+ qemu_mutex_unlock(&s->thread_mutex);
+ qemu_av_free(s, ctx_idx);
+ qemu_mutex_lock(&s->thread_mutex);
s->codec_ctx[ctx_idx].avctx_use = false;
break;
}
pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
+ /* JPEG YUV */
+ pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
+
+ pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
+ pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
+ pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
+
/* RGB formats */
pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
+
+ pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
+ pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
}
static uint8_t *qemu_malloc_avpicture (int picture_size)
case PIX_FMT_YUV444P:
case PIX_FMT_YUV410P:
case PIX_FMT_YUV411P:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUVJ422P:
+ case PIX_FMT_YUVJ444P:
stride = ROUND_UP_4(width);
h2 = ROUND_UP_X(height, pinfo->y_chroma_shift);
size = stride * h2;
picture->linesize[1] = stride2;
picture->linesize[2] = stride2;
picture->linesize[3] = 0;
- TRACE("planes %d %d %d", 0, size, size + size2);
- TRACE("strides %d %d %d", stride, stride2, stride2);
+ TRACE("planes %d %d %d\n", 0, size, size + size2);
+ TRACE("strides %d %d %d\n", stride, stride2, stride2);
+ break;
+ case PIX_FMT_YUVA420P:
+ stride = ROUND_UP_4 (width);
+ h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
+ size = stride * h2;
+ w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
+ stride2 = ROUND_UP_4 (w2);
+ h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
+ size2 = stride2 * h2;
+ fsize = 2 * size + 2 * size2;
+ TRACE("stride %d, stride2 %d, size %d, size2 %d, fsize %d\n",
+ stride, stride2, size, size2, fsize);
+ if (!encode && !ptr) {
+ ptr = qemu_malloc_avpicture(fsize);
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = picture->data[0] + size;
+ picture->data[2] = picture->data[1] + size2;
+ picture->data[3] = picture->data[2] + size2;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = stride2;
+ picture->linesize[2] = stride2;
+ picture->linesize[3] = stride;
+ TRACE("planes %d %d %d %d\n", 0, size, size + size2, size + 2 * size2);
+ TRACE("strides %d %d %d %d\n", stride, stride2, stride2, stride);
break;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
stride = ROUND_UP_4 (width * 3);
fsize = stride * height;
- TRACE("stride: %d, size: %d\n", stride, fsize);
+ TRACE("stride: %d, fsize: %d\n", stride, fsize);
if (!encode && !ptr) {
ptr = qemu_malloc_avpicture(fsize);
}
case PIX_FMT_RGB32:
stride = width * 4;
fsize = stride * height;
- TRACE("stride: %d, size: %d\n", stride, fsize);
+ TRACE("stride: %d, fsize: %d\n", stride, fsize);
if (!encode && !ptr) {
ptr = qemu_malloc_avpicture(fsize);
}
break;
case PIX_FMT_RGB555:
case PIX_FMT_RGB565:
+ case PIX_FMT_YUYV422:
+ case PIX_FMT_UYVY422:
stride = ROUND_UP_4 (width * 2);
fsize = stride * height;
- TRACE("stride: %d, size: %d\n", stride, fsize);
+ TRACE("stride: %d, fsize: %d\n", stride, fsize);
+ if (!encode && !ptr) {
+ ptr = qemu_malloc_avpicture(fsize);
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_UYYVYY411:
+ /* FIXME, probably not the right stride */
+ stride = ROUND_UP_4 (width);
+ size = stride * height;
+ fsize = size + size / 2;
+ TRACE("stride %d, size %d, fsize %d\n", stride, size, fsize);
+ if (!encode && !ptr) {
+ ptr = qemu_malloc_avpicture(fsize);
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = width + width / 2;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_GRAY8:
+ stride = ROUND_UP_4 (width);
+ fsize = stride * height;
+ TRACE("stride %d, fsize %d\n", stride, fsize);
+ if (!encode && !ptr) {
+ ptr = qemu_malloc_avpicture(fsize);
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = NULL;
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 0;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
+ case PIX_FMT_MONOWHITE:
+ case PIX_FMT_MONOBLACK:
+ stride = ROUND_UP_4 ((width + 7) >> 3);
+ fsize = stride * height;
+ TRACE("stride %d, fsize %d\n", stride, fsize);
if (!encode && !ptr) {
ptr = qemu_malloc_avpicture(fsize);
}
picture->linesize[2] = 0;
picture->linesize[3] = 0;
break;
+ case PIX_FMT_PAL8:
+ /* already forced to be with stride, so same result as other function */
+ stride = ROUND_UP_4 (width);
+ size = stride * height;
+ fsize = size + 256 * 4;
+ TRACE("stride %d, size %d, fsize %d\n", stride, size, fsize);
+ if (!encode && !ptr) {
+ ptr = qemu_malloc_avpicture(fsize);
+ }
+ picture->data[0] = ptr;
+ picture->data[1] = ptr + size; /* palette is stored here as 256 32 bit words */
+ picture->data[2] = NULL;
+ picture->data[3] = NULL;
+ picture->linesize[0] = stride;
+ picture->linesize[1] = 4;
+ picture->linesize[2] = 0;
+ picture->linesize[3] = 0;
+ break;
default:
picture->data[0] = NULL;
picture->data[1] = NULL;
if (codec->type == AVMEDIA_TYPE_AUDIO) {
s->codec_ctx[ctx_index].mem_index = s->codec_param.mem_index;
TRACE("set mem_index: %d into ctx_index: %d.\n",
- s->codec_ctx[ctx_index].mem_index, ctx_index);
+ s->codec_ctx[ctx_index].mem_index, ctx_index);
}
#if 0
* SungMin Ha <sungmin82.ha@samsung.com>
* JiHye Kim <jihye1128.kim@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
+ * DaiYoung Kim <daiyoung777.kim@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
* DongKyun Yun
* DoHyung Hong
#define PCI_DEVICE_ID_VIRTIO_KEYBOARD 0x1020
#define PCI_DEVICE_ID_VIRTIO_ESM 0x1024
#define PCI_DEVICE_ID_VIRTIO_HWKEY 0x1028
+#define PCI_DEVICE_ID_VIRTUAL_BRILL_CODEC 0x1040
/* Virtio */
/*
MULTI_DEBUG_CHANNEL(qemu, hwkey);
#define DEVICE_NAME "virtio-hwkey"
+#define MAX_BUF_COUNT 64
+static int vqidx = 0;
/*
* HW key event queue
QTAILQ_ENTRY(ElementEntry) node;
} ElementEntry;
-static ElementEntry _elem_buf[10];
static QTAILQ_HEAD(, ElementEntry) elem_queue =
QTAILQ_HEAD_INITIALIZER(elem_queue);
static unsigned int elem_queue_cnt; /* elem_queue */
VirtIOHwKey *vhk;
+VirtQueueElement elem_vhk;
/* lock for between communication thread and IO thread */
static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t elem_mutex = PTHREAD_MUTEX_INITIALIZER;
void maru_hwkey_event(int event_type, int keycode)
{
static void maru_virtio_hwkey_handle(VirtIODevice *vdev, VirtQueue *vq)
{
int virt_sg_index = 0;
- ElementEntry *elem_entry = NULL;
TRACE("maru_virtio_hwkey_handle\n");
TRACE("virtqueue is empty\n");
return;
}
-
- while (true) {
- elem_entry = &(_elem_buf[elem_ringbuf_cnt % 10]);
- elem_ringbuf_cnt++;
-
- virt_sg_index = virtqueue_pop(vhk->vq, &elem_entry->elem);
- if (virt_sg_index == 0) {
- elem_ringbuf_cnt--;
- break;
- } else if (virt_sg_index < 0) {
- ERR("virtqueue is broken\n");
- elem_ringbuf_cnt--;
- return;
- }
-
- pthread_mutex_lock(&elem_mutex);
-
- elem_entry->el_index = ++elem_queue_cnt;
- elem_entry->sg_index = (unsigned int)virt_sg_index;
-
- /* save VirtQueueElement */
- QTAILQ_INSERT_TAIL(&elem_queue, elem_entry, node);
- /* call maru_virtio_hwkey_notify */
- qemu_bh_schedule(vhk->bh);
-
- pthread_mutex_unlock(&elem_mutex);
- }
+ /* Get a queue buffer which is written by guest side. */
+ do {
+ virt_sg_index = virtqueue_pop(vq, &elem_vhk);
+ TRACE("virtqueue pop.\n");
+ } while (virt_sg_index < MAX_BUF_COUNT);
}
void maru_virtio_hwkey_notify(void)
{
HwKeyEventEntry *event_entry = NULL;
- ElementEntry *elem_entry = NULL;
- VirtQueueElement *element = NULL;
- void *vbuf = NULL;
TRACE("maru_virtio_hwkey_notify\n");
break;
}
- elem_entry = QTAILQ_FIRST(&elem_queue);
-
- if ( elem_entry->sg_index > 0) {
- /* get hwkey event from host queue */
- event_entry = QTAILQ_FIRST(&events_queue);
+ /* get hwkey event from host queue */
+ event_entry = QTAILQ_FIRST(&events_queue);
- TRACE("hwkey(%d) : keycode=%d, event_type=%d | \
- event_queue_cnt=%d\n",
- event_entry->index,
+ printf("keycode=%d, event_type=%d, event_queue_cnt=%d, vqidx=%d\n",
event_entry->hwkey.keycode, event_entry->hwkey.event_type,
- event_queue_cnt);
+ event_queue_cnt, vqidx);
- element = &elem_entry->elem;
- vbuf = element->in_sg[elem_entry->sg_index - 1].iov_base;
-
- /* copy event into virtio buffer */
- memcpy(vbuf, &(event_entry->hwkey), sizeof(EmulHwKeyEvent));
-
- virtqueue_push(vhk->vq, element, sizeof(EmulHwKeyEvent));
- virtio_notify(&vhk->vdev, vhk->vq);
+ /* copy event into virtio buffer */
+ memcpy(elem_vhk.in_sg[vqidx++].iov_base, &(event_entry->hwkey), sizeof(EmulHwKeyEvent));
+ if (vqidx == MAX_BUF_COUNT) {
+ vqidx = 0;
}
+ virtqueue_push(vhk->vq, &elem_vhk, sizeof(EmulHwKeyEvent));
+ virtio_notify(&vhk->vdev, vhk->vq);
+
pthread_mutex_lock(&event_mutex);
/* remove host event */
VirtIODevice *maru_virtio_hwkey_init(DeviceState *dev)
{
INFO("initialize the hwkey device\n");
+ vqidx = 0;
vhk = (VirtIOHwKey *)virtio_common_init(DEVICE_NAME,
VIRTIO_ID_HWKEY, 0 /*config_size*/, sizeof(VirtIOHwKey));
}
vhk->vdev.get_features = virtio_hwkey_get_features;
- vhk->vq = virtio_add_queue(&vhk->vdev, 64, maru_virtio_hwkey_handle);
+ vhk->vq = virtio_add_queue(&vhk->vdev, MAX_BUF_COUNT, maru_virtio_hwkey_handle);
vhk->qdev = dev;
#include "console.h"
#include "maru_virtio_touchscreen.h"
#include "maru_device_ids.h"
+#include "emul_state.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, touchscreen);
pthread_mutex_lock(&event_mutex);
- entry->index = ++event_queue_cnt; // 1 ~
+ entry->index = ++event_queue_cnt; /* 1 ~ */
QTAILQ_INSERT_TAIL(&events_queue, entry, node);
}
}
+static void virtio_touchscreen_get_config(
+ VirtIODevice *vdev, uint8_t *config_data)
+{
+ int max_trkid = 10;
+ INFO("virtio_touchscreen_get_config\n");
+
+ max_trkid = get_emul_max_touch_point();
+ memcpy(config_data, &max_trkid, 4);
+}
+
+static void virtio_touchscreen_set_config(
+ VirtIODevice *vdev, const uint8_t *config_data)
+{
+ /* do nothing */
+}
+
static uint32_t virtio_touchscreen_get_features(
VirtIODevice *vdev, uint32_t request_features)
{
- // TODO:
+ /* do nothing */
+
return request_features;
}
INFO("initialize the touchscreen device\n");
ts = (TouchscreenState *)virtio_common_init(DEVICE_NAME,
- VIRTIO_ID_TOUCHSCREEN, 0 /*config_size*/, sizeof(TouchscreenState));
+ VIRTIO_ID_TOUCHSCREEN, 4, sizeof(TouchscreenState));
if (ts == NULL) {
ERR("failed to initialize the touchscreen device\n");
return NULL;
}
+ ts->vdev.get_config = virtio_touchscreen_get_config;
+ ts->vdev.set_config = virtio_touchscreen_set_config;
ts->vdev.get_features = virtio_touchscreen_get_features;
- ts->vq = virtio_add_queue(&ts->vdev, 64, maru_virtio_touchscreen_handle);
+ ts->vq = virtio_add_queue(&ts->vdev, 64, maru_virtio_touchscreen_handle);
ts->qdev = dev;
/* reset the counters */
#include <stdlib.h>
#include <assert.h>
#include <string.h>
-#include <sys/types.h> // for pid_t
+#include <stdint.h>
+#include <sys/types.h> // for pid_t
#include "qemu-common.h"
*/
#include "tizen/src/debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, opengl);
-#define DEBUGF TRACE
+#define DEBUGF TRACE
#define GL_GLEXT_PROTOTYPES
#define GLX_GLXEXT_PROTOTYPES
#include "range_alloc.h"
#include "gloffscreen.h"
-
/** Misc X11/GLX defines - we don't want to include the whole files for these
* as we need them on Windows too */
typedef int Bool;
const Bool False = 0;
typedef struct __GLXFBConfigRec GLXFBConfig;
struct __GLXFBConfigRec {
- int formatFlags;
+ int formatFlags;
};
// #defines from glx.h
/* We'll say the XVisual Id is actually just an index into here */
const GLXFBConfig FBCONFIGS[] = {
- {GLO_FF_ALPHA|GLO_FF_BITS_32},
- {GLO_FF_ALPHA|GLO_FF_BITS_32|GLO_FF_DEPTH_24},
- {GLO_FF_ALPHA|GLO_FF_BITS_32|GLO_FF_DEPTH_24|GLO_FF_STENCIL_8},
+ {GLO_FF_ALPHA | GLO_FF_BITS_32},
+ {GLO_FF_ALPHA | GLO_FF_BITS_32 | GLO_FF_DEPTH_24},
+ {GLO_FF_ALPHA | GLO_FF_BITS_32 | GLO_FF_DEPTH_24 | GLO_FF_STENCIL_8},
/*
{GLO_FF_BITS_32},
{GLO_FF_BITS_32|GLO_FF_DEPTH_24},
#define FAKE_GL_VERSION "1.4"
#define FAKE_GL_MAJOR 1
-
#define FAKE_GLX_VENDOR "Qemu"
#define FAKE_GLX_VERSION_STRING "1.2"
#define FAKE_GLX_VERSION_MAJOR 1
#define FAKE_GLX_VERSION_MINOR 2
-void *g_malloc(size_t size);
-void *g_realloc(void *ptr, size_t size);
-void g_free(void *ptr);
-
/*#define glGetError() 0*/
+#ifdef WIN32
+# define CCONV _stdcall /* DLL entry points are WINAPI */
+#else
+# define CCONV
+#endif
+
#define GET_EXT_PTR(type, funcname, args_decl) \
static int detect_##funcname = 0; \
- static type(*ptr_func_##funcname)args_decl = NULL; \
+ static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
if (detect_##funcname == 0) \
{ \
detect_##funcname = 1; \
- ptr_func_##funcname = (type(*)args_decl)glo_getprocaddress((const char*)#funcname); \
+ ptr_func_##funcname = (type CCONV (*)args_decl)glo_getprocaddress((const char*)#funcname); \
assert (ptr_func_##funcname); \
}
#define GET_EXT_PTR_NO_FAIL(type, funcname, args_decl) \
static int detect_##funcname = 0; \
- static type(*ptr_func_##funcname)args_decl = NULL; \
+ static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
if (detect_##funcname == 0) \
{ \
detect_##funcname = 1; \
- ptr_func_##funcname = (type(*)args_decl)glo_getprocaddress((const char*)#funcname); \
+ ptr_func_##funcname = (type CCONV (*)args_decl)glo_getprocaddress((const char*)#funcname); \
}
#ifndef WIN32
static void *get_glu_ptr(const char *name)
{
- static void *handle = (void *) -1;
+ static void *handle = (void *)-1;
- if (handle == (void *) -1) {
+ if (handle == (void *)-1) {
#ifndef WIN32
handle = dlopen("libGLU.so", RTLD_LAZY);
if (!handle)
DEBUGF("can't load libGLU.so : %s\n", dlerror());
#else
- handle = (void *) LoadLibrary("glu32.dll");
+ handle = (void *)LoadLibrary("glu32.dll");
if (!handle)
DEBUGF("can't load glu32.dll\n");
#endif
#define GET_GLU_PTR(type, funcname, args_decl) \
static int detect_##funcname = 0; \
- static type(*ptr_func_##funcname)args_decl = NULL; \
+ static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
if (detect_##funcname == 0) \
{ \
detect_##funcname = 1; \
- ptr_func_##funcname = (type(*)args_decl)get_glu_ptr(#funcname); \
+ ptr_func_##funcname = (type CCONV (*)args_decl)get_glu_ptr(#funcname); \
}
int display_function_call = 0;
#define MAX_CLIENT_STATE_STACK_SIZE 16
-typedef void *ClientGLXDrawable;
+typedef uint32_t ClientGLXDrawable;
typedef struct GLState GLState;
};
enum {
- SURFACE_PENDING, /* Created with light-weight context */
- SURFACE_ACTIVE, /* Ready after MakeCurrent */
+ SURFACE_PENDING, /* Created with light-weight context */
+ SURFACE_ACTIVE, /* Ready after MakeCurrent */
};
typedef struct QGloSurface {
GLState *glstate;
GloSurface *surface;
- ClientGLXDrawable *client_drawable;
- int type; /* window, pixmap or pbuffer */
+ ClientGLXDrawable client_drawable;
+ int type; /* window, pixmap or pbuffer */
int ready;
- int status;
+ int status;
int ref;
- QTAILQ_ENTRY(QGloSurface) next;
+ QTAILQ_ENTRY(QGloSurface) next;
} QGloSurface;
#define MAX_PIXMAP_TEXTURE 32
ClientGLXDrawable drawable;
} PixmapTexture;
+typedef struct ClientTabValues {
+ unsigned int count;
+ unsigned int *values;
+} ClientTabValues;
+
struct GLState {
int ref;
int fake_ctxt;
int fake_shareList;
- GloContext *context; // context (owned by this)
- QGloSurface *current_qsurface; // current rendering surface/drawable
- QTAILQ_HEAD(, QGloSurface) qsurfaces; // list of surfaces/drawables for
- // this context
+ GloContext *context; // context (owned by this)
+ QGloSurface *current_qsurface; // current rendering surface/drawable
+ QTAILQ_HEAD(, QGloSurface) qsurfaces; // list of surfaces/drawables for
+ // this context
void *vertexPointer;
void *normalPointer;
int clientStateSp;
int activeTextureIndex;
- unsigned int ownTabTextures[32768];
- unsigned int *tabTextures;
/* The mapping between the texture and pixmap used as texture */
PixmapTexture pixmapTextures[MAX_PIXMAP_TEXTURE];
unsigned int bindTexture2D;
+
+ ClientTabValues ownTabTextures;
+ ClientTabValues *tabTextures;
RangeAllocator ownTextureAllocator;
RangeAllocator *textureAllocator;
- unsigned int ownTabBuffers[32768];
- unsigned int *tabBuffers;
+ ClientTabValues ownTabBuffers;
+ ClientTabValues *tabBuffers;
RangeAllocator ownBufferAllocator;
RangeAllocator *bufferAllocator;
- unsigned int ownTabLists[32768];
- unsigned int *tabLists;
+ ClientTabValues ownTabLists;
+ ClientTabValues *tabLists;
RangeAllocator ownListAllocator;
RangeAllocator *listAllocator;
};
+struct GLCallStatInfo {
+ uint64_t n; // Number of time a function is called
+ uint64_t max; // Maximum number of ms spent here
+ uint64_t total; // Total number of ms spent here
+};
+
typedef struct {
ProcessStruct p;
QGloSurface **pending_qsurfaces;
int nb_qsurf;
+ /* Number of FB configs sets allocated on behalf of this process */
int nfbconfig;
+
+ /* Array of FB configs sets */
const GLXFBConfig *fbconfigs[MAX_FBCONFIG];
+
+ /* Number of FB configs per set */
int fbconfigs_max[MAX_FBCONFIG];
+
+ /* Total number of FB configs allocated on behalf of this process */
int nfbconfig_total;
int primitive;
int bufsize;
int bufstart;
arg_t *cmdbuf;
+
+ struct GLCallStatInfo stats[GL_N_CALLS];
} ProcessState;
static ProcessState processes[MAX_HANDLED_PROCESS];
-static char *strip_extensions(const char *avail, const char *ext[]) {
+static char *strip_extensions(const char *avail, const char *ext[])
+{
char *pos, *supported, *srcp;
supported = (char *)g_malloc(strlen(avail) + 2);
pos = supported;
- while(*ext) {
- srcp = (char*)avail;
- while((srcp = strstr(srcp, *ext))) {
+ while (*ext) {
+ srcp = (char *)avail;
+ while ((srcp = strstr(srcp, *ext))) {
int len = strlen(*ext);
- if(*(srcp+len) == ' ' || *(srcp+len) == '\0') {
+ if (*(srcp + len) == ' ' || *(srcp + len) == '\0') {
strcpy(pos, *ext);
pos += len;
- if(*(srcp+len) == ' ') {
+ if (*(srcp + len) == ' ') {
*pos = ' ';
pos++;
}
*pos = ' ';
*pos = '\0';
- return supported;
+ return supported;
}
+extern void vmgl_context_switch(ProcessStruct * p, int switch_gl_context);
+extern ProcessStruct *vmgl_get_process(pid_t pid);
+extern void gl_disconnect(ProcessState * process);
+extern int do_function_call(ProcessState * process, int func_number,
+ unsigned long *args, char *ret_string);
+
static const char *glx_ext_supported[] = {
"GLX_ARB_multisample",
0
};
-static char *supported_glx_extensions() {
+static char *supported_glx_extensions(void)
+{
static char *supported;
- if(!supported)
- supported = strip_extensions(glo_glXQueryExtensionsString(),
- glx_ext_supported);
+ if (!supported)
+ supported = strip_extensions(glo_glXQueryExtensionsString(),
+ glx_ext_supported);
return supported;
}
"GL_ARB_fragment_shader",
"GL_ARB_framebuffer_object",
"GL_ARB_half_float_pixel",
- "GL_ARB_map_buffer_range",
+ "GL_ARB_map_buffer_range",
"GL_ARB_occlusion_query",
"GL_ARB_pixel_buffer_object",
"GL_ARB_point_sprite",
"GL_ARB_shader_objects",
"GL_ARB_shading_language_100",
"GL_ARB_shading_language_120",
- "GL_ARB_sync",
+ "GL_ARB_sync",
"GL_ARB_texture_non_power_of_two",
"GL_ARB_texture_rectangle",
- "GL_ARB_vertex_array_bgra",
+ "GL_ARB_vertex_array_bgra",
"GL_ARB_vertex_array_object",
"GL_ARB_vertex_buffer_object",
"GL_ARB_vertex_program",
- "GL_ARB_vertex_shader,"
- "GL_EXT_abgr",
+ "GL_ARB_vertex_shader," "GL_EXT_abgr",
"GL_EXT_blend_equation_separate",
"GL_EXT_cull_vertex",
"GL_EXT_framebuffer_blit",
"GL_EXT_framebuffer_object",
- "GL_EXT_gpu_program_parameters",
- "GL_EXT_packed_depth_stencil",
+ "GL_EXT_gpu_program_parameters",
+ "GL_EXT_packed_depth_stencil",
"GL_EXT_pixel_buffer_object",
"GL_EXT_provoking_vertex",
"GL_EXT_shadow_funcs",
"GL_EXT_stencil_two_side",
- "GL_EXT_texture_cube_map",
- "GL_EXT_texture_env_dot3",
+ "GL_EXT_texture_cube_map",
+ "GL_EXT_texture_env_dot3",
"GL_EXT_texture_filter_anisotropic",
"GL_EXT_texture_rectangle",
"GL_EXT_texture_sRGB",
"GL_EXT_vertex_array_bgra",
"GL_3DFX_texture_compression_FXT1",
"GL_APPLE_client_storage",
- "GL_APPLE_vertex_array_object",
+ "GL_APPLE_vertex_array_object",
"GL_ATI_blend_equation_separate",
"GL_ATI_envmap_bumpmap",
"GL_ATI_texture_env_combine3",
"GL_IBM_multimode_draw_arrays",
"GL_IBM_rasterpos_clip",
"GL_IBM_texture_mirrored_repeat",
- "GL_INGR_blend_func_separate",
+ "GL_INGR_blend_func_separate",
"GL_MESA_pack_invert",
"GL_MESA_texture_signed_rgba",
"GL_MESA_ycbcr_texture",
0
};
-static char *compute_gl_extensions() {
+static char *compute_gl_extensions(void)
+{
static char *supported;
- if(!supported)
+ if (!supported)
supported = strip_extensions((const char *)glGetString(GL_EXTENSIONS),
gl_ext_supported);
return supported;
}
-static inline QGloSurface *get_qsurface_from_client_drawable(GLState *state, ClientGLXDrawable client_drawable) {
+static int alloc_space(ClientTabValues *tabValues, unsigned int client_value, int zero)
+{
+ ClientTabValues tv;
+
+ tv.values = tabValues->values;
+ tv.count = tabValues->count;
+
+ while (client_value >= tv.count) {
+ tv.count = (tv.count == 0) ? 4 : tv.count * 2;
+ }
+
+ if (tv.count != tabValues->count) {
+ DEBUGF("Reallocate array of %d uint\n", tv.count);
+ tv.values = g_realloc(tv.values, tv.count * sizeof(unsigned int));
+ if (zero)
+ memset(tv.values + tabValues->count, 0,
+ (tv.count - tabValues->count) * sizeof(unsigned int));
+ }
+
+ if (!tv.values) {
+ DEBUGF("Failed to allocate array of %d uint\n", tv.count);
+ return 0;
+ }
+
+ *tabValues = tv;
+
+ return 1;
+}
+
+static void free_space(ClientTabValues *tabValues, unsigned int client_value)
+{
+ if (client_value < tabValues->count) {
+ tabValues->values[client_value] = 0;
+ /* FIXME we should compact the tabValues data here */
+ } else {
+ DEBUGF("Tried to free client_value %d of %d\n", client_value, tabValues->count);
+ }
+}
+
+static inline QGloSurface *get_qsurface_from_client_drawable(GLState * state,
+ ClientGLXDrawable
+ client_drawable)
+{
QGloSurface *qsurface;
- if(state->current_qsurface->client_drawable == client_drawable)
+ if (state->current_qsurface
+ && state->current_qsurface->client_drawable == client_drawable)
return state->current_qsurface;
QTAILQ_FOREACH(qsurface, &state->qsurfaces, next) {
}
// This must always be called only on surfaces belonging to the current context
-static inline void render_surface(QGloSurface *qsurface, int bpp, int stride, char *buffer)
+static inline void render_surface(QGloSurface * qsurface, int bpp, int stride,
+ char *buffer)
{
int w, h;
- if(!qsurface->ready)
- return;
+ if (!qsurface->ready)
+ return;
glo_surface_get_size(qsurface->surface, &w, &h);
glo_surface_getcontents(qsurface->surface, stride, bpp, buffer);
}
+static void qsurface_pixmap_ref(QGloSurface * qsurface)
+{
+ if (!qsurface) {
+ DEBUGF("%s %p\n", __FUNCTION__, qsurface);
+ return;
+ }
+
+ if (qsurface->type != SURFACE_PIXMAP) {
+ DEBUGF("%s %p is not a pixmap\n", __FUNCTION__, qsurface);
+ return;
+ }
+
+ qsurface->ref++;
+ DEBUGF("%s %p references increased to %d\n", __FUNCTION__, qsurface,
+ qsurface->ref);
+}
+
+static void qsurface_pixmap_unref(QGloSurface * qsurface)
+{
+ if (!qsurface) {
+ DEBUGF("%s %p\n", __FUNCTION__, qsurface);
+ return;
+ }
+
+ if (qsurface->type != SURFACE_PIXMAP) {
+ DEBUGF("%s %p is not a pixmap\n", __FUNCTION__, qsurface);
+ return;
+ }
+
+ qsurface->ref--;
+ DEBUGF("%s %p references decreased to %d\n", __FUNCTION__, qsurface,
+ qsurface->ref);
+
+ if (qsurface->ref == 0) {
+ glo_surface_destroy(qsurface->surface);
+ g_free(qsurface);
+ DEBUGF("%s freed: %p\n", __FUNCTION__, qsurface);
+ }
+}
+
+static void state_set_current_surface(GLState * state, QGloSurface * qsurface)
+{
+ if (state->current_qsurface != NULL)
+ qsurface_pixmap_unref(state->current_qsurface);
+
+ if (qsurface != NULL)
+ qsurface_pixmap_ref(qsurface);
+
+ state->current_qsurface = qsurface;
+}
+
// This must always be called only on surfaces belonging to the current context
-static inline void resize_surface(ProcessState *process, QGloSurface *qsurface,
- int w, int h) {
+static inline void resize_surface(ProcessState * process,
+ QGloSurface * qsurface, int w, int h)
+{
GLState *glstate = qsurface->glstate;
GloSurface *old_surface = qsurface->surface;
GloSurface *surface;
qsurface->surface = surface;
// Client doesnt know surface is new - need to MakeCurrent
- if(process->current_state == qsurface->glstate) {
+ if (process->current_state == qsurface->glstate) {
glo_surface_makecurrent(qsurface->surface);
// set the viewport while the window size is changed. It is needed
// especially for the case that glViewport is not explicitly called
// in the first MakeCurrent when the window size is not known.
// It will not impact normal GL programs with glViewport set as
// programmers want.
- glViewport (0, 0, w, h);
- }
- else {
+ glViewport(0, 0, w, h);
+ } else {
DEBUGF("Error: Surface is not current! %p %p\n",
process->current_state,
process->current_state->current_qsurface);
}
glstate->current_qsurface->ready = 1;
- DEBUGF( "resize_done\n");
+ DEBUGF("resize_done\n");
}
-
-void init_process_tab()
+static void init_process_tab(void)
{
memset(processes, 0, sizeof(processes));
}
-#define ARG_TO_CHAR(x) (char)(x)
-#define ARG_TO_UNSIGNED_CHAR(x) (unsigned char)(x)
-#define ARG_TO_SHORT(x) (short)(x)
-#define ARG_TO_UNSIGNED_SHORT(x) (unsigned short)(x)
-#define ARG_TO_INT(x) (int)(x)
-#define ARG_TO_UNSIGNED_INT(x) (unsigned int)(x)
+#define ARG_TO_CHAR(x) (char)(long)(x)
+#define ARG_TO_UNSIGNED_CHAR(x) (unsigned char)(long)(x)
+#define ARG_TO_SHORT(x) (short)(long)(x)
+#define ARG_TO_UNSIGNED_SHORT(x) (unsigned short)(long)(x)
+#define ARG_TO_INT(x) (int)(long)(x)
+#define ARG_TO_UNSIGNED_INT(x) (unsigned int)(long)(x)
#define ARG_TO_FLOAT(x) (*(float*)&(x))
#define ARG_TO_DOUBLE(x) (*(double*)(x))
#include "server_stub.c"
-//typedef void *ClientGLXDrawable;
static inline ClientGLXDrawable to_drawable(arg_t arg)
{
#ifdef TARGET_X86_64
- if (arg > (unsigned long) -1) {
- DEBUGF( "GLXDrawable too big for this implementation\n");
+ if (arg > (unsigned long)-1) {
+ DEBUGF("GLXDrawable too big for this implementation\n");
exit(-1);
}
#endif
- return (void *) (unsigned long) arg;
+ return (ClientGLXDrawable) arg;
}
/* ---- */
/* Bind a qsurface to a context (GLState) */
-static void bind_qsurface(GLState *state,
- QGloSurface *qsurface)
+static void bind_qsurface(GLState * state, QGloSurface * qsurface)
{
- DEBUGF("%s qsurface %p qsurface->glstate %p new state %p\n", __FUNCTION__, qsurface, qsurface->glstate, state);
+ DEBUGF("%s qsurface %p qsurface->glstate %p new state %p\n", __FUNCTION__,
+ qsurface, qsurface->glstate, state);
qsurface->glstate = state;
- if ( qsurface->type == SURFACE_WINDOW )
- QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
+ if (qsurface->type == SURFACE_WINDOW)
+ QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
- state->current_qsurface = qsurface;
+ state_set_current_surface(state, qsurface);
}
/* Unbind a qsurface from a context (GLState) */
-static void unbind_qsurface(GLState *state,
- QGloSurface *qsurface)
+static void unbind_qsurface(GLState * state, QGloSurface * qsurface)
{
if (!state || !qsurface) {
- DEBUGF("%s invalid parameter, state %p, qsurface %p\n", __FUNCTION__, state, qsurface);
+ DEBUGF("%s invalid parameter, state %p, qsurface %p\n", __FUNCTION__,
+ state, qsurface);
return;
}
- DEBUGF("%s qsurface %p qsurface->glstate %p old state %p\n", __FUNCTION__, qsurface, qsurface->glstate, state);
+ DEBUGF("%s qsurface %p qsurface->glstate %p old state %p\n", __FUNCTION__,
+ qsurface, qsurface->glstate, state);
qsurface->glstate = NULL;
- if ( qsurface->type == SURFACE_WINDOW )
- QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
+ if (qsurface->type == SURFACE_WINDOW)
+ QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
- if ( state->current_qsurface == qsurface )
- state->current_qsurface = NULL;
+ if (state->current_qsurface == qsurface)
+ state_set_current_surface(state, NULL);
}
/* Find the qsurface with required drawable in all pixmap/pbuffer surfaces */
-QGloSurface* find_qsurface_from_client_drawable(ProcessState *process, ClientGLXDrawable client_drawable)
+static QGloSurface *find_qsurface_from_client_drawable(ProcessState * process,
+ ClientGLXDrawable
+ client_drawable)
{
int i;
QGloSurface *qsurface;
- for ( i = 0; i < process->nb_qsurf; i++ )
- {
+ for (i = 0; i < process->nb_qsurf; i++) {
qsurface = process->pending_qsurfaces[i];
- if ( qsurface && qsurface->client_drawable == client_drawable )
+ if (qsurface && qsurface->client_drawable == client_drawable)
return qsurface;
}
}
/* Make the appropriate qsurface current for a given client_drawable */
-static int set_current_qsurface(GLState *state,
+static int set_current_qsurface(GLState * state,
ClientGLXDrawable client_drawable)
{
QGloSurface *qsurface;
- if(state->current_qsurface && state->current_qsurface->client_drawable == client_drawable)
+ if (state->current_qsurface
+ && state->current_qsurface->client_drawable == client_drawable)
return 1;
QTAILQ_FOREACH(qsurface, &state->qsurfaces, next) {
- if(qsurface->client_drawable == client_drawable) {
- state->current_qsurface = qsurface;
- qsurface->glstate = state;
+ if (qsurface->client_drawable == client_drawable) {
+ state_set_current_surface(state, qsurface);
+ qsurface->glstate = state;
return 1;
}
}
- state->current_qsurface = NULL;
+ state_set_current_surface(state, NULL);
return 0;
}
/* */
-static int keep_drawable(ProcessState *process, ClientGLXDrawable drawable)
+static int keep_drawable(ProcessState * process, ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PENDING_DRAWABLE; i++)
- {
- if ( process->pending_drawables[i] == 0 )
- {
+ for (i = 0; i < MAX_PENDING_DRAWABLE; i++) {
+ if (process->pending_drawables[i] == 0) {
process->pending_drawables[i] = drawable;
return 1;
}
return 0;
}
-static int link_drawable(ProcessState *process, ClientGLXDrawable drawable)
+static int link_drawable(ProcessState * process, ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PENDING_DRAWABLE; i++ )
- {
- if ( process->pending_drawables[i] == drawable )
- {
+ for (i = 0; i < MAX_PENDING_DRAWABLE; i++) {
+ if (process->pending_drawables[i] == drawable) {
process->pending_drawables[i] = 0;
return 1;
}
* 1. Create one light-weight context just for surface creation.
* 2. Store this qsurface, and link it with right context when MakeCurrent
*/
-static void keep_qsurface(ProcessState *process, QGloSurface *qsurface)
+static void keep_qsurface(ProcessState * process, QGloSurface * qsurface)
{
process->pending_qsurfaces =
g_realloc(process->pending_qsurfaces,
- (process->nb_qsurf + 1) * sizeof(QGloSurface*));
+ (process->nb_qsurf + 1) * sizeof(QGloSurface *));
process->pending_qsurfaces[process->nb_qsurf] = qsurface;
process->nb_qsurf++;
}
-static int link_qsurface(ProcessState *process, GLState *glstate, ClientGLXDrawable client_drawable)
+static int link_qsurface(ProcessState * process, GLState * glstate,
+ ClientGLXDrawable client_drawable)
{
int i;
QGloSurface *qsurface;
- for ( i = 0; i < process->nb_qsurf; i++ )
- {
+ for (i = 0; i < process->nb_qsurf; i++) {
qsurface = process->pending_qsurfaces[i];
- if ( qsurface && qsurface->client_drawable == client_drawable )
- {
+ if (qsurface && qsurface->client_drawable == client_drawable) {
/* XXX:Current limitation is that each surface is binded to one
* context, and not accessible from another context. It's hard for
* glEGLImageTargetTexture2DOES implementation, in which we need
* */
#if 0
memmove(&process->pending_qsurfaces[i],
- &process->pending_qsurfaces[i+1],
- (process->nb_qsurf - i - 1) * sizeof(QGloSurface*));
+ &process->pending_qsurfaces[i + 1],
+ (process->nb_qsurf - i - 1) * sizeof(QGloSurface *));
#endif
- qsurface->ref = 1;
- if(qsurface->status == SURFACE_PENDING)
- {
- glo_surface_update_context(qsurface->surface, glstate->context, 1);
- qsurface->status = SURFACE_ACTIVE;
- }
- else
- {
- unbind_qsurface(qsurface->glstate, qsurface);
- glo_surface_update_context(qsurface->surface, glstate->context, 0);
-
- }
+ if (qsurface->type != SURFACE_PIXMAP) {
+ DEBUGF
+ ("%s Forcing non pixmap qsurface->ref to 1 (type %d, ref %d)\n",
+ __FUNCTION__, qsurface->type, qsurface->ref);
+ qsurface->ref = 1;
+ }
+ if (qsurface->status == SURFACE_PENDING) {
+ glo_surface_update_context(qsurface->surface, glstate->context,
+ 1);
+ qsurface->status = SURFACE_ACTIVE;
+ } else {
+ unbind_qsurface(qsurface->glstate, qsurface);
+ glo_surface_update_context(qsurface->surface, glstate->context,
+ 0);
+ }
bind_qsurface(glstate, qsurface);
return 1;
* and glXBindTexImage, so need keep the mapping between them to add proper
* action when bind the texture again
*/
-static void del_pixmap_texture_mapping(GLState *state,
- unsigned int texture)
+static void del_pixmap_texture_mapping(GLState * state, unsigned int texture)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].texture == texture )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].texture == texture) {
state->pixmapTextures[i].used = 0;
state->pixmapTextures[i].texture = 0;
state->pixmapTextures[i].drawable = 0;
}
}
-static void remove_pixmap_texture_mapping(GLState *state,
- ClientGLXDrawable drawable)
+static void remove_pixmap_texture_mapping(GLState * state,
+ ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].drawable == drawable )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].drawable == drawable) {
state->pixmapTextures[i].used = 0;
state->pixmapTextures[i].texture = 0;
state->pixmapTextures[i].drawable = 0;
}
}
-static int add_pixmap_texture_mapping(GLState *state,
- unsigned int texture, ClientGLXDrawable drawable)
+static int add_pixmap_texture_mapping(GLState * state,
+ unsigned int texture,
+ ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].texture == texture ||
- !state->pixmapTextures[i].used )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].texture == texture ||
+ !state->pixmapTextures[i].used) {
state->pixmapTextures[i].used = 1;
state->pixmapTextures[i].texture = texture;
state->pixmapTextures[i].drawable = drawable;
return 0;
}
-static ClientGLXDrawable find_pixmap_texture(GLState *state,
- unsigned int texture)
+static ClientGLXDrawable find_pixmap_texture(GLState * state,
+ unsigned int texture)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].texture == texture )
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].texture == texture)
return state->pixmapTextures[i].drawable;
}
return 0;
}
-static int get_server_texture(ProcessState *process,
+static int get_server_texture(ProcessState * process,
unsigned int client_texture)
{
unsigned int server_texture = 0;
- if (client_texture < 32768) {
- server_texture = process->current_state->tabTextures[client_texture];
+ if (client_texture < process->current_state->tabTextures->count) {
+ server_texture = process->current_state->tabTextures->values[client_texture];
} else {
- DEBUGF( "invalid texture name %d\n", client_texture);
+ DEBUGF("invalid texture name %d\n", client_texture);
}
return server_texture;
}
-static int get_server_buffer(ProcessState *process,
- unsigned int client_buffer)
+static int get_server_buffer(ProcessState * process, unsigned int client_buffer)
{
unsigned int server_buffer = 0;
- if (client_buffer < 32768) {
- server_buffer = process->current_state->tabBuffers[client_buffer];
+ if (client_buffer < process->current_state->tabBuffers->count) {
+ server_buffer = process->current_state->tabBuffers->values[client_buffer];
} else {
- DEBUGF( "invalid buffer name %d\n", client_buffer);
+ DEBUGF("invalid buffer name %d\n", client_buffer);
}
return server_buffer;
}
-
-static int get_server_list(ProcessState *process, unsigned int client_list)
+static int get_server_list(ProcessState * process, unsigned int client_list)
{
unsigned int server_list = 0;
- if (client_list < 32768) {
- server_list = process->current_state->tabLists[client_list];
+ if (client_list < process->current_state->tabLists->count) {
+ server_list = process->current_state->tabLists->values[client_list];
} else {
- DEBUGF( "invalid list name %d\n", client_list);
+ DEBUGF("invalid list name %d\n", client_list);
}
return server_list;
}
-const GLXFBConfig *get_fbconfig(ProcessState *process, int client_fbconfig)
+static const GLXFBConfig *get_fbconfig(ProcessState * process,
+ int client_fbconfig)
{
int i;
+
+ /* The client_fbconfig returned to upper layers is 1 + the index of the
+ * fb config in the set that contains it, + the number of fb configs
+ * store in previously allocated sets. */
int nbtotal = 0;
+ /* For each set */
for (i = 0; i < process->nfbconfig; i++) {
- assert(client_fbconfig >= 1 + nbtotal);
+ /* If the fb config is stored within this set, return it */
if (client_fbconfig <= nbtotal + process->fbconfigs_max[i]) {
return &process->fbconfigs[i][client_fbconfig - 1 - nbtotal];
}
+ /* Otherwise proceed to next set */
nbtotal += process->fbconfigs_max[i];
}
return 0;
int bestConfig = 0;
int bestScore = -1;
- for (i=0;i<DIM(FBCONFIGS);i++) {
+ for (i = 0; i < DIM(FBCONFIGS); i++) {
int score = glo_flags_score(formatFlags, FBCONFIGS[i].formatFlags);
- if (bestScore < 0 || score<=bestScore) {
+ if (bestScore < 0 || score <= bestScore) {
bestScore = score;
bestConfig = i;
}
}
if (bestScore > 0)
- DEBUGF( "Got format flags %d but we couldn't find an exactly matching config, chose %d\n", formatFlags, bestConfig);
+ DEBUGF
+ ("Got format flags %d but we couldn't find an exactly matching config, chose %d\n",
+ formatFlags, bestConfig);
return bestConfig;
}
-static int glXGetConfigFunc(int visualid, int attrib, int *value) {
- const GLXFBConfig *config = &FBCONFIGS[0]; // default
+static int glXGetConfigFunc(int visualid, int attrib, int *value)
+{
+ const GLXFBConfig *config = &FBCONFIGS[0]; // default
int v;
- if (visualid>=0 && visualid<DIM(FBCONFIGS))
+ if (visualid >= 0 && visualid < DIM(FBCONFIGS))
config = &FBCONFIGS[visualid];
else
- DEBUGF( "Unknown visual ID %d\n", visualid);
+ DEBUGF("Unknown visual ID %d\n", visualid);
v = glo_get_glx_from_flags(config->formatFlags, attrib);
if (value)
- *value = v;
+ *value = v;
return 0;
}
-static const GLXFBConfig * glXGetFBConfigsFunc(int screen, int *nelements) {
+static const GLXFBConfig *glXGetFBConfigsFunc(int screen, int *nelements)
+{
*nelements = DIM(FBCONFIGS);
return &FBCONFIGS[0];
}
-static int glXGetFBConfigAttribFunc(const GLXFBConfig *fbconfig, int attrib, int *value) {
+static int glXGetFBConfigAttribFunc(const GLXFBConfig * fbconfig, int attrib,
+ int *value)
+{
// TODO other enums - see http://www.opengl.org/sdk/docs/man/xhtml/glXGetFBConfigAttrib.xml
int v = glo_get_glx_from_flags(fbconfig->formatFlags, attrib);
- if (value) *value = v;
+ if (value)
+ *value = v;
return 0;
}
-static const GLXFBConfig *glXChooseFBConfigFunc(int screen, const int *attrib_list, int *nelements) {
+static const GLXFBConfig *glXChooseFBConfigFunc(int screen,
+ const int *attrib_list,
+ int *nelements)
+{
if (attrib_list != NULL) {
int formatFlags = glo_flags_get_from_glx(attrib_list, False);
int i;
int bestConfig = 0;
int bestScore = -1;
- for (i=0;i<DIM(FBCONFIGS);i++) {
+ for (i = 0; i < DIM(FBCONFIGS); i++) {
int score = glo_flags_score(formatFlags, FBCONFIGS[i].formatFlags);
- if (bestScore < 0 || score<=bestScore) {
+ if (bestScore < 0 || score <= bestScore) {
bestScore = score;
bestConfig = i;
}
}
if (bestScore > 0) {
- DEBUGF( "Got format flags %d but we couldn't find an exactly matching config, chose %d\n", formatFlags, bestConfig);
+ DEBUGF
+ ("Got format flags %d but we couldn't find an exactly matching config, chose %d\n",
+ formatFlags, bestConfig);
}
if (nelements)
- *nelements=1;
+ *nelements = 1;
return &FBCONFIGS[bestConfig];
}
if (nelements)
- *nelements=0;
+ *nelements = 0;
return 0;
}
}
}
-static void destroy_gl_state(GLState *state)
+static void destroy_gl_state(GLState * state)
{
int i;
QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
g_free(qsurface);
}
-
+
if (state->context)
- glo_context_destroy(state->context);
+ glo_context_destroy(state->context);
if (state->vertexPointer)
g_free(state->vertexPointer);
g_free(state->interleavedArrays);
if (state->elementPointerATI)
g_free(state->elementPointerATI);
+
+ if (state->ownTabTextures.values)
+ g_free(state->ownTabTextures.values);
+ if (state->ownTabBuffers.values)
+ g_free(state->ownTabBuffers.values);
+ if (state->ownTabLists.values)
+ g_free(state->ownTabLists.values);
}
-static void init_gl_state(GLState *state)
+static void init_gl_state(GLState * state)
{
state->textureAllocator = &state->ownTextureAllocator;
- state->tabTextures = state->ownTabTextures;
+ state->tabTextures = &state->ownTabTextures;
state->bufferAllocator = &state->ownBufferAllocator;
- state->tabBuffers = state->ownTabBuffers;
+ state->tabBuffers = &state->ownTabBuffers;
state->listAllocator = &state->ownListAllocator;
- state->tabLists = state->ownTabLists;
+ state->tabLists = &state->ownTabLists;
}
/*
* Translate the nth element of list from type to GLuint.
*/
-static GLuint translate_id(GLsizei n, GLenum type, const GLvoid *list)
+static GLuint translate_id(GLsizei n, GLenum type, const GLvoid * list)
{
GLbyte *bptr;
GLubyte *ubptr;
switch (type) {
case GL_BYTE:
bptr = (GLbyte *) list;
- return (GLuint) *(bptr + n);
+ return (GLuint) * (bptr + n);
case GL_UNSIGNED_BYTE:
ubptr = (GLubyte *) list;
- return (GLuint) *(ubptr + n);
+ return (GLuint) * (ubptr + n);
case GL_SHORT:
sptr = (GLshort *) list;
- return (GLuint) *(sptr + n);
+ return (GLuint) * (sptr + n);
case GL_UNSIGNED_SHORT:
usptr = (GLushort *) list;
- return (GLuint) *(usptr + n);
+ return (GLuint) * (usptr + n);
case GL_INT:
iptr = (GLint *) list;
- return (GLuint) *(iptr + n);
+ return (GLuint) * (iptr + n);
case GL_UNSIGNED_INT:
uiptr = (GLuint *) list;
- return (GLuint) *(uiptr + n);
+ return (GLuint) * (uiptr + n);
case GL_FLOAT:
fptr = (GLfloat *) list;
- return (GLuint) *(fptr + n);
+ return (GLuint) * (fptr + n);
case GL_2_BYTES:
ubptr = ((GLubyte *) list) + 2 * n;
- return (GLuint) (*ubptr << 8) + (GLuint) *(ubptr + 1);
+ return (GLuint) (*ubptr << 8) + (GLuint) * (ubptr + 1);
case GL_3_BYTES:
ubptr = ((GLubyte *) list) + 3 * n;
return (GLuint) (*ubptr << 16) + (GLuint) (*(ubptr + 1) << 8) +
- (GLuint) *(ubptr + 2);
+ (GLuint) * (ubptr + 2);
case GL_4_BYTES:
ubptr = ((GLubyte *) list) + 4 * n;
return (GLuint) (*ubptr << 24) + (GLuint) (*(ubptr + 1) << 16) +
- (GLuint) (*(ubptr + 2) << 8) + (GLuint) *(ubptr + 3);
+ (GLuint) (*(ubptr + 2) << 8) + (GLuint) * (ubptr + 3);
default:
return 0;
}
}
-GLState *_create_context(ProcessState *process, int fake_ctxt, int fake_shareList)
+static GLState *_create_context(ProcessState * process, int fake_ctxt)
{
- // FIXMEIM - realloc? really?
- process->glstates = g_realloc(process->glstates,
- (process->nb_states + 1) * sizeof(GLState *));
+ GLState *state = g_try_malloc0(sizeof(GLState));
+
+ if (state) {
+ state->ref = 1;
+ state->fake_ctxt = fake_ctxt;
+ init_gl_state(state);
+
+ // FIXMEIM - realloc? really?
+ process->glstates = g_realloc(process->glstates,
+ (process->nb_states +
+ 1) * sizeof(GLState *));
+
+ process->glstates[process->nb_states] = state;
- process->glstates[process->nb_states] = g_malloc(sizeof(GLState));
- memset(process->glstates[process->nb_states], 0, sizeof(GLState));
+ process->nb_states++;
+ }
- process->glstates[process->nb_states]->ref = 1;
- process->glstates[process->nb_states]->fake_ctxt = fake_ctxt;
- process->glstates[process->nb_states]->fake_shareList = fake_shareList;
+ DEBUGF("state %p fake_ctxt %08x process->nb_states %d\n", state, fake_ctxt,
+ process->nb_states);
+ return state;
+}
- init_gl_state(process->glstates[process->nb_states]);
+static void set_context_sharelist(ProcessState * process, GLState * state,
+ int fake_shareList)
+{
+ state->fake_shareList = fake_shareList;
if (fake_shareList) {
int i;
for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_shareList) {
process->glstates[i]->ref++;
- process->glstates[process->nb_states]->textureAllocator =
+ state->textureAllocator =
process->glstates[i]->textureAllocator;
- process->glstates[process->nb_states]->tabTextures =
- process->glstates[i]->tabTextures;
- process->glstates[process->nb_states]->bufferAllocator =
- process->glstates[i]->bufferAllocator;
- process->glstates[process->nb_states]->tabBuffers =
- process->glstates[i]->tabBuffers;
- process->glstates[process->nb_states]->listAllocator =
- process->glstates[i]->listAllocator;
- process->glstates[process->nb_states]->tabLists =
- process->glstates[i]->tabLists;
+ state->tabTextures = process->glstates[i]->tabTextures;
+ state->bufferAllocator = process->glstates[i]->bufferAllocator;
+ state->tabBuffers = process->glstates[i]->tabBuffers;
+ state->listAllocator = process->glstates[i]->listAllocator;
+ state->tabLists = process->glstates[i]->tabLists;
break;
}
}
}
- process->nb_states++;
-
- return process->glstates[process->nb_states-1];
}
-GLState *get_glstate_for_fake_ctxt(ProcessState *process, int fake_ctxt)
+static GLState *get_glstate_for_fake_ctxt(ProcessState * process, int fake_ctxt)
{
int i;
for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_ctxt)
return process->glstates[i];
- }
+ }
return 0;
}
-void gl_disconnect(ProcessState *process)
+void gl_disconnect(ProcessState * process)
{
int i;
for (i = 0; i < process->nb_states; i++) {
if (process->cmdbuf)
g_free(process->cmdbuf);
- for (i = 0; &processes[i] != process; i ++) {
- ; // do nothing
- }
+ for (i = 0; &processes[i] != process; i++) {
+ ; // do nothing
+ }
- memmove(&processes[i], &processes[i + 1],
- (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
+ memmove(&processes[i], &processes[i + 1],
+ (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
}
static const int beginend_allowed[GL_N_CALLS] = {
static int first;
int i;
- if(!first) {
+ if (!first) {
first = 1;
init_process_tab();
}
* process->current_state contains info on which of the guests contexts is
* current.
*/
- for (i = 0; i < MAX_HANDLED_PROCESS; i ++) {
+ for (i = 0; i < MAX_HANDLED_PROCESS; i++) {
if (processes[i].p.process_id == pid) {
process = &processes[i];
break;
process->current_state = &process->default_state;
break;
}
- }
+ }
if (process == NULL) {
- DEBUGF( "Too many processes !\n");
+ DEBUGF("Too many processes !\n");
exit(-1);
}
- return (ProcessStruct *)process; // Cast is ok due to struct defn.
+ return (ProcessStruct *) process; // Cast is ok due to struct defn.
}
-void vmgl_context_switch(ProcessStruct *p, int switch_gl_context)
+void vmgl_context_switch(ProcessStruct * p, int switch_gl_context)
{
- ProcessState *process = (ProcessState *)p;
- if(switch_gl_context) {
- if(process->current_state->current_qsurface)
- glo_surface_makecurrent(process->current_state->current_qsurface->surface);
+ ProcessState *process = (ProcessState *) p;
+ if (switch_gl_context) {
+ if (process->current_state->current_qsurface)
+ glo_surface_makecurrent(process->current_state->current_qsurface->
+ surface);
else
glo_surface_makecurrent(0); // should never happen
}
}
-static const char *opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
+static char *opengl_strtok(const char *s, int *n, char const **saveptr,
+ char *prevbuf)
{
- char *start;
- char *ret;
- char *p;
- int retlen;
+ const char *start;
+ char *ret;
+ char *p;
+ int retlen;
static const char *delim = " \t\n\r/";
- if (prevbuf)
- free(prevbuf);
+ if (prevbuf)
+ free(prevbuf);
if (s) {
*saveptr = s;
s++, (*n)--;
} while (*n > 2 && (s[1] != '*' || s[2] != '/'));
s++, (*n)--;
- s++, (*n)--;
- if (*n == 0) {
- break;
- }
- } else {
- break;
+ s++, (*n)--;
+ if (*n == 0) {
+ break;
+ }
+ } else {
+ break;
}
}
}
- start = s;
+ start = s;
for (; *n && *s && !strchr(delim, *s); s++, (*n)--) {
- ; // do nothing
- }
+ ; // do nothing
+ }
- if (*n > 0)
- s++, (*n)--;
+ if (*n > 0)
+ s++, (*n)--;
- *saveptr = s;
+ *saveptr = s;
- retlen = s - start;
- ret = malloc(retlen + 1);
- p = ret;
+ retlen = s - start;
+ ret = malloc(retlen + 1);
+ p = ret;
- if (retlen == 0) {
- *p = 0;
- return;
- }
+ if (retlen == 0) {
+ *p = 0;
+ return ret;
+ }
- while (retlen > 0) {
+ while (retlen > 0) {
if (*start == '/' && retlen > 1) {
if (start[1] == '/') {
do {
start++, retlen--;
} while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
- start++, retlen--;
- continue;
+ start++, retlen--;
+ continue;
} else if (start[1] == '*') {
do {
start++, retlen--;
} while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
start += 3, retlen -= 3;
- continue;
+ continue;
}
}
- *(p++) = *(start++), retlen--;
- }
-
- *p = 0;
- return ret;
+ *(p++) = *(start++), retlen--;
+ }
+
+ *p = 0;
+ return ret;
}
static char *do_eglShaderPatch(const char *source, int length, int *patched_len)
{
- char *saveptr = NULL;
- char *sp;
- char *p = NULL;
+ const char *saveptr = NULL;
+ char *sp;
+ char *p = NULL;
- if (!length)
+ if (!length)
length = strlen(source);
-
+
*patched_len = 0;
int patched_size = length;
char *patched = malloc(patched_size + 1);
- if (!patched)
+ if (!patched)
return NULL;
p = opengl_strtok(source, &length, &saveptr, NULL);
for (; p; p = opengl_strtok(0, &length, &saveptr, p)) {
- if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) {
+ if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7)
+ || !strncmp(p, "highp", 5)) {
continue;
} else if (!strncmp(p, "precision", 9)) {
- while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';')) {
- // do nothing
- ;
- }
+ while ((p = opengl_strtok(0, &length, &saveptr, p))
+ && !strchr(p, ';')) {
+ // do nothing
+ ;
+ }
} else {
+ const char *p2;
if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) {
- p = "(gl_MaxVertexUniformComponents / 4)";
+ p2 = "(gl_MaxVertexUniformComponents / 4)";
} else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28)) {
- p = "(gl_MaxFragmentUniformComponents / 4)";
+ p2 = "(gl_MaxFragmentUniformComponents / 4)";
} else if (!strncmp(p, "gl_MaxVaryingVectors", 20)) {
- p = "(gl_MaxVaryingFloats / 4)";
+ p2 = "(gl_MaxVaryingFloats / 4)";
+ } else {
+ p2 = p;
}
- int new_len = strlen(p);
+ int new_len = strlen(p2);
if (*patched_len + new_len > patched_size) {
patched_size *= 2;
patched = realloc(patched, patched_size + 1);
- if (!patched)
+ if (!patched)
return NULL;
}
- memcpy(patched + *patched_len, p, new_len);
+ memcpy(patched + *patched_len, p2, new_len);
*patched_len += new_len;
- }
+ }
}
patched[*patched_len] = 0;
/* check that we don't leave dummy preprocessor lines */
for (sp = patched; *sp;) {
for (; *sp == ' ' || *sp == '\t'; sp++) {
- ; // do nothing
- }
+ ; // do nothing
+ }
if (!strncmp(sp, "#define", 7)) {
for (p = sp + 7; *p == ' ' || *p == '\t'; p++) {
- ; // do nothing
- }
+ ; // do nothing
+ }
if (*p == '\n' || *p == '\r' || *p == '/') {
memset(sp, 0x20, 7);
}
}
for (; *sp && *sp != '\n' && *sp != '\r'; sp++) {
- ; // do nothing
- }
+ ; // do nothing
+ }
for (; *sp == '\n' || *sp == '\r'; sp++) {
- ; // do nothing
- }
+ ; // do nothing
+ }
}
return patched;
}
-static int
-shadersrc_gles_to_gl(GLsizei count, const char** string, char **s, const GLint* length, GLint *l)
+static int
+shadersrc_gles_to_gl(GLsizei count, const char **string, char **s,
+ const GLint * length, GLint * l)
{
- int i;
-
- for(i = 0; i < count; ++i) {
- GLint len;
- if(length) {
- len = length[i];
- if (len < 0)
- len = string[i] ? strlen(string[i]) : 0;
- } else
- len = string[i] ? strlen(string[i]) : 0;
-
- if(string[i]) {
- s[i] = do_eglShaderPatch(string[i], len, &l[i]);
- if(!s[i]) {
- while(i) {
- free(s[--i]);
- }
-
- free(l);
- free(s);
- return -1;
- }
- } else {
- s[i] = NULL;
- l[i] = 0;
- }
- }
-
- return 0;
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ GLint len;
+ if (length) {
+ len = length[i];
+ if (len < 0)
+ len = string[i] ? strlen(string[i]) : 0;
+ } else
+ len = string[i] ? strlen(string[i]) : 0;
+
+ if (string[i]) {
+ s[i] = do_eglShaderPatch(string[i], len, &l[i]);
+ if (!s[i]) {
+ while (i) {
+ free(s[--i]);
+ }
+
+ free(l);
+ free(s);
+ return -1;
+ }
+ } else {
+ s[i] = NULL;
+ l[i] = 0;
+ }
+ }
+
+ return 0;
}
#ifdef __APPLE__
* read texture back right after glTexSubImage2D, thus guarantee a
* synchronization.
*/
-static void mac_dump_texture()
+static void mac_dump_texture(void)
{
- int w, h;
- unsigned char *buf;
+ int w, h;
+ unsigned char *buf;
- /* only handle target=GL_TEXTURE_2D, level=0, format=GL_RGBA, type=GL_UNSIGNED_BYTE */
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
+ /* only handle target=GL_TEXTURE_2D, level=0, format=GL_RGBA, type=GL_UNSIGNED_BYTE */
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
- if ( w == 0 && h == 0 )
- return;
+ if (w == 0 && h == 0)
+ return;
- buf = g_malloc( (w*4) * h); /* XXX:need allignment? */
+ buf = g_malloc((w * 4) * h); /* XXX:need allignment? */
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
- g_free(buf);
+ g_free(buf);
}
#endif
-int do_function_call(ProcessState *process, int func_number, unsigned long *args, char *ret_string)
+static int record_fbconfig_set(ProcessState * process,
+ const GLXFBConfig * fbconfigs, int nconfigs)
+{
+ int i;
+ int id;
+ int previous_entries = 0;
+
+ if (!fbconfigs)
+ return 0;
+
+ /* Check if we already have a similar set in our tables */
+ for (i = 0; i < process->nfbconfig; i++) {
+ if (process->fbconfigs_max[i] == nconfigs &&
+ !memcmp(fbconfigs, process->fbconfigs[i],
+ sizeof(GLXFBConfig) * nconfigs)) {
+ /* No need to store this set as it's identical to another one */
+ // XFree(fbconfigs);
+
+ /* Return the identifier of the previously allocated set matching the query */
+ id = previous_entries + 1;
+ return id;
+ } else
+ previous_entries += process->fbconfigs_max[i];
+ }
+
+ /* Check if we have room for a new set */
+ if (process->nfbconfig >= MAX_FBCONFIG) {
+ fprintf(stderr,
+ "[%s]:%d Too many FB configs allocated for this process\n",
+ __FUNCTION__, __LINE__);
+ // XFree(fbconfigs);
+ return 0;
+ }
+
+ /* Store new set - this block should be released using XFree on process exit */
+ process->fbconfigs[process->nfbconfig] = fbconfigs;
+ process->fbconfigs_max[process->nfbconfig] = nconfigs;
+ process->nfbconfig++;
+ process->nfbconfig_total += nconfigs;
+
+ id = previous_entries + 1;
+ return id;
+}
+
+int do_function_call(ProcessState * process, int func_number,
+ unsigned long *args, char *ret_string)
{
union gl_ret_type ret;
Signature *signature = (Signature *) tab_opengl_calls[func_number];
int ret_type = signature->ret_type;
+ struct timeval t0, t1;
+
+ if (TRACE_ON(qemu)) {
+ gettimeofday(&t0, NULL);
+ }
ret.s = NULL;
if (display_function_call) {
- DEBUGF( "[%d]> %s\n", process->p.process_id,
- tab_opengl_calls_name[func_number]);
+ DEBUGF("[%d]> %s\n", process->p.process_id,
+ tab_opengl_calls_name[func_number]);
}
- TRACE( "[%d]> %s\n", process->p.process_id,
- tab_opengl_calls_name[func_number]);
+ TRACE("[%d]> %s\n", process->p.process_id,
+ tab_opengl_calls_name[func_number]);
switch (func_number) {
case -1:
case _resize_surface_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[0]);
- QGloSurface *qsurface = get_qsurface_from_client_drawable(
- process->current_state, client_drawable);
+ QGloSurface *qsurface =
+ get_qsurface_from_client_drawable(process->current_state,
+ client_drawable);
// We have to assume the current context here
// since we assume that a drawable must belong to a specific context
- resize_surface(process, qsurface, (int)args[1], (int)args[2]);
+ if (qsurface)
+ resize_surface(process, qsurface, (int)args[1], (int)args[2]);
+ else
+ DEBUGF
+ ("%s Failed to find surface for client_drawable %p process %p ->current_state %p ->->current_surface %p\n",
+ "_resize_surface_func", client_drawable, process,
+ process->current_state,
+ process->current_state->current_qsurface);
break;
}
case _render_surface_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[0]);
- QGloSurface *qsurface = get_qsurface_from_client_drawable(
- process->current_state, client_drawable);
- int bpp = (int)args[1];
+ QGloSurface *qsurface =
+ get_qsurface_from_client_drawable(process->current_state,
+ client_drawable);
+ int bpp = (int)args[1];
int stride = (int)args[2];
- char *render_buffer = (char*)args[3];
+ char *render_buffer = (char *)args[3];
// DEBUGF( "win: %08x stride: %d buf: %08x cl_dr: %08x qsurf: %08x\n", args[0], args[1], args[2], client_drawable, qsurface);
// We have to assume the current context here
// since we assume that a drawable must belong to a specific context
- render_surface(qsurface, bpp, stride, render_buffer);
+ if (qsurface)
+ render_surface(qsurface, bpp, stride, render_buffer);
break;
}
case glXWaitGL_func:
{
- glFinish(); //glXWaitGL();
+ glFinish(); //glXWaitGL();
ret.i = 0;
break;
}
case glXChooseVisual_func:
{
- ret.i = glXChooseVisualFunc((int *) &args[2]);
+ ret.i = glXChooseVisualFunc((int *)&args[2]);
break;
}
case glXQueryExtensionsString_func:
{
- ret.s = supported_glx_extensions();//glXQueryExtensionsString(dpy, 0);
+ ret.s = supported_glx_extensions(); //glXQueryExtensionsString(dpy, 0);
break;
}
case glXQueryServerString_func:
{
switch (args[2]) {
- case GLX_VENDOR : ret.s = FAKE_GLX_VENDOR; break;
- case GLX_VERSION : ret.s = FAKE_GLX_VERSION_STRING; break;
- case GLX_EXTENSIONS : ret.s = supported_glx_extensions(); break;
- default: ret.s = 0;
+ case GLX_VENDOR:
+ ret.s = FAKE_GLX_VENDOR;
+ break;
+ case GLX_VERSION:
+ ret.s = FAKE_GLX_VERSION_STRING;
+ break;
+ case GLX_EXTENSIONS:
+ ret.s = supported_glx_extensions();
+ break;
+ default:
+ ret.s = 0;
}
break;
}
case glXGetClientString_func:
{
switch (args[1]) {
- case GLX_VENDOR : ret.s = FAKE_GLX_VENDOR; break;
- case GLX_VERSION : ret.s = FAKE_GLX_VERSION_STRING; break;
- case GLX_EXTENSIONS : ret.s = "GLX_ARB_get_proc_address "; break;
- default: ret.s = 0;
+ case GLX_VENDOR:
+ ret.s = FAKE_GLX_VENDOR;
+ break;
+ case GLX_VERSION:
+ ret.s = FAKE_GLX_VERSION_STRING;
+ break;
+ case GLX_EXTENSIONS:
+ ret.s = "GLX_ARB_get_proc_address ";
+ break;
+ default:
+ ret.s = 0;
}
break;
}
case glXCreateContext_func:
{
- int visualid = (int) args[1];
- int fake_shareList = (int) args[2];
+ int visualid = (int)args[1];
+ int fake_shareList = (int)args[2];
if (display_function_call)
- DEBUGF( "visualid=%d, fake_shareList=%d\n", visualid,
- fake_shareList);
+ DEBUGF("visualid=%d, fake_shareList=%d\n", visualid,
+ fake_shareList);
- GLState *shareListState = get_glstate_for_fake_ctxt(process, fake_shareList);
- int fake_ctxt = ++process->next_available_context_number;
+ GLState *shareListState =
+ get_glstate_for_fake_ctxt(process, fake_shareList);
- ret.i = fake_ctxt;
+ ret.i = 0;
// Work out format flags from visual id
int formatFlags = GLO_FF_DEFAULT;
- if (visualid>=0 && visualid<DIM(FBCONFIGS))
- formatFlags = FBCONFIGS[visualid].formatFlags;
-
- GLState *state = _create_context(process, fake_ctxt, fake_shareList);
- state->context = glo_context_create(formatFlags,
- (GloContext*)shareListState?shareListState->context:0);
-
- DEBUGF( " created context %p for %08x\n", state, fake_ctxt);
+ if (visualid >= 0 && visualid < DIM(FBCONFIGS))
+ formatFlags = FBCONFIGS[visualid].formatFlags;
+
+ GloContext *context = glo_context_create(formatFlags,
+ (GloContext *)
+ shareListState ?
+ shareListState->
+ context : 0);
+ if (context) {
+ GLState *state =
+ _create_context(process,
+ ++process->next_available_context_number);
+ if (state) {
+ state->context = context;
+ set_context_sharelist(process, state, fake_shareList);
+ ret.i = state->fake_ctxt;
+ } else {
+ DEBUGF("Failed to allocate state context for format %08x\n",
+ formatFlags);
+ glo_context_destroy(context);
+ }
+ } else {
+ DEBUGF("Failed to create context for format %08x\n",
+ formatFlags);
+ }
break;
}
-
case glXCreateNewContext_func:
{
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
if (fbconfig) {
int fake_shareList = args[3];
- GLState *shareListState = get_glstate_for_fake_ctxt(process, fake_shareList);
-
- process->next_available_context_number++;
- int fake_ctxt = process->next_available_context_number;
- ret.i = fake_ctxt;
-
- DEBUGF( "fake_ctxt = %d\n", fake_ctxt);
-
- GLState *state = _create_context(process, fake_ctxt, fake_shareList);
- state->context = glo_context_create(fbconfig->formatFlags,
- shareListState?shareListState->context:0); // FIXME GW get from fbconfig
+ GLState *shareListState =
+ get_glstate_for_fake_ctxt(process, fake_shareList);
+
+ GloContext *context = glo_context_create(fbconfig->formatFlags,
+ (GloContext *) shareListState ? shareListState->context : 0); // FIXME GW get from fbconfig
+ if (context) {
+ GLState *state =
+ _create_context(process,
+ ++process->
+ next_available_context_number);
+ if (state) {
+ state->context = context;
+ set_context_sharelist(process, state, fake_shareList);
+ ret.i = state->fake_ctxt;
+ } else {
+ DEBUGF
+ ("Failed to allocate state context for format %08x",
+ fbconfig->formatFlags);
+ glo_context_destroy(context);
+ }
+ } else {
+ DEBUGF("Failed to create context for format %08x",
+ fbconfig->formatFlags);
+ }
}
break;
}
case glXCopyContext_func:
{
- DEBUGF( " glXCopyContext not supported (does anything use it?)\n");
+ DEBUGF(" glXCopyContext not supported (does anything use it?)\n");
break;
}
case glXDestroyContext_func:
{
- int fake_ctxt = (int) args[1];
+ int fake_ctxt = (int)args[1];
if (display_function_call)
- DEBUGF( "fake_ctxt=%d\n", fake_ctxt);
+ DEBUGF("fake_ctxt=%d\n", fake_ctxt);
int i;
- for (i = 0; i < process->nb_states; i ++) {
+ for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_ctxt) {
- /*XXX: DestroyContext should not switch current context, or
- * else guest still try to access it and cause qemu
- * segfalt. But not sure if any corner case, so comment it
- * for now and will remove it completely in future.
- */
+ /*XXX: DestroyContext should not switch current context, or
+ * else guest still try to access it and cause qemu
+ * segfalt. But not sure if any corner case, so comment it
+ * for now and will remove it completely in future.
+ */
// this was our GLState...
// process->current_state = &process->default_state;
- int fake_shareList =
- process->glstates[i]->fake_shareList;
+ int fake_shareList = process->glstates[i]->fake_shareList;
process->glstates[i]->ref--;
if (process->glstates[i]->ref == 0) {
- DEBUGF(
- "destroy_gl_state fake_ctxt = %d\n",
- process->glstates[i]->fake_ctxt);
+ DEBUGF("destroy_gl_state fake_ctxt = %d\n",
+ process->glstates[i]->fake_ctxt);
destroy_gl_state(process->glstates[i]);
g_free(process->glstates[i]);
memmove(&process->glstates[i],
&process->glstates[i + 1],
(process->nb_states - i - 1) *
sizeof(GLState *));
- process->nb_states --;
+ process->nb_states--;
}
if (fake_shareList) {
fake_shareList) {
process->glstates[i]->ref--;
if (process->glstates[i]->ref == 0) {
- DEBUGF(
- "destroy_gl_state fake_sharelist fake_ctxt = %d\n",
- process->glstates[i]->
- fake_ctxt);
- destroy_gl_state(process->
- glstates[i]);
+ DEBUGF
+ ("destroy_gl_state fake_sharelist fake_ctxt = %d\n",
+ process->glstates[i]->fake_ctxt);
+ destroy_gl_state(process->glstates[i]);
g_free(process->glstates[i]);
memmove(&process->glstates[i],
&process->glstates[i + 1],
(process->nb_states - i - 1) *
sizeof(GLState *));
- process->nb_states --;
+ process->nb_states--;
}
break;
}
case glXQueryVersion_func:
{
- int *major = (int *) args[1];
- int *minor = (int *) args[2];
+ int *major = (int *)args[1];
+ int *minor = (int *)args[2];
//ret.i = glXQueryVersion(dpy, (int *) args[1], (int *) args[2]);
- if (major) *major=FAKE_GLX_VERSION_MAJOR;
- if (minor) *minor=FAKE_GLX_VERSION_MINOR;
+ if (major)
+ *major = FAKE_GLX_VERSION_MAJOR;
+ if (minor)
+ *minor = FAKE_GLX_VERSION_MINOR;
ret.i = True;
break;
}
case glGetString_func:
{
switch (args[0]) {
- case GL_VENDOR:
+ case GL_VENDOR:
ret.s = FAKE_GL_VENDOR;
- break;
- case GL_RENDERER:
+ break;
+ case GL_RENDERER:
ret.s = FAKE_GL_RENDERER;
- break;
- case GL_VERSION:
+ break;
+ case GL_VERSION:
ret.s = FAKE_GL_VERSION;
- break;
- case GL_EXTENSIONS:
+ break;
+ case GL_EXTENSIONS:
ret.s = compute_gl_extensions();
- break;
- case GL_SHADING_LANGUAGE_VERSION:
- if(FAKE_GL_MAJOR < 2) {
- ret.s = "";
- break;
+ break;
+ case GL_SHADING_LANGUAGE_VERSION:
+ if (FAKE_GL_MAJOR < 2) {
+ ret.s = "";
+ break;
}
- // Fall through.
- default:
- ret.s = (char *) glGetString(args[0]);
- break;
+ // Fall through.
+ default:
+ ret.s = (char *)glGetString(args[0]);
+ break;
}
break;
}
case glXMakeCurrent_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- int fake_ctxt = (int) args[2];
+ int fake_ctxt = (int)args[2];
GLState *glstate = NULL;
- DEBUGF( "Makecurrent: fake_ctx=%d client_drawable=%08x\n", fake_ctxt, client_drawable);
+ DEBUGF("Makecurrent: fake_ctx=%d client_drawable=%08x\n", fake_ctxt,
+ client_drawable);
if (client_drawable == 0 && fake_ctxt == 0) {
/* Release context */
- if(process->current_state->current_qsurface) {
- if(process->current_state->current_qsurface->type != SURFACE_PIXMAP)
+ if (process->current_state->current_qsurface) {
+ if (process->current_state->current_qsurface->type !=
+ SURFACE_PIXMAP)
process->current_state->current_qsurface->ref--;
else
- unbind_qsurface(process->current_state, process->current_state->current_qsurface);
+ unbind_qsurface(process->current_state,
+ process->current_state->
+ current_qsurface);
}
process->current_state = &process->default_state;
- DEBUGF( " --release\n");
+ DEBUGF(" --release\n");
glo_surface_makecurrent(0);
- } else { /* Lookup GLState struct for this context */
+ } else { /* Lookup GLState struct for this context */
glstate = get_glstate_for_fake_ctxt(process, fake_ctxt);
if (!glstate) {
- DEBUGF( " --invalid fake_ctxt (%d)!\n", fake_ctxt);
+ DEBUGF(" --invalid fake_ctxt (%d)!\n", fake_ctxt);
} else {
- if(!set_current_qsurface(glstate, client_drawable) &&
- !link_qsurface(process, glstate, client_drawable) ) {
- // If there is no surface, create one.
- QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
- qsurface->surface = glo_surface_create(4, 4,
- glstate->context);
- qsurface->client_drawable = client_drawable;
- qsurface->ref = 1;
- qsurface->type = SURFACE_WINDOW;
- qsurface->status = SURFACE_ACTIVE;
-
- bind_qsurface(glstate, qsurface);
- DEBUGF( " --Client drawable not found, create new surface: %16x %16lx\n", (unsigned int)qsurface, (unsigned long int)client_drawable);
-
- }
- else {
- DEBUGF( " --Client drawable found, using surface: %16x %16lx\n", (unsigned int)glstate->current_qsurface, (unsigned long int)client_drawable);
+ if (!set_current_qsurface(glstate, client_drawable) &&
+ !link_qsurface(process, glstate, client_drawable)) {
+ // If there is no surface, create one.
+ QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+ qsurface->surface = glo_surface_create(4, 4,
+ glstate->
+ context);
+ qsurface->client_drawable = client_drawable;
+ qsurface->ref = 1;
+ qsurface->type = SURFACE_WINDOW;
+ qsurface->status = SURFACE_ACTIVE;
+
+ bind_qsurface(glstate, qsurface);
+ DEBUGF
+ (" --Client drawable not found, create new surface: %p %16lx\n",
+ qsurface, (unsigned long int)client_drawable);
+ } else {
+ DEBUGF
+ (" --Client drawable found, using surface: %p %16lx\n",
+ glstate->current_qsurface,
+ (unsigned long int)client_drawable);
}
#if 0
/*Test old surface contents */
int reset_texture = 0;
GLState *old_glstate = NULL;
/* Switch from pixmap */
- if (process->current_state->current_qsurface && SURFACE_PIXMAP == process->current_state->current_qsurface->type )
- {
- glo_surface_updatecontents(process->current_state->current_qsurface->surface);
+ if (process->current_state->current_qsurface
+ && SURFACE_PIXMAP ==
+ process->current_state->current_qsurface->type) {
+ glo_surface_updatecontents(process->current_state->
+ current_qsurface->surface);
reset_texture = 1;
old_glstate = process->current_state;
}
- fprintf(stderr, "edwin:MakeCurrent: drawable=0x%x,qsurface=%p.\n", client_drawable, glstate->current_qsurface);
+ fprintf(stderr,
+ "edwin:MakeCurrent: drawable=0x%x,qsurface=%p.\n",
+ client_drawable, glstate->current_qsurface);
#endif
/* Switch in pixmap surface */
- if (glstate->current_qsurface && SURFACE_PIXMAP == glstate->current_qsurface->type )
- {
+ if (glstate->current_qsurface
+ && SURFACE_PIXMAP == glstate->current_qsurface->type) {
/* Release it if the surface is used as texture target */
- glo_surface_release_texture(glstate->current_qsurface);
+ glo_surface_release_texture(glstate->current_qsurface->
+ surface);
}
process->current_state = glstate;
- ret.i = glo_surface_makecurrent(glstate->current_qsurface->surface);
+ ret.i =
+ glo_surface_makecurrent(glstate->current_qsurface->
+ surface);
/* if (reset_texture)*/
/* glo_surface_as_texture(process->current_state->context, old_glstate->current_qsurface->surface);*/
}
case glXGetConfig_func:
{
int visualid = args[1];
- ret.i = glXGetConfigFunc(visualid, args[2], (int *) args[3]);
+ ret.i = glXGetConfigFunc(visualid, args[2], (int *)args[3]);
break;
}
int visualid = args[1];
int n = args[2];
int i;
- int *attribs = (int *) args[3];
- int *values = (int *) args[4];
- int *res = (int *) args[5];
+ int *attribs = (int *)args[3];
+ int *values = (int *)args[4];
+ int *res = (int *)args[5];
for (i = 0; i < n; i++) {
res[i] = glXGetConfigFunc(visualid, attribs[i], &values[i]);
case glXQueryExtension_func:
{
- int *errorBase = (int *) args[1];
- int *eventBase = (int *) args[2];
- if (errorBase) *errorBase = 0; /* FIXME GW */
- if (eventBase) *eventBase = 0; /* FIXME GW */
+ int *errorBase = (int *)args[1];
+ int *eventBase = (int *)args[2];
+ if (errorBase)
+ *errorBase = 0; /* FIXME GW */
+ if (eventBase)
+ *eventBase = 0; /* FIXME GW */
ret.i = True;
break;
}
case glXChooseFBConfig_func:
{
- if (process->nfbconfig >= MAX_FBCONFIG) {
- fprintf(stderr, "[%s]:%d Request FB configs error, excceed the MAX FBCONFIG of one process, return NULL!\n", __FUNCTION__, __LINE__);
- *(int *) args[3] = 0;
- ret.i = 0;
- } else {
- const GLXFBConfig *fbconfigs =
- glXChooseFBConfigFunc(args[1], (int *) args[2], (int *) args[3]);
- if (fbconfigs) {
- process->fbconfigs[process->nfbconfig] = fbconfigs;
- process->fbconfigs_max[process->nfbconfig] =
- *(int *) args[3];
- process->nfbconfig++;
- ret.i = 1 + process->nfbconfig_total;
- process->nfbconfig_total +=
- process->fbconfigs_max[process->nfbconfig];
- } else {
- ret.i = 0;
- }
- }
+ /* Retrieve array of FB configs matching our contraints */
+ const GLXFBConfig *fbconfigs =
+ glXChooseFBConfigFunc(args[1], (int *)args[2], (int *)args[3]);
+
+ /* Record this in our tables and return a client-side identifier for the first entry in the array */
+ ret.i = record_fbconfig_set(process, fbconfigs, *(int *)args[3]);
+
+ /* Zero indicates failure */
+ if (ret.i == 0)
+ *(int *)args[3] = 0;
+
break;
}
+
case glXGetFBConfigs_func:
{
- if (process->nfbconfig == MAX_FBCONFIG) {
- *(int *) args[2] = 0;
- ret.i = 0;
- } else {
- const GLXFBConfig *fbconfigs =
- glXGetFBConfigsFunc(args[1], (int *) args[2]);
- if (fbconfigs) {
- process->fbconfigs[process->nfbconfig] = fbconfigs;
- process->fbconfigs_max[process->nfbconfig] =
- *(int *) args[2];
- process->nfbconfig++;
- ret.i = 1 + process->nfbconfig_total;
- process->nfbconfig_total +=
- process->fbconfigs_max[process->nfbconfig];
- } else {
- ret.i = 0;
- }
- }
+ /* Retrieve array of available FB configs */
+ const GLXFBConfig *fbconfigs =
+ glXGetFBConfigsFunc(args[1], (int *)args[2]);
+
+ /* Record this in our tables and return a client-side identifier for the first entry in the array */
+ ret.i = record_fbconfig_set(process, fbconfigs, *(int *)args[2]);
+
+ /* Zero indicates failure */
+ if (ret.i == 0)
+ *(int *)args[2] = 0;
+
break;
}
case glXGetFBConfigAttrib_func:
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
if (fbconfig)
ret.i =
- glXGetFBConfigAttribFunc(fbconfig, args[2], (int *) args[3]);
+ glXGetFBConfigAttribFunc(fbconfig, args[2], (int *)args[3]);
break;
}
int client_fbconfig = args[1];
int n = args[2];
int i;
- int *attribs = (int *) args[3];
- int *values = (int *) args[4];
- int *res = (int *) args[5];
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ int *attribs = (int *)args[3];
+ int *values = (int *)args[4];
+ int *res = (int *)args[5];
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
for (i = 0; i < n; i++) {
if (fbconfig) {
res[i] =
- glXGetFBConfigAttribFunc(fbconfig, attribs[i], &values[i]);
+ glXGetFBConfigAttribFunc(fbconfig, attribs[i],
+ &values[i]);
} else {
res[i] = 0;
}
}
case glXQueryContext_func:
{
- DEBUGF( "glXQueryContext not implemented\n");
+ DEBUGF("glXQueryContext not implemented\n");
ret.i = 0;
-#if 0 //GW
+#if 0 //GW
GET_EXT_PTR(int, glXQueryContext,
(Display *, GLXContext, int, int *));
- int fake_ctxt = (int) args[1];
+ int fake_ctxt = (int)args[1];
if (display_function_call)
- DEBUGF( "fake_ctx=%i\n", fake_ctxt);
+ DEBUGF("fake_ctx=%i\n", fake_ctxt);
GLXContext ctxt =
get_association_fakecontext_glxcontext(process, fake_ctxt);
if (ctxt == NULL) {
- DEBUGF( "invalid fake_ctxt (%i) !\n", fake_ctxt);
+ DEBUGF("invalid fake_ctxt (%i) !\n", fake_ctxt);
ret.i = 0;
} else {
ret.i =
ptr_func_glXQueryContext(dpy, ctxt, args[2],
- (int *) args[3]);
+ (int *)args[3]);
}
#endif
break;
{
// TODO GW one of:
// GLX_WIDTH, GLX_HEIGHT, GLX_PRESERVED_CONTENTS, GLX_LARGEST_PBUFFER, GLX_FBCONFIG_ID
- DEBUGF( "FIXME: glXQueryDrawable not implemented\n");
+ DEBUGF("FIXME: glXQueryDrawable not implemented\n");
ret.i = 0;
-#if 0 //GW
+#if 0 //GW
GET_EXT_PTR(void, glXQueryDrawable,
(Display *, GLXDrawable, int, int *));
ClientGLXDrawable client_drawable = to_drawable(args[1]);
GLXDrawable drawable =
- get_association_clientdrawable_serverdrawable(
- glstate, client_drawable);
+ get_association_clientdrawable_serverdrawable(glstate,
+ client_drawable);
if (display_function_call)
- DEBUGF( "client_drawable=%p\n",
- client_drawable);
+ DEBUGF("client_drawable=%p\n", client_drawable);
if (!drawable)
- DEBUGF( "invalid client_drawable (%p) !\n",
- client_drawable);
+ DEBUGF("invalid client_drawable (%p) !\n", client_drawable);
else
ptr_func_glXQueryDrawable(dpy, drawable,
- args[2], (int *) args[3]);
+ args[2], (int *)args[3]);
#endif
break;
}
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
if (fbconfig) {
// we tread visualid as the index into the fbconfigs array
ret.i = &FBCONFIGS[0] - fbconfig;
if (display_function_call)
- DEBUGF( "visualid = %d\n", ret.i);
+ DEBUGF("visualid = %d\n", ret.i);
}
break;
}
case glXSwapIntervalSGI_func:
{
/*GET_EXT_PTR(int, glXSwapIntervalSGI, (int));
- ret.i = ptr_func_glXSwapIntervalSGI(args[0]);*/
+ ret.i = ptr_func_glXSwapIntervalSGI(args[0]); */
ret.i = 0;
break;
}
{
// if (display_function_call)
//DEBUGF( "glXGetProcAddress %s ", (char *) args[0]);
- ret.i = glo_getprocaddress((const char *) args[0]) != NULL;
+ ret.i = glo_getprocaddress((const char *)args[0]) != NULL;
// DEBUGF( " == %08x\n", ret.i);
ret.i = 0;
break;
case glXGetProcAddress_global_fake_func:
{
int nbElts = args[0];
- char *huge_buffer = (char *) args[1];
- char *result = (char *) args[2];
+ char *huge_buffer = (char *)args[1];
+ char *result = (char *)args[2];
int i;
for (i = 0; i < nbElts; i++) {
int len = strlen(huge_buffer);
//DEBUGF( "glXGetProcAddress_global %s ", (char *)huge_buffer);
result[i] =
- glo_getprocaddress((const char *) huge_buffer) !=
- NULL;
+ glo_getprocaddress((const char *)huge_buffer) != NULL;
huge_buffer += len + 1;
}
break;
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
if (fbconfig) {
-
/* Create a light-weight context just for creating surface */
- GloContext *context = __glo_context_create(fbconfig->formatFlags);
-
- /* glXPixmap same as input Pixmap */
- ClientGLXDrawable client_drawable = to_drawable(args[2]);
-
- QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
-
- /* get the width and height */
- int width, height;
- glo_geometry_get_from_glx((int*)args[3], &width, &height);
-
- DEBUGF( "glXCreatePixmap: %dX%d.\n", width, height);
- qsurface->surface = glo_surface_create(width, height, context);
- qsurface->client_drawable = client_drawable;
- qsurface->type = SURFACE_PIXMAP;
- qsurface->status = SURFACE_PENDING;
- /* qsurface->ref = 1;*/
-
- /* Keep this surface, will link it with context in MakeCurrent */
- keep_qsurface(process, qsurface);
-
- /* If this pixmap is linked as texture previously */
- if (link_drawable(process, client_drawable))
- glo_surface_as_texture(process->current_state->context,
- qsurface->surface, qsurface->type);
-
-
- ret.i = client_drawable;
-
+ GloContext *context =
+ __glo_context_create(fbconfig->formatFlags);
+ if (context) {
+ /* glXPixmap same as input Pixmap */
+ ClientGLXDrawable client_drawable = to_drawable(args[2]);
+
+ QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+ if (qsurface) {
+ /* get the width and height */
+ int width, height;
+ glo_geometry_get_from_glx((int *)args[3], &width,
+ &height);
+
+ DEBUGF("glXCreatePixmap: %dX%d.\n", width, height);
+ qsurface->surface =
+ glo_surface_create(width, height, context);
+ if (qsurface->surface) {
+ qsurface->client_drawable = client_drawable;
+ qsurface->type = SURFACE_PIXMAP;
+ qsurface->status = SURFACE_PENDING;
+ qsurface_pixmap_ref(qsurface);
+
+ /* Keep this surface, will link it with context in MakeCurrent */
+ keep_qsurface(process, qsurface);
+
+ /* If this pixmap is linked as texture previously */
+ if (link_drawable(process, client_drawable))
+ glo_surface_as_texture(process->current_state->
+ context,
+ qsurface->surface,
+ qsurface->type);
+
+ ret.i = (int)client_drawable;
+ } else {
+ free(qsurface);
+ glo_context_destroy(context);
+ }
+ } else {
+ glo_context_destroy(context);
+ }
+ }
}
break;
}
{
/* glXPixmap same as input Pixmap */
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
- if ( qsurface &&
- qsurface != process->current_state->current_qsurface &&
- qsurface->glstate == NULL &&
- qsurface->type == SURFACE_PIXMAP )
- {
- glo_surface_destroy(qsurface->surface);
- g_free(qsurface);
- }
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process, client_drawable);
+ qsurface_pixmap_unref(qsurface);
break;
}
case glEGLImageTargetTexture2DOES_fake_func:
{
int target = args[0];
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process, client_drawable);
- /* Only support GL_TEXTURE_2D according to spec */
- if ( target == GL_TEXTURE_2D )
+ /* Only support GL_TEXTURE_2D according to spec */
+ if (target == GL_TEXTURE_2D)
add_pixmap_texture_mapping(process->current_state,
- process->current_state->bindTexture2D,
- client_drawable);
-
- if ( !qsurface )
- {
- if ( !keep_drawable(process, client_drawable) )
- {
- DEBUGF( "No space to store drawable for ImageTargetTexture. Need call CreatePixmapSurface to free them.\n");
+ process->current_state->
+ bindTexture2D, client_drawable);
+
+ if (!qsurface) {
+ if (!keep_drawable(process, client_drawable)) {
+ DEBUGF
+ ("No space to store drawable for ImageTargetTexture. Need call CreatePixmapSurface to free them.\n");
break;
}
+ } else
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface, qsurface->type);
+
+ break;
+ }
+ case glXBindTexImageARB_fake_func:
+ {
+ ClientGLXDrawable client_drawable = to_drawable(args[1]);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process, client_drawable);
+ ret.i = 0;
+
+ if (qsurface) {
+ add_pixmap_texture_mapping(process->current_state,
+ process->current_state->
+ bindTexture2D, client_drawable);
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface, qsurface->type);
+ ret.i = 1;
+ } else
+ DEBUGF("Not found pbuffer surface for BindTexImage!\n");
+
+ break;
+ }
+ case glXReleaseTexImageARB_fake_func:
+ {
+ ClientGLXDrawable client_drawable = to_drawable(args[1]);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process, client_drawable);
+
+ if (qsurface) {
+ remove_pixmap_texture_mapping(process->current_state,
+ client_drawable);
+ glo_surface_release_texture(qsurface->surface);
}
- else
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
-
- break;
- }
- case glXBindTexImageARB_fake_func:
- {
- ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
- ret.i = 0;
-
-
- if ( qsurface )
- {
- add_pixmap_texture_mapping(process->current_state,
- process->current_state->bindTexture2D,
- client_drawable);
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
- ret.i = 1;
- }
- else
- DEBUGF( "Not found pbuffer surface for BindTexImage!\n");
-
- break;
- }
- case glXReleaseTexImageARB_fake_func:
- {
- ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
-
- if ( qsurface )
- {
- remove_pixmap_texture_mapping(process->current_state,
- client_drawable);
- glo_surface_release_texture(qsurface->surface);
- }
-
- break;
- }
- case glXCreatePbuffer_func:
- {
- int client_fbconfig = args[1];
-
- ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
-
- if (fbconfig) {
-
- /* Create a light-weight context just for creating surface */
- GloContext *context = __glo_context_create(fbconfig->formatFlags);
-
- QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
-
- /* get the width and height */
- int width, height;
- glo_geometry_get_from_glx((int*)args[2], &width, &height);
-
- DEBUGF( "glXCreatePbuffer: %dX%d.\n", width, height);
- qsurface->surface = glo_surface_create(width, height, context);
- /* Use GloSurface handler as no input client_drawable, and
- * keep only low 32bit of handler on x86_64 host. */
- qsurface->client_drawable = (int)qsurface->surface;
- qsurface->type = SURFACE_PBUFFER;
- qsurface->status = SURFACE_PENDING;
- /* qsurface->ref = 1;*/
-
- /* Keep this surface, will link it with context in MakeCurrent */
- keep_qsurface(process, qsurface);
-
- ret.i = qsurface->client_drawable;
-
- }
- break;
- }
- case glXDestroyPbuffer_func:
- {
+
+ break;
+ }
+ case glXCreatePbuffer_func:
+ {
+ int client_fbconfig = args[1];
+
+ ret.i = 0;
+ const GLXFBConfig *fbconfig =
+ get_fbconfig(process, client_fbconfig);
+
+ if (fbconfig) {
+
+ /* Create a light-weight context just for creating surface */
+ GloContext *context =
+ __glo_context_create(fbconfig->formatFlags);
+ if (context) {
+ QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+ if (qsurface) {
+ /* get the width and height */
+ int width, height;
+ glo_geometry_get_from_glx((int *)args[2], &width,
+ &height);
+
+ DEBUGF("glXCreatePbuffer: %dX%d.\n", width, height);
+ qsurface->surface =
+ glo_surface_create(width, height, context);
+ if (qsurface->surface) {
+ /* Use GloSurface handler as no input client_drawable, and
+ * keep only low 32bit of handler on x86_64 host. */
+ qsurface->client_drawable =
+ (ClientGLXDrawable) (long)qsurface->surface;
+ qsurface->type = SURFACE_PBUFFER;
+ qsurface->status = SURFACE_PENDING;
+ /* qsurface->ref = 1; */
+
+ /* Keep this surface, will link it with context in MakeCurrent */
+ keep_qsurface(process, qsurface);
+
+ ret.i = qsurface->client_drawable;
+ } else {
+ free(qsurface);
+ glo_context_destroy(context);
+ }
+ } else {
+ glo_context_destroy(context);
+ }
+ }
+ }
+ break;
+ }
+ case glXDestroyPbuffer_func:
+ {
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
- if ( qsurface &&
- qsurface != process->current_state->current_qsurface &&
- qsurface->glstate == NULL &&
- qsurface->type == SURFACE_PBUFFER )
- {
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process, client_drawable);
+ if (qsurface && qsurface != process->current_state->current_qsurface
+ && qsurface->glstate == NULL
+ && qsurface->type == SURFACE_PBUFFER) {
glo_surface_destroy(qsurface->surface);
g_free(qsurface);
}
break;
- }
+ }
/* Begin of texture stuff */
case glBindTexture_func:
unsigned int client_texture = args[1];
unsigned int server_texture;
- if(((int)client_texture) < 0)
- {
- fprintf(stderr, "glBindTexture got invalid texture ID, do nothing!\n");
- break;
- }
+ if (((int)client_texture) < 0) {
+ fprintf(stderr,
+ "glBindTexture got invalid texture ID, do nothing!\n");
+ break;
+ }
if (client_texture == 0) {
glBindTexture(target, 0);
} else {
alloc_value(process->current_state->textureAllocator,
client_texture);
+ alloc_space(process->current_state->tabTextures, client_texture, 1);
server_texture =
- process->current_state->tabTextures[client_texture];
+ process->current_state->tabTextures->values[client_texture];
if (server_texture == 0) {
glGenTextures(1, &server_texture);
- process->current_state->tabTextures[client_texture] =
+ process->current_state->tabTextures->values[client_texture] =
server_texture;
}
glBindTexture(target, server_texture);
}
- if ( target == GL_TEXTURE_2D ) {
+ if (target == GL_TEXTURE_2D) {
QGloSurface *qsurface = NULL;
ClientGLXDrawable drawable =
find_pixmap_texture(process->current_state, client_texture);
- if ( drawable )
- {
- qsurface = find_qsurface_from_client_drawable(process, drawable);
+ if (drawable) {
+ qsurface =
+ find_qsurface_from_client_drawable(process, drawable);
- if ( qsurface )
- {
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
- /*fprintf(stderr, "edwin:bindtexture: drawable=0x%x,qsurface=%p.\n", drawable, qsurface);*/
+ if (qsurface) {
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface,
+ qsurface->type);
+ /*fprintf(stderr, "edwin:bindtexture: drawable=0x%x,qsurface=%p.\n", drawable, qsurface); */
}
}
process->current_state->bindTexture2D = client_texture;
}
- break;
+ break;
}
case glGenTextures_fake_func:
clientTabTextures);
//ptr_func_glGenTextures(n, serverTabTextures);
- glGenTextures(n, serverTabTextures);
+ glGenTextures(n, serverTabTextures);
for (i = 0; i < n; i++) {
- process->current_state->tabTextures[clientTabTextures[i]] =
+ alloc_space(process->current_state->tabTextures, clientTabTextures[i], 0);
+ process->current_state->tabTextures->values[clientTabTextures[i]] =
serverTabTextures[i];
}
break;
}
-
case glDeleteTextures_func:
{
//GET_EXT_PTR(void, glDeleteTextures,
// (GLsizei n, const GLuint *textures));
int i;
int n = args[0];
- unsigned int *clientTabTextures = (unsigned int *) args[1];
+ unsigned int *clientTabTextures = (unsigned int *)args[1];
delete_range(process->current_state->textureAllocator, n,
clientTabTextures);
get_server_texture(process, clientTabTextures[i]);
}
//ptr_func_glDeleteTextures(n, serverTabTextures);
- glDeleteTextures(n, serverTabTextures);
+ glDeleteTextures(n, serverTabTextures);
for (i = 0; i < n; i++) {
- process->current_state->tabTextures[clientTabTextures[i]] = 0;
+ free_space(process->current_state->tabTextures, clientTabTextures[i]);
}
g_free(serverTabTextures);
- for ( i = 0; i < n; i++ )
- {
- del_pixmap_texture_mapping(process->current_state, clientTabTextures[i]);
+ for (i = 0; i < n; i++) {
+ del_pixmap_texture_mapping(process->current_state,
+ clientTabTextures[i]);
}
- break;
+ break;
}
case glPrioritizeTextures_func:
{
GET_EXT_PTR(void, glPrioritizeTextures,
- (GLsizei n, const GLuint *textures,
- const GLclampf *priorities));
+ (GLsizei n, const GLuint * textures,
+ const GLclampf * priorities));
int i;
int n = args[0];
- unsigned int *textures = (unsigned int *) args[1];
+ unsigned int *textures = (unsigned int *)args[1];
for (i = 0; i < n; i++) {
textures[i] = get_server_texture(process, textures[i]);
}
ptr_func_glPrioritizeTextures(n, textures,
- (const GLclampf *) args[2]);
+ (const GLclampf *)args[2]);
break;
}
case glAreTexturesResident_func:
{
GET_EXT_PTR(void, glAreTexturesResident,
- (GLsizei n, const GLuint *textures,
- GLboolean *residences));
+ (GLsizei n, const GLuint * textures,
+ GLboolean * residences));
int i;
int n = args[0];
- unsigned int *textures = (unsigned int *) args[1];
+ unsigned int *textures = (unsigned int *)args[1];
for (i = 0; i < n; i++) {
textures[i] = get_server_texture(process, textures[i]);
}
- ptr_func_glAreTexturesResident(n, textures,
- (GLboolean *) args[2]);
+ ptr_func_glAreTexturesResident(n, textures, (GLboolean *) args[2]);
break;
}
unsigned int server_texture =
get_server_texture(process, client_texture);
if (server_texture)
- // ret.c = ptr_func_glIsTexture(server_texture);
- ret.c = glIsTexture(server_texture);
+ // ret.c = ptr_func_glIsTexture(server_texture);
+ ret.c = glIsTexture(server_texture);
else
ret.c = 0;
break;
unsigned int first_client = args[0];
int n = args[1];
- unsigned int first_server =
- get_server_list(process, first_client);
+ unsigned int first_server = get_server_list(process, first_client);
for (i = 0; i < n; i++) {
if (get_server_list(process, first_client + i) !=
first_server + i)
}
for (i = 0; i < n; i++) {
- process->current_state->tabLists[first_client + i] = 0;
+ free_space(process->current_state->tabLists, first_client + i);
}
delete_consecutive_values(process->current_state->listAllocator,
first_client, n);
alloc_range(process->current_state->listAllocator, n,
NULL);
for (i = 0; i < n; i++) {
- process->current_state->tabLists[client_first + i] =
+ alloc_space(process->current_state->tabLists, client_first + i, 0);
+ process->current_state->tabLists->values[client_first + i] =
server_first + i;
}
}
if (server_list == 0) {
server_list = glGenLists(1);
- process->current_state->tabLists[client_list] = server_list;
+ alloc_space(process->current_state->tabLists, client_list, 0);
+ process->current_state->tabLists->values[client_list] = server_list;
}
glNewList(server_list, mode);
break;
int i;
int n = args[0];
int type = args[1];
- const GLvoid *lists = (const GLvoid *) args[2];
+ const GLvoid *lists = (const GLvoid *)args[2];
int *new_lists = g_malloc(sizeof(int) * n);
for (i = 0; i < n; i++) {
break;
}
-
/* End of list stuff */
/* Begin of buffer stuff */
ptr_func_glGenBuffersARB(n, serverTabBuffers);
for (i = 0; i < n; i++) {
- process->current_state->tabBuffers[clientTabBuffers[i]] =
+ alloc_space(process->current_state->tabBuffers, clientTabBuffers[i], 0);
+ process->current_state->tabBuffers->values[clientTabBuffers[i]] =
serverTabBuffers[i];
}
break;
}
-
case glDeleteBuffersARB_func:
{
GET_EXT_PTR(void, glDeleteBuffersARB, (int, int *));
int i;
int n = args[0];
- unsigned int *clientTabBuffers = (unsigned int *) args[1];
+ unsigned int *clientTabBuffers = (unsigned int *)args[1];
delete_range(process->current_state->bufferAllocator, n,
clientTabBuffers);
}
ptr_func_glDeleteBuffersARB(n, serverTabBuffers);
for (i = 0; i < n; i++) {
- process->current_state->tabBuffers[clientTabBuffers[i]] = 0;
+ free_space(process->current_state->tabBuffers, clientTabBuffers[i]);
}
g_free(serverTabBuffers);
break;
int i;
int acc_length = 0;
GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
- int *tab_length = (int *) args[3];
+ int *tab_length = (int *)args[3];
for (i = 0; i < size; i++) {
tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
acc_length += tab_length[i];
}
- ptr_func_glShaderSourceARB(args[0], args[1], tab_prog,
- tab_length);
+ ptr_func_glShaderSourceARB(args[0], args[1], tab_prog, tab_length);
g_free(tab_prog);
break;
}
case glShaderSource_fake_func:
- {
- GET_EXT_PTR(void, glShaderSource, (int, int, char **, void *));
- int size = args[1];
- int i;
- int acc_length = 0;
- GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
- int *tab_length = (int *) args[3];
-
- char **tab_prog_new;
- GLint *tab_length_new;
+ {
+ GET_EXT_PTR(void, glShaderSource, (int, int, char **, void *));
+ int size = args[1];
+ int i;
+ int acc_length = 0;
+ GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
+ int *tab_length = (int *)args[3];
- tab_prog_new = malloc(args[1]* sizeof(char*));
- tab_length_new = malloc(args[1]* sizeof(GLint));
+ char **tab_prog_new;
+ GLint *tab_length_new;
- memset(tab_prog_new, 0, args[1] * sizeof(char*));
- memset(tab_length_new, 0, args[1] * sizeof(GLint));
+ tab_prog_new = malloc(args[1] * sizeof(char *));
+ tab_length_new = malloc(args[1] * sizeof(GLint));
+ memset(tab_prog_new, 0, args[1] * sizeof(char *));
+ memset(tab_length_new, 0, args[1] * sizeof(GLint));
- for (i = 0; i < size; i++) {
- tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
- acc_length += tab_length[i];
- }
+ for (i = 0; i < size; i++) {
+ tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
+ acc_length += tab_length[i];
+ }
- shadersrc_gles_to_gl(args[1], tab_prog, tab_prog_new, tab_length, tab_length_new);
+ shadersrc_gles_to_gl(args[1], (const char **)tab_prog, tab_prog_new,
+ tab_length, tab_length_new);
- if (!tab_prog_new || !tab_length_new)
- break;
+ if (!tab_prog_new || !tab_length_new)
+ break;
- ptr_func_glShaderSource(args[0], args[1], tab_prog_new, tab_length_new);
+ ptr_func_glShaderSource(args[0], args[1], tab_prog_new,
+ tab_length_new);
- for (i = 0; i < args[1]; i++) {
- free(tab_prog_new[i]);
- }
+ for (i = 0; i < args[1]; i++) {
+ free(tab_prog_new[i]);
+ }
- free(tab_prog_new);
- free(tab_length_new);
+ free(tab_prog_new);
+ free(tab_length_new);
- free(tab_prog);
+ free(tab_prog);
- break;
- }
+ break;
+ }
case glVertexPointer_fake_func:
{
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
/* DEBUGF( "glVertexPointer_fake_func size=%d, type=%d,
* stride=%d, byte_size=%d\n", size, type, stride, bytes_size); */
glVertexPointer(size, type, stride,
offset + bytes_size);
process->current_state->normalPointer =
g_realloc(process->current_state->normalPointer,
- process->current_state->normalPointerSize);
+ process->current_state->normalPointerSize);
memcpy(process->current_state->normalPointer + offset,
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
// DEBUGF( "glNormalPointer_fake_func type=%d, stride=%d,
// byte_size=%d\n", type, stride, bytes_size);
glNormalPointer(type, stride,
offset + bytes_size);
process->current_state->indexPointer =
g_realloc(process->current_state->indexPointer,
- process->current_state->indexPointerSize);
+ process->current_state->indexPointerSize);
memcpy(process->current_state->indexPointer + offset,
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
// DEBUGF( "glIndexPointer_fake_func type=%d, stride=%d,
// byte_size=%d\n", type, stride, bytes_size);
- glIndexPointer(type, stride,
- process->current_state->indexPointer);
+ glIndexPointer(type, stride, process->current_state->indexPointer);
break;
}
offset + bytes_size);
process->current_state->edgeFlagPointer =
g_realloc(process->current_state->edgeFlagPointer,
- process->current_state->edgeFlagPointerSize);
+ process->current_state->edgeFlagPointerSize);
memcpy(process->current_state->edgeFlagPointer + offset,
- (void *) args[3], bytes_size);
+ (void *)args[3], bytes_size);
// DEBUGF( "glEdgeFlagPointer_fake_func stride = %d,
// bytes_size=%d\n", stride, bytes_size);
- glEdgeFlagPointer(stride,
- process->current_state->edgeFlagPointer);
+ glEdgeFlagPointer(stride, process->current_state->edgeFlagPointer);
break;
}
offset + bytes_size);
process->current_state->vertexAttribPointer[index] =
g_realloc(process->current_state->vertexAttribPointer[index],
- process->current_state->
- vertexAttribPointerSize[index]);
- memcpy(process->current_state->vertexAttribPointer[index] +
- offset, (void *) args[7], bytes_size);
+ process->
+ current_state->vertexAttribPointerSize[index]);
+ memcpy(process->current_state->vertexAttribPointer[index] + offset,
+ (void *)args[7], bytes_size);
ptr_func_glVertexAttribPointerARB(index, size, type, normalized,
stride,
- process->current_state->
- vertexAttribPointer[index]);
+ process->
+ current_state->vertexAttribPointer
+ [index]);
break;
}
offset + bytes_size);
process->current_state->vertexAttribPointerNV[index] =
g_realloc(process->current_state->vertexAttribPointerNV[index],
- process->current_state->
- vertexAttribPointerNVSize[index]);
+ process->
+ current_state->vertexAttribPointerNVSize[index]);
memcpy(process->current_state->vertexAttribPointerNV[index] +
- offset, (void *) args[6], bytes_size);
+ offset, (void *)args[6], bytes_size);
ptr_func_glVertexAttribPointerNV(index, size, type, stride,
- process->current_state->
- vertexAttribPointerNV[index]);
+ process->
+ current_state->vertexAttribPointerNV
+ [index]);
break;
}
offset + bytes_size);
process->current_state->colorPointer =
g_realloc(process->current_state->colorPointer,
- process->current_state->colorPointerSize);
+ process->current_state->colorPointerSize);
memcpy(process->current_state->colorPointer + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
// DEBUGF( "glColorPointer_fake_func bytes_size = %d\n",
// bytes_size);
glColorPointer(size, type, stride,
case glSecondaryColorPointer_fake_func:
{
- GET_EXT_PTR(void, glSecondaryColorPointer,
- (int, int, int, void *));
+ GET_EXT_PTR(void, glSecondaryColorPointer, (int, int, int, void *));
int offset = args[0];
int size = args[1];
int type = args[2];
offset + bytes_size);
process->current_state->secondaryColorPointer =
g_realloc(process->current_state->secondaryColorPointer,
- process->current_state->secondaryColorPointerSize);
+ process->current_state->secondaryColorPointerSize);
memcpy(process->current_state->secondaryColorPointer + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
// DEBUGF( "glSecondaryColorPointer_fake_func bytes_size
// = %d\n", bytes_size);
ptr_func_glSecondaryColorPointer(size, type, stride,
- process->current_state->
- secondaryColorPointer);
+ process->
+ current_state->secondaryColorPointer);
break;
}
if (process->current_state->clientStateSp <
MAX_CLIENT_STATE_STACK_SIZE) {
- process->current_state->clientStateStack[process->
- current_state->
- clientStateSp].mask =
- mask;
+ process->current_state->
+ clientStateStack[process->current_state->clientStateSp].
+ mask = mask;
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
- process->current_state->clientStateStack[process->
- current_state->
- clientStateSp].
- activeTextureIndex =
- process->current_state->activeTextureIndex;
+ process->current_state->
+ clientStateStack
+ [process->current_state->clientStateSp].activeTextureIndex
+ = process->current_state->activeTextureIndex;
}
process->current_state->clientStateSp++;
}
{
if (process->current_state->clientStateSp > 0) {
process->current_state->clientStateSp--;
- if (process->current_state->
- clientStateStack[process->current_state->clientStateSp].
- mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ if (process->
+ current_state->clientStateStack[process->current_state->
+ clientStateSp].mask &
+ GL_CLIENT_VERTEX_ARRAY_BIT) {
process->current_state->activeTextureIndex =
- process->current_state->clientStateStack[process->
- current_state->
- clientStateSp].
- activeTextureIndex;
+ process->current_state->
+ clientStateStack
+ [process->current_state->clientStateSp].activeTextureIndex;
}
}
glPopClientAttrib();
offset + bytes_size);
process->current_state->texCoordPointer[index] =
g_realloc(process->current_state->texCoordPointer[index],
- process->current_state->texCoordPointerSize[index]);
+ process->current_state->texCoordPointerSize[index]);
memcpy(process->current_state->texCoordPointer[index] + offset,
- (void *) args[6], bytes_size);
+ (void *)args[6], bytes_size);
/* DEBUGF( "glTexCoordPointer_fake_func size=%d, type=%d,
* stride=%d, byte_size=%d\n", size, type, stride, bytes_size); */
do_glClientActiveTextureARB(GL_TEXTURE0_ARB + index);
glTexCoordPointer(size, type, stride,
process->current_state->texCoordPointer[index]);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
offset + bytes_size);
process->current_state->weightPointer =
g_realloc(process->current_state->weightPointer,
- process->current_state->weightPointerSize);
+ process->current_state->weightPointerSize);
memcpy(process->current_state->weightPointer + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
/* DEBUGF( "glWeightPointerARB_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
ptr_func_glWeightPointerARB(size, type, stride,
- process->current_state->
- weightPointer);
+ process->current_state->weightPointer);
break;
}
case glMatrixIndexPointerARB_fake_func:
{
- GET_EXT_PTR(void, glMatrixIndexPointerARB,
- (int, int, int, void *));
+ GET_EXT_PTR(void, glMatrixIndexPointerARB, (int, int, int, void *));
int offset = args[0];
int size = args[1];
int type = args[2];
offset + bytes_size);
process->current_state->matrixIndexPointer =
g_realloc(process->current_state->matrixIndexPointer,
- process->current_state->matrixIndexPointerSize);
+ process->current_state->matrixIndexPointerSize);
memcpy(process->current_state->matrixIndexPointer + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
/* DEBUGF( "glMatrixIndexPointerARB_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
ptr_func_glMatrixIndexPointerARB(size, type, stride,
- process->current_state->
- matrixIndexPointer);
+ process->
+ current_state->matrixIndexPointer);
break;
}
offset + bytes_size);
process->current_state->fogCoordPointer =
g_realloc(process->current_state->fogCoordPointer,
- process->current_state->fogCoordPointerSize);
+ process->current_state->fogCoordPointerSize);
memcpy(process->current_state->fogCoordPointer + offset,
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
// DEBUGF( "glFogCoordPointer_fake_func type=%d,
// stride=%d, byte_size=%d\n", type, stride, bytes_size);
ptr_func_glFogCoordPointer(type, stride,
- process->current_state->
- fogCoordPointer);
+ process->current_state->fogCoordPointer);
break;
}
offset + bytes_size);
process->current_state->variantPointerEXT[id] =
g_realloc(process->current_state->variantPointerEXT[id],
- process->current_state->variantPointerEXTSize[id]);
+ process->current_state->variantPointerEXTSize[id]);
memcpy(process->current_state->variantPointerEXT[id] + offset,
- (void *) args[5], bytes_size);
+ (void *)args[5], bytes_size);
// DEBUGF( "glVariantPointerEXT_fake_func[%d] type=%d,
// stride=%d, byte_size=%d\n", id, type, stride, bytes_size);
ptr_func_glVariantPointerEXT(id, type, stride,
- process->current_state->
- variantPointerEXT[id]);
+ process->
+ current_state->variantPointerEXT[id]);
break;
}
offset + bytes_size);
process->current_state->interleavedArrays =
g_realloc(process->current_state->interleavedArrays,
- process->current_state->interleavedArraysSize);
+ process->current_state->interleavedArraysSize);
memcpy(process->current_state->interleavedArrays + offset,
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
// DEBUGF( "glInterleavedArrays_fake_func format=%d,
// stride=%d, byte_size=%d\n", format, stride, bytes_size);
ptr_func_glInterleavedArrays(format, stride,
- process->current_state->
- interleavedArrays);
+ process->
+ current_state->interleavedArrays);
break;
}
process->current_state->elementPointerATISize = bytes_size;
process->current_state->elementPointerATI =
g_realloc(process->current_state->elementPointerATI,
- process->current_state->elementPointerATISize);
+ process->current_state->elementPointerATISize);
memcpy(process->current_state->elementPointerATI,
- (void *) args[2], bytes_size);
+ (void *)args[2], bytes_size);
// DEBUGF( "glElementPointerATI_fake_func type=%d,
// byte_size=%d\n", type, bytes_size);
ptr_func_glElementPointerATI(type,
- process->current_state->
- elementPointerATI);
+ process->
+ current_state->elementPointerATI);
break;
}
process->current_state->texCoordPointerSize[0] = bytes_size;
process->current_state->texCoordPointer[0] =
g_realloc(process->current_state->texCoordPointer[0],
- bytes_size);
+ bytes_size);
memcpy(process->current_state->texCoordPointer[0],
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
/* DEBUGF( "glTexCoordPointer01_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
glTexCoordPointer(size, type, stride,
process->current_state->texCoordPointer[0]);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
process->current_state->texCoordPointerSize[0] = bytes_size;
process->current_state->texCoordPointer[0] =
g_realloc(process->current_state->texCoordPointer[0],
- bytes_size);
+ bytes_size);
memcpy(process->current_state->texCoordPointer[0],
- (void *) args[4], bytes_size);
+ (void *)args[4], bytes_size);
/* DEBUGF( "glTexCoordPointer012_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
glTexCoordPointer(size, type, stride,
process->current_state->texCoordPointer[0]);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int normalPointerType = args[3];
int normalPointerStride = args[4];
int bytes_size = args[5];
- void *ptr = (void *) args[6];
+ void *ptr = (void *)args[6];
process->current_state->vertexPointerSize = bytes_size;
process->current_state->vertexPointer =
int normalPointerOffset = args[i++];
int normalPointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
int mode = args[0];
int count = args[1];
int isColorEnabled = args[2];
- void *ptr = (void *) args[3];
+ void *ptr = (void *)args[3];
int stride =
6 * sizeof(float) +
((isColorEnabled) ? 4 * sizeof(unsigned char) : 0);
ptr + 6 * sizeof(float));
glDrawArrays(mode, 0, count);
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+#ifdef __APPLE__ //only for mac
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0)
+ glFlush();
+ }
#endif
break;
int colorPointerSize = args[i++];
int colorPointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord0PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord0PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord1PointerSize = args[i++];
int texCoord1PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord1PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord2PointerSize = args[i++];
int texCoord2PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord2PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord0PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord1PointerSize = args[i++];
int texCoord1PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord1PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
int texCoord2PointerSize = args[i++];
int texCoord2PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
offset + bytes_size);
process->current_state->vertexPointer =
g_realloc(process->current_state->vertexPointer,
- process->current_state->vertexPointerSize);
+ process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset, ptr,
bytes_size);
glVertexPointer(vertexPointerSize, vertexPointerType, stride,
process->current_state->vertexPointer +
texCoord2PointerOffset);
do_glClientActiveTextureARB(GL_TEXTURE0_ARB +
- process->current_state->
- activeTextureIndex);
+ process->
+ current_state->activeTextureIndex);
break;
}
case _glVertexPointer_buffer_func:
{
- glVertexPointer(args[0], args[1], args[2], (void *) args[3]);
+ glVertexPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
case _glNormalPointer_buffer_func:
{
- glNormalPointer(args[0], args[1], (void *) args[2]);
+ glNormalPointer(args[0], args[1], (void *)args[2]);
break;
}
case _glColorPointer_buffer_func:
{
- glColorPointer(args[0], args[1], args[2], (void *) args[3]);
+ glColorPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
case _glSecondaryColorPointer_buffer_func:
{
- GET_EXT_PTR(void, glSecondaryColorPointer,
- (int, int, int, void *));
+ GET_EXT_PTR(void, glSecondaryColorPointer, (int, int, int, void *));
ptr_func_glSecondaryColorPointer(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
case _glIndexPointer_buffer_func:
{
- glIndexPointer(args[0], args[1], (void *) args[2]);
+ glIndexPointer(args[0], args[1], (void *)args[2]);
break;
}
case _glTexCoordPointer_buffer_func:
{
- glTexCoordPointer(args[0], args[1], args[2], (void *) args[3]);
+ glTexCoordPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
case _glEdgeFlagPointer_buffer_func:
{
- glEdgeFlagPointer(args[0], (void *) args[1]);
+ glEdgeFlagPointer(args[0], (void *)args[1]);
break;
}
(int, int, int, int, int, void *));
ptr_func_glVertexAttribPointerARB(args[0], args[1], args[2],
args[3], args[4],
- (void *) args[5]);
+ (void *)args[5]);
break;
}
GET_EXT_PTR(void, glWeightPointerARB, (int, int, int, void *));
ptr_func_glWeightPointerARB(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
case _glMatrixIndexPointerARB_buffer_func:
{
- GET_EXT_PTR(void, glMatrixIndexPointerARB,
- (int, int, int, void *));
+ GET_EXT_PTR(void, glMatrixIndexPointerARB, (int, int, int, void *));
ptr_func_glMatrixIndexPointerARB(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
{
GET_EXT_PTR(void, glFogCoordPointer, (int, int, void *));
- ptr_func_glFogCoordPointer(args[0], args[1], (void *) args[2]);
+ ptr_func_glFogCoordPointer(args[0], args[1], (void *)args[2]);
break;
}
GET_EXT_PTR(void, glVariantPointerEXT, (int, int, int, void *));
ptr_func_glVariantPointerEXT(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
case _glDrawElements_buffer_func:
{
- glDrawElements(args[0], args[1], args[2], (void *) args[3]);
+ glDrawElements(args[0], args[1], args[2], (void *)args[3]);
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+#ifdef __APPLE__ //only for mac
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0)
+ glFlush();
+ }
#endif
break;
case _glDrawRangeElements_buffer_func:
{
glDrawRangeElements(args[0], args[1], args[2], args[3], args[4],
- (void *) args[5]);
+ (void *)args[5]);
break;
}
#endif
{
GET_EXT_PTR(void, glMultiDrawElements,
(int, int *, int, void **, int));
- ptr_func_glMultiDrawElements(args[0], (int *) args[1], args[2],
- (void **) args[3], args[4]);
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+ ptr_func_glMultiDrawElements(args[0], (int *)args[1], args[2],
+ (void **)args[3], args[4]);
+#ifdef __APPLE__ //only for mac
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0)
+ glFlush();
+ }
#endif
- break;
- }
-#ifdef __APPLE__ // only for mac
- case glDrawArrays_func:
- {
- int prev_fbo;
- glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_INT(args[2]));
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- break;
- }
- case glDrawElements_func:
- {
- int prev_fbo;
- glDrawElements(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_UNSIGNED_INT(args[2]), (const void*)(args[3]));
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- break;
- }
+ break;
+ }
+#ifdef __APPLE__ // only for mac
+ case glDrawArrays_func:
+ {
+ int prev_fbo;
+ glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0)
+ glFlush();
+ break;
+ }
+ case glDrawElements_func:
+ {
+ int prev_fbo;
+ glDrawElements(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_UNSIGNED_INT(args[2]),
+ (const void *)(args[3]));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0)
+ glFlush();
+ break;
+ }
#endif
case _glGetError_fake_func:
case glGetIntegerv_func:
{
- glGetIntegerv(args[0], (int *) args[1]);
+ glGetIntegerv(args[0], (int *)args[1]);
break;
}
glReadPixels(ARG_TO_INT(args[0]), ARG_TO_INT(args[1]),
ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
ARG_TO_UNSIGNED_INT(args[4]),
- ARG_TO_UNSIGNED_INT(args[5]), (void *) (args[6]));
+ ARG_TO_UNSIGNED_INT(args[5]), (void *)(args[6]));
break;
}
{
glDrawPixels(ARG_TO_INT(args[0]), ARG_TO_INT(args[1]),
ARG_TO_UNSIGNED_INT(args[2]),
- ARG_TO_UNSIGNED_INT(args[3]),
- (const void *) (args[4]));
+ ARG_TO_UNSIGNED_INT(args[3]), (const void *)(args[4]));
break;
}
GET_EXT_PTR(GLboolean, glUnmapBufferARB, (GLenum));
int target = args[0];
int size = args[1];
- void *dst_ptr = (void *) args[2];
+ void *dst_ptr = (void *)args[2];
void *src_ptr = ptr_func_glMapBufferARB(target, GL_READ_ONLY);
if (src_ptr) {
GET_GLU_PTR(GLint, gluBuild2DMipmaps,
(GLenum arg_0, GLint arg_1, GLsizei arg_2,
GLsizei arg_3, GLenum arg_4, GLenum arg_5,
- const GLvoid *arg_6));
+ const GLvoid * arg_6));
if (ptr_func_gluBuild2DMipmaps == NULL)
ptr_func_gluBuild2DMipmaps = mesa_gluBuild2DMipmaps;
ptr_func_gluBuild2DMipmaps(ARG_TO_UNSIGNED_INT(args[0]),
ARG_TO_INT(args[3]),
ARG_TO_UNSIGNED_INT(args[4]),
ARG_TO_UNSIGNED_INT(args[5]),
- (const void *) (args[6]));
+ (const void *)(args[6]));
break;
}
process->current_state->selectBufferSize = args[0] * 4;
process->current_state->selectBufferPtr =
g_realloc(process->current_state->selectBufferPtr,
- process->current_state->selectBufferSize);
+ process->current_state->selectBufferSize);
glSelectBuffer(args[0], process->current_state->selectBufferPtr);
break;
}
case _glGetSelectBuffer_fake_func:
{
- void *ptr = (void *) args[0];
+ void *ptr = (void *)args[0];
memcpy(ptr, process->current_state->selectBufferPtr,
process->current_state->selectBufferSize);
process->current_state->feedbackBufferSize = args[0] * 4;
process->current_state->feedbackBufferPtr =
g_realloc(process->current_state->feedbackBufferPtr,
- process->current_state->feedbackBufferSize);
- glFeedbackBuffer((GLsizei)args[0], (GLenum) args[1],
+ process->current_state->feedbackBufferSize);
+ glFeedbackBuffer((GLsizei) args[0], (GLenum) args[1],
process->current_state->feedbackBufferPtr);
break;
}
case _glGetFeedbackBuffer_fake_func:
{
- void *ptr = (void *) args[0];
+ void *ptr = (void *)args[0];
memcpy(ptr, process->current_state->feedbackBufferPtr,
process->current_state->feedbackBufferSize);
GET_EXT_PTR(int, glNewObjectBufferATI, (int, void *, int));
ret.i = ptr_func_glNewObjectBufferATI(args[0],
- (void *) args[1], args[2]);
+ (void *)args[1], args[2]);
break;
}
case glClear_func:
- glClear((GLbitfield)args[0]);
+ glClear((GLbitfield) args[0]);
break;
#if 0
/* HACK workaround for an unexplainable issue */
#endif
#ifdef _WIN32
- /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver
- * should calculate it for glTexSubImage2D according to width parameter and
- * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia,
- * don't follow it. So we need do it for the driver, and probably remove
- * this hack in future if driver get fixed.
- */
- case glTexSubImage2D_func:
- {
- int origin_row_length, alignment, width;
-
- if (args[6] == GL_ALPHA) {
- width = args[4];
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length);
-
- if (width%alignment != 0) {
- width = (width/alignment + 1) * alignment;
- }
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
- }
-
- glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
- ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
- ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
- ARG_TO_UNSIGNED_INT(args[6]),
- ARG_TO_UNSIGNED_INT(args[7]), (const void*)(args[8]));
-
- if (args[6] == GL_ALPHA)
- glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length);
-
- break;
- }
+ /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver
+ * should calculate it for glTexSubImage2D according to width parameter and
+ * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia,
+ * don't follow it. So we need do it for the driver, and probably remove
+ * this hack in future if driver get fixed.
+ */
+ case glTexSubImage2D_func:
+ {
+ int origin_row_length, alignment, width;
+
+ if (args[6] == GL_ALPHA) {
+ width = args[4];
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length);
+
+ if (width % alignment != 0) {
+ width = (width / alignment + 1) * alignment;
+ }
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
+ }
+
+ glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
+ ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
+ ARG_TO_UNSIGNED_INT(args[6]),
+ ARG_TO_UNSIGNED_INT(args[7]),
+ (const void *)(args[8]));
+
+ if (args[6] == GL_ALPHA)
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length);
+
+ break;
+ }
#endif
#ifdef __APPLE__
- case glTexSubImage2D_func:
- {
-
- glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
- ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
- ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
- ARG_TO_UNSIGNED_INT(args[6]), ARG_TO_UNSIGNED_INT(args[7]),
- (const void*)(args[8]));
-
- if ( ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D &&
- ARG_TO_INT(args[1]) == 0 &&
- ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA &&
- ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE )
- mac_dump_texture();
- else
- fprintf(stderr, "!!! Probable screen crash, no work around as glTexSubImage2d parameters do not match!\n");
-
- break;
- }
+ case glTexSubImage2D_func:
+ {
+
+ glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
+ ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
+ ARG_TO_UNSIGNED_INT(args[6]),
+ ARG_TO_UNSIGNED_INT(args[7]),
+ (const void *)(args[8]));
+
+ if (ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D &&
+ ARG_TO_INT(args[1]) == 0 &&
+ ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA &&
+ ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE)
+ mac_dump_texture();
+ else
+ fprintf(stderr,
+ "!!! Probable screen crash, no work around as glTexSubImage2d parameters do not match!\n");
+
+ break;
+ }
#endif
default:
- execute_func(func_number, (void**)args, &ret);
+ execute_func(func_number, (void **)args, &ret);
break;
}
}
default:
- DEBUGF( "unexpected ret type : %d\n", ret_type);
+ DEBUGF("unexpected ret type : %d\n", ret_type);
exit(-1);
break;
}
+ if (TRACE_ON(qemu)) {
+ gettimeofday(&t1, NULL);
+ qemu_timersub(&t1, &t0, &t1);
+ unsigned long duration = t1.tv_sec * 1000000 + t1.tv_usec;
+ struct GLCallStatInfo *stats = &(process->stats[func_number]);
+ stats->n++;
+ stats->total += duration;
+ if (duration > stats->max)
+ stats->max = duration;
+ if (stats->total > 0)
+ TRACE("[%d]< %s (n %llu, total %llu, max %llu, moy %llu)\n",
+ process->p.process_id, tab_opengl_calls_name[func_number],
+ stats->n, stats->total, stats->max, stats->total / stats->n);
+ }
+
if (display_function_call)
- DEBUGF( "[%d]< %s\n", process->p.process_id,
- tab_opengl_calls_name[func_number]);
+ DEBUGF("[%d]< %s\n", process->p.process_id,
+ tab_opengl_calls_name[func_number]);
return ret.i;
}
* THE SOFTWARE.
*/
-
#include <sys/types.h>
-extern void gl_disconnect(ProcessStruct *process);
+extern void gl_disconnect(ProcessStruct * process);
extern ProcessStruct *vmgl_get_process(pid_t pid);
-extern void vmgl_context_switch(ProcessStruct *process, int switch_gl_context);
-extern int do_function_call(ProcessStruct *process, int func_number,
+extern void vmgl_context_switch(ProcessStruct * process, int switch_gl_context);
+extern int do_function_call(ProcessStruct * process, int func_number,
unsigned long *args, char *ret_string);
#ifdef TARGET_X86_64
#define TARGET_LONG_BITS 64
-#define TARGET_PHYS_ADDR_BITS 64
#else
#define TARGET_LONG_BITS 32
-#define TARGET_PHYS_ADDR_BITS 32
#endif
//#define NEED_CPU_H
#define CASE_POINTERS CASE_IN_POINTERS: CASE_OUT_POINTERS
#define CASE_KNOWN_SIZE_POINTERS CASE_IN_KNOWN_SIZE_POINTERS: CASE_OUT_KNOWN_SIZE_POINTERS
-
#define IS_ARRAY_CHAR(type) (type == TYPE_ARRAY_CHAR || type == TYPE_1CHAR || type == TYPE_2CHAR || type == TYPE_3CHAR || type == TYPE_4CHAR || type == TYPE_ARRAY_CHAR_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS)
#define IS_ARRAY_SHORT(type) (type == TYPE_ARRAY_SHORT || type == TYPE_1SHORT || type == TYPE_2SHORT || type == TYPE_3SHORT || type == TYPE_4SHORT || type == TYPE_ARRAY_SHORT_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS)
#define IS_ARRAY_INT(type) (type == TYPE_ARRAY_INT || type == TYPE_1INT || type == TYPE_2INT || type == TYPE_3INT || type == TYPE_4INT || type == TYPE_ARRAY_INT_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS)
{ TYPE_NONE, 1, 3, TYPE_INT, TYPE_INT, TYPE_OUT_1INT };
static const int _resize_surface_signature[] =
- {TYPE_NONE, 0, 3, TYPE_INT, TYPE_INT, TYPE_INT};
+ { TYPE_NONE, 0, 3, TYPE_INT, TYPE_INT, TYPE_INT };
static const int _render_surface_signature[] =
- {TYPE_NONE, 1, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_OUT_ARRAY_CHAR};
+ { TYPE_NONE, 1, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_OUT_ARRAY_CHAR };
/* XVisualInfo* glXChooseVisual( Display *dpy, int screen, int *attribList ) */
static const int glXChooseVisual_signature[] =
static const int glXCopyContext_signature[] =
{ TYPE_NONE, 0, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_INT };
+ TYPE_INT
+};
/* void glXDestroyContext( Display *dpy, GLXContext ctx ) */
static const int glXDestroyContext_signature[] =
int attrib, int *value )*/
static const int glXGetConfig_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
/* "glXGetConfig_extended"(dpy, visual_id, int n, int* attribs, int* values, int* rets) */
static const int glXGetConfig_extended_signature[] =
{ TYPE_NONE, 1, 6, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_INT, TYPE_OUT_ARRAY_INT, TYPE_OUT_ARRAY_INT };
+ TYPE_ARRAY_INT, TYPE_OUT_ARRAY_INT, TYPE_OUT_ARRAY_INT
+};
/* void glXSwapBuffers( Display *dpy, GLXDrawable drawable ); */
static const int glXSwapBuffers_signature[] =
static const int glXQueryServerString_signature[] =
{ TYPE_CONST_CHAR, 0, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT };
-
static const int glXGetProcAddress_fake_signature[] =
{ TYPE_INT, 0, 1, TYPE_NULL_TERMINATED_STRING };
static const int glXGetProcAddress_global_fake_signature[] =
{ TYPE_NONE, 1, 3, TYPE_INT, TYPE_ARRAY_CHAR, TYPE_OUT_ARRAY_CHAR };
-
/* GLX 1.3 and later */
/*
const int *attribList, int *nitems ); */
static const int glXChooseFBConfig_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_ARRAY_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXChooseFBConfigSGIX_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_ARRAY_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXGetFBConfigs_signature[] =
{ TYPE_INT, 1, 3, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_OUT_1INT };
/* "glXGetFBConfigAttrib_extended"(dpy, fbconfig, int n, int* attribs, int* values, int* rets) */
static const int glXGetFBConfigAttrib_extended_signature[] =
{ TYPE_NONE, 1, 6, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_INT, TYPE_OUT_ARRAY_INT, TYPE_OUT_ARRAY_INT };
-
+ TYPE_ARRAY_INT, TYPE_OUT_ARRAY_INT, TYPE_OUT_ARRAY_INT
+};
/* GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
const int *attribList ) */
static const int glXCreateGLXPbufferSGIX_signature[] =
{ TYPE_INT, 0, 5, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_INT };
+ TYPE_ARRAY_INT
+};
static const int glXDestroyPbuffer_signature[] =
{ TYPE_NONE, 0, 2, TYPE_IN_IGNORED_POINTER, TYPE_INT };
Bool Direct) */
static const int glXCreateNewContext_signature[] =
{ TYPE_INT, 0, 5, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT };
+ TYPE_INT
+};
static const int glXCreateContextWithConfigSGIX_signature[] =
{ TYPE_INT, 0, 5, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT };
+ TYPE_INT
+};
/*XVisualInfo *glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) */
static const int glXGetVisualFromFBConfig_signature[] =
/*int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)*/
static const int glXGetFBConfigAttrib_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXGetFBConfigAttribSGIX_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXQueryContext_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXQueryGLXPbufferSGIX_signature[] =
{ TYPE_INT, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
static const int glXQueryDrawable_signature[] =
{ TYPE_NONE, 1, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
-TYPE_OUT_1INT };
+ TYPE_OUT_1INT
+};
/* void glXUseXFont( Font font, int first, int count, int list ) */
static const int glXUseXFont_signature[] =
static const int glXGetDriverConfig_signature[] =
{ TYPE_CONST_CHAR, 0, 1, TYPE_NULL_TERMINATED_STRING };
-
static const int glXWaitVideoSyncSGI_signature[] =
{ TYPE_INT, 1, 3, TYPE_INT, TYPE_INT, TYPE_OUT_1INT };
static const int glXGetVideoSyncSGI_signature[] =
{ TYPE_INT, 1, 1, TYPE_OUT_1INT };
-static const int glXSwapIntervalSGI_signature[] =
- { TYPE_INT, 0, 1, TYPE_INT };
+static const int glXSwapIntervalSGI_signature[] = { TYPE_INT, 0, 1, TYPE_INT };
static const int glXCreatePixmap_signature[] =
- { TYPE_INT, 0, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT, TYPE_ARRAY_INT };
+ { TYPE_INT, 0, 4, TYPE_IN_IGNORED_POINTER, TYPE_INT, TYPE_INT,
+TYPE_ARRAY_INT };
static const int glXDestroyPixmap_signature[] =
{ TYPE_NONE, 0, 2, TYPE_IN_IGNORED_POINTER, TYPE_INT };
{ TYPE_NONE, 0, 2, TYPE_UNSIGNED_INT, TYPE_INT };
/* const GLubyte * glGetString( GLenum name ) */
-static const int glGetString_signature[] =
- { TYPE_CONST_CHAR, 0, 1, TYPE_INT };
+static const int glGetString_signature[] = { TYPE_CONST_CHAR, 0, 1, TYPE_INT };
/* void glShaderSourceARB (GLhandleARB handle , GLsizei size, const GLcharARB* *p_tab_prog, const GLint * tab_length) */
/* --> void glShaderSourceARB (GLhandleARB handle , GLsizei size, const GLcharARB* all_progs, const GLint * tab_length) */
static const int glVertexPointer_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glNormalPointer_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glColorPointer_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glSecondaryColorPointer_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glIndexPointer_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glTexCoordPointer_fake_signature[] =
{ TYPE_NONE, 0, 7, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_ARRAY_CHAR
+};
static const int glEdgeFlagPointer_fake_signature[] =
{ TYPE_NONE, 0, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
static const int glVertexAttribPointerARB_fake_signature[] =
{ TYPE_NONE, 0, 8, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexAttribPointerNV_fake_signature[] =
{ TYPE_NONE, 0, 7, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glWeightPointerARB_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glMatrixIndexPointerARB_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glFogCoordPointer_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glInterleavedArrays_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
static const int glElementPointerATI_fake_signature[] =
{ TYPE_NONE, 0, 3, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
static const int glVariantPointerEXT_fake_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
static const int glTuxRacerDrawElements_fake_signature[] =
{ TYPE_NONE, 0, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
static const int glVertexAndNormalPointer_fake_signature[] =
{ TYPE_NONE, 0, 7, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glTexCoordPointer01_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glTexCoordPointer012_fake_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_ARRAY_CHAR
+};
+
static const int glVertexNormalPointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 8, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexNormalColorPointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 11, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexColorTexCoord0PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 12, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexNormalTexCoord0PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 11, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexNormalTexCoord01PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 14, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+ TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int glVertexNormalTexCoord012PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 17, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int
- glVertexNormalColorTexCoord0PointerInterlaced_fake_signature[] =
+ glVertexNormalColorTexCoord0PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 14, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+ TYPE_INT,
+ TYPE_ARRAY_CHAR
+};
+
static const int
- glVertexNormalColorTexCoord01PointerInterlaced_fake_signature[] =
+ glVertexNormalColorTexCoord01PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 17, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+ TYPE_INT,
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
+
static const int
- glVertexNormalColorTexCoord012PointerInterlaced_fake_signature[] =
+ glVertexNormalColorTexCoord012PointerInterlaced_fake_signature[] =
{ TYPE_NONE, 0, 20, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR };
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+ TYPE_INT,
+ TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_ARRAY_CHAR
+};
-static const int glGenTextures_fake_signature[] =
- { TYPE_NONE, 0, 1, TYPE_INT };
+static const int glGenTextures_fake_signature[] = { TYPE_NONE, 0, 1, TYPE_INT };
static const int glGenBuffersARB_fake_signature[] =
{ TYPE_NONE, 0, 1, TYPE_INT };
static const int glGenLists_fake_signature[] = { TYPE_NONE, 0, 1, TYPE_INT };
{ TYPE_NONE, 0, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT };
static const int _glDrawRangeElements_buffer_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT };
+ TYPE_INT
+};
+
static const int _glMultiDrawElements_buffer_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_ARRAY_INT, TYPE_INT, TYPE_ARRAY_INT,
-TYPE_INT };
+ TYPE_INT
+};
static const int _glVertexPointer_buffer_signature[] =
{ TYPE_NONE, 0, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT };
{ TYPE_NONE, 0, 2, TYPE_INT, TYPE_INT };
static const int _glVertexAttribPointerARB_buffer_signature[] =
{ TYPE_NONE, 0, 6, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT };
+ TYPE_INT
+};
static const int _glWeightPointerARB_buffer_signature[] =
{ TYPE_NONE, 0, 4, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT };
static const int _glMatrixIndexPointerARB_buffer_signature[] =
static const int _glReadPixels_pbo_signature[] =
{ TYPE_INT, 0, 7, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
-TYPE_INT, TYPE_INT };
+ TYPE_INT, TYPE_INT
+};
static const int _glDrawPixels_pbo_signature[] =
{ TYPE_NONE, 0, 5, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT };
static const int _glMapBufferARB_fake_signature[] =
func_number == glBufferDataARB_func || \
func_number == glNewObjectBufferATI_func)
-#endif // INCLUDE_OPENGL_FUNC_H
-
+#endif // INCLUDE_OPENGL_FUNC_H
* THE SOFTWARE.
*/
+#ifndef __OPENGL_PROCESS_H
+#define __OPENGL_PROCESS_H
+
typedef struct {
int process_id;
int wordsize;
int rq_l, rrq_l;
- int sum; // Debugging only
+ int sum; // Debugging only
char *rq, *rq_p;
char *rrq, *rrq_p;
} ProcessStruct;
+#endif
#define GL_INCLUDE_PATH "../tizen/src/hw/"
-
-int isExtByName(const char* name)
+int isExtByName(const char *name)
{
- return (strstr(name, "ARB") != NULL) ||
- (strstr(name, "IBM") != NULL) ||
- (strstr(name, "EXT") != NULL) ||
- (strstr(name, "ATI") != NULL) ||
- (strstr(name, "NV") != NULL) ||
- (strstr(name, "MESA") != NULL) ||
- (strstr(name, "APPLE") != NULL) ||
- (strstr(name, "SUN") != NULL) ||
- (strstr(name, "SGI") != NULL);
+ return (strstr(name, "ARB") != NULL) ||
+ (strstr(name, "IBM") != NULL) ||
+ (strstr(name, "EXT") != NULL) ||
+ (strstr(name, "ATI") != NULL) ||
+ (strstr(name, "NV") != NULL) ||
+ (strstr(name, "MESA") != NULL) ||
+ (strstr(name, "APPLE") != NULL) ||
+ (strstr(name, "SUN") != NULL) || (strstr(name, "SGI") != NULL);
}
-char* get_arg_type(char* s)
+char *get_arg_type(char *s)
{
- while(*s == ' ' || *s == '\t') s++;
- char* n = s;
- char* c = strstr(n, "const");
- if (c)
- n += 6;
-
- char* t = strstr(n, " ");
- if (t)
- {
- if (t[1] == '*')
- t += 2;
- t[0] = 0;
- char* ori = t;
- t = strstr(t+1, "[");
- if (t)
- {
- memmove(ori, t, strlen(t));
- strstr(ori, "]")[1] = 0;
+ while (*s == ' ' || *s == '\t')
+ s++;
+ char *n = s;
+ char *c = strstr(n, "const");
+ if (c)
+ n += 6;
+
+ char *t = strstr(n, " ");
+ if (t) {
+ if (t[1] == '*')
+ t += 2;
+ t[0] = 0;
+ char *ori = t;
+ t = strstr(t + 1, "[");
+ if (t) {
+ memmove(ori, t, strlen(t));
+ strstr(ori, "]")[1] = 0;
+ }
}
- }
- return strdup(s);
+ return strdup(s);
}
-typedef struct
-{
- char* type;
- char* name;
- int nargs;
- char** args;
- int ok;
- int just_for_server_side;
- int has_out_parameters;
- int isExt;
+typedef struct {
+ char *type;
+ char *name;
+ int nargs;
+ char **args;
+ int ok;
+ int just_for_server_side;
+ int has_out_parameters;
+ int isExt;
} FuncDesc;
-int isExt(FuncDesc* func)
+int isExt(FuncDesc * func)
{
- return func->isExt;
+ return func->isExt;
}
-char* get_type_string(char* type)
+char *get_type_string(char *type)
{
- if (strstr(type, "[16]"))
- {
- if (strstr(type, "float"))
- return ("TYPE_16FLOAT");
- else if (strstr(type, "double"))
- return ("TYPE_16DOUBLE");
- else
- {
- printf("inconnu %s\n", type);
- exit(-1);
+ if (strstr(type, "[16]")) {
+ if (strstr(type, "float"))
+ return ("TYPE_16FLOAT");
+ else if (strstr(type, "double"))
+ return ("TYPE_16DOUBLE");
+ else {
+ printf("inconnu %s\n", type);
+ exit(-1);
+ }
+ } else if (strstr(type, "[128]") && strstr(type, "GLubyte"))
+ return strstr(type, "const") ? "TYPE_128UCHAR" : "TYPE_OUT_128UCHAR";
+ else if (strstr(type, "const GLvoid *"))
+ return "TYPE_ARRAY_VOID";
+ else if (strstr(type, "const GLchar *") ||
+ strstr(type, "const GLcharARB *"))
+ return "TYPE_NULL_TERMINATED_STRING";
+ else if (strstr(type, "const GLbyte *"))
+ return "TYPE_ARRAY_SIGNED_CHAR";
+ else if (strstr(type, "const GLubyte *"))
+ return "TYPE_ARRAY_UNSIGNED_CHAR";
+ else if (strstr(type, "const GLshort *"))
+ return "TYPE_ARRAY_SHORT";
+ else if (strstr(type, "const GLushort *") ||
+ strstr(type, "const GLhalfNV *"))
+ return "TYPE_ARRAY_UNSIGNED_SHORT";
+ else if (strstr(type, "const GLint *"))
+ return "TYPE_ARRAY_INT";
+ else if (strstr(type, "const GLuint *") || strstr(type, "const GLenum *"))
+ return "TYPE_ARRAY_UNSIGNED_INT";
+ else if (strstr(type, "const GLfloat *") ||
+ strstr(type, "const GLclampf *"))
+ return "TYPE_ARRAY_FLOAT";
+ else if (strstr(type, "const GLdouble *"))
+ return "TYPE_ARRAY_DOUBLE";
+ else if (strstr(type, "GLvoid *"))
+ return "TYPE_OUT_ARRAY_VOID";
+ else if (strstr(type, "GLboolean *") || strstr(type, "GLubyte *"))
+ return "TYPE_OUT_ARRAY_UNSIGNED_CHAR";
+ else if (strstr(type, "GLcharARB *") || strstr(type, "GLchar *"))
+ return "TYPE_OUT_ARRAY_CHAR";
+ else if (strstr(type, "GLshort *"))
+ return "TYPE_OUT_ARRAY_SHORT";
+ else if (strstr(type, "GLushort *"))
+ return "TYPE_OUT_ARRAY_UNSIGNED_SHORT";
+ else if (strstr(type, "GLint *") || strstr(type, "GLsizei *"))
+ return "TYPE_OUT_ARRAY_INT";
+ else if (strstr(type, "GLuint *") ||
+ strstr(type, "GLenum *") || strstr(type, "GLhandleARB *"))
+ return "TYPE_OUT_ARRAY_UNSIGNED_INT";
+ else if (strstr(type, "GLfloat *"))
+ return "TYPE_OUT_ARRAY_FLOAT";
+ else if (strstr(type, "GLdouble *"))
+ return "TYPE_OUT_ARRAY_DOUBLE";
+ else if (strcmp(type, "void") == 0)
+ return ("TYPE_NONE");
+ else if (strcmp(type, "GLbyte") == 0)
+ return ("TYPE_CHAR");
+ else if (strcmp(type, "GLubyte") == 0 || strcmp(type, "GLboolean") == 0)
+ return ("TYPE_UNSIGNED_CHAR");
+ else if (strcmp(type, "GLshort") == 0)
+ return ("TYPE_SHORT");
+ else if (strcmp(type, "GLushort") == 0 || strcmp(type, "GLhalfNV") == 0)
+ return ("TYPE_UNSIGNED_SHORT");
+ else if (strcmp(type, "GLint") == 0 ||
+ strcmp(type, "GLsizei") == 0 ||
+ strcmp(type, "GLintptr") == 0 ||
+ strcmp(type, "GLsizeiptr") == 0 ||
+ strcmp(type, "GLintptrARB") == 0 ||
+ strcmp(type, "GLsizeiptrARB") == 0)
+ return ("TYPE_INT");
+ else if (strcmp(type, "GLenum") == 0 ||
+ strcmp(type, "GLuint") == 0 ||
+ strcmp(type, "GLhandleARB") == 0 ||
+ strcmp(type, "GLbitfield") == 0)
+ return ("TYPE_UNSIGNED_INT");
+ else if (strcmp(type, "GLfloat") == 0 || strcmp(type, "GLclampf") == 0)
+ return ("TYPE_FLOAT");
+ else if (strcmp(type, "GLdouble") == 0 || strcmp(type, "GLclampd") == 0)
+ return ("TYPE_DOUBLE");
+ else {
+ printf("inconnu %s\n", type);
+ exit(-1);
}
- }
- else if (strstr(type, "[128]") && strstr(type, "GLubyte"))
- return strstr(type, "const") ? "TYPE_128UCHAR" : "TYPE_OUT_128UCHAR";
- else if (strstr(type, "const GLvoid *"))
- return "TYPE_ARRAY_VOID";
- else if (strstr(type, "const GLchar *") ||
- strstr(type, "const GLcharARB *"))
- return "TYPE_NULL_TERMINATED_STRING";
- else if (strstr(type, "const GLbyte *"))
- return "TYPE_ARRAY_SIGNED_CHAR";
- else if (strstr(type, "const GLubyte *"))
- return "TYPE_ARRAY_UNSIGNED_CHAR";
- else if (strstr(type, "const GLshort *"))
- return "TYPE_ARRAY_SHORT";
- else if (strstr(type, "const GLushort *") ||
- strstr(type, "const GLhalfNV *"))
- return "TYPE_ARRAY_UNSIGNED_SHORT";
- else if (strstr(type, "const GLint *"))
- return "TYPE_ARRAY_INT";
- else if (strstr(type, "const GLuint *") ||
- strstr(type, "const GLenum *"))
- return "TYPE_ARRAY_UNSIGNED_INT";
- else if (strstr(type, "const GLfloat *") ||
- strstr(type, "const GLclampf *"))
- return "TYPE_ARRAY_FLOAT";
- else if (strstr(type, "const GLdouble *"))
- return "TYPE_ARRAY_DOUBLE";
- else if (strstr(type, "GLvoid *"))
- return "TYPE_OUT_ARRAY_VOID";
- else if (strstr(type, "GLboolean *") ||
- strstr(type, "GLubyte *"))
- return "TYPE_OUT_ARRAY_UNSIGNED_CHAR";
- else if (strstr(type, "GLcharARB *") ||
- strstr(type, "GLchar *"))
- return "TYPE_OUT_ARRAY_CHAR";
- else if (strstr(type, "GLshort *"))
- return "TYPE_OUT_ARRAY_SHORT";
- else if (strstr(type, "GLushort *"))
- return "TYPE_OUT_ARRAY_UNSIGNED_SHORT";
- else if (strstr(type, "GLint *")||
- strstr(type, "GLsizei *"))
- return "TYPE_OUT_ARRAY_INT";
- else if (strstr(type, "GLuint *") ||
- strstr(type, "GLenum *") ||
- strstr(type, "GLhandleARB *"))
- return "TYPE_OUT_ARRAY_UNSIGNED_INT";
- else if (strstr(type, "GLfloat *"))
- return "TYPE_OUT_ARRAY_FLOAT";
- else if (strstr(type, "GLdouble *"))
- return "TYPE_OUT_ARRAY_DOUBLE";
- else if (strcmp(type, "void") == 0)
- return("TYPE_NONE");
- else if (strcmp(type, "GLbyte") == 0)
- return("TYPE_CHAR");
- else if (strcmp(type, "GLubyte") == 0 ||
- strcmp(type, "GLboolean") == 0)
- return("TYPE_UNSIGNED_CHAR");
- else if (strcmp(type, "GLshort") == 0)
- return("TYPE_SHORT");
- else if (strcmp(type, "GLushort") == 0 ||
- strcmp(type, "GLhalfNV") == 0)
- return("TYPE_UNSIGNED_SHORT");
- else if (strcmp(type, "GLint") == 0 ||
- strcmp(type, "GLsizei") == 0 ||
- strcmp(type, "GLintptr") == 0 ||
- strcmp(type, "GLsizeiptr") == 0 ||
- strcmp(type, "GLintptrARB") == 0 ||
- strcmp(type, "GLsizeiptrARB") == 0)
- return("TYPE_INT");
- else if (strcmp(type, "GLenum") == 0 ||
- strcmp(type, "GLuint") == 0 ||
- strcmp(type, "GLhandleARB") == 0 ||
- strcmp(type, "GLbitfield") == 0)
- return("TYPE_UNSIGNED_INT");
- else if (strcmp(type, "GLfloat") == 0 ||
- strcmp(type, "GLclampf") == 0)
- return("TYPE_FLOAT");
- else if (strcmp(type, "GLdouble") == 0 ||
- strcmp(type, "GLclampd") == 0)
- return("TYPE_DOUBLE");
- else
- {
- printf("inconnu %s\n", type);
- exit(-1);
- }
}
-typedef struct
-{
- char* letter;
- char* signature_type_name;
- char* gl_c_type_name;
- char* c_type_name;
+typedef struct {
+ char *letter;
+ char *signature_type_name;
+ char *gl_c_type_name;
+ char *c_type_name;
} ForIsKnownArgVector;
#define N_ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
#define N_FIELDS_IN_ARG_VECTOR 4
-
-typedef struct
-{
- char* func_name;
- char* signature_type_name;
+typedef struct {
+ char *func_name;
+ char *signature_type_name;
} KnownLastArgFunc;
-static KnownLastArgFunc knownLastArgFuncs[] =
-{
-{"glFogCoordfv", "TYPE_1FLOAT"},
-{"glFogCoorddv", "TYPE_1DOUBLE"},
-{"glFogCoordfvEXT", "TYPE_1FLOAT"},
-{"glFogCoorddvEXT", "TYPE_1DOUBLE"},
-{"glFogCoordhvNV", "TYPE_1USHORT"},
-
-{"glGetFenceivNV", "TYPE_OUT_1INT"},
-
-{"glGetTexLevelParameteriv", "TYPE_OUT_1INT" },
-{"glGetTexLevelParameterfv", "TYPE_OUT_1FLOAT" },
-
-{"glGetRenderbufferParameterivEXT", "TYPE_OUT_1INT"},
-{"glGetFramebufferAttachmentParameterivEXT", "TYPE_OUT_1INT"},
-{"glGetFinalCombinerInputParameterivNV", "TYPE_OUT_1INT"},
-{"glGetCombinerOutputParameterivNV", "TYPE_OUT_1INT"},
-{"glGetCombinerInputParameterivNV", "TYPE_OUT_1INT"},
-{"glGetOcclusionQueryivNV", "TYPE_OUT_1INT"},
-{"glGetOcclusionQueryuivNV", "TYPE_OUT_1UINT"},
-{"glGetObjectParameterivARB", "TYPE_OUT_1INT"},
-{"glGetQueryivARB", "TYPE_OUT_1INT"},
-{"glGetQueryiv", "TYPE_OUT_1INT"},
-{"glGetQueryObjectivARB", "TYPE_OUT_1INT"},
-{"glGetQueryObjectiv", "TYPE_OUT_1INT"},
-{"glGetQueryObjectuivARB", "TYPE_OUT_1UINT"},
-{"glGetQueryObjectuiv", "TYPE_OUT_1UINT"},
-{"glGetProgramivARB", "TYPE_OUT_1INT"},
-{"glGetProgramiv", "TYPE_OUT_1INT"},
-{"glGetProgramivNV", "TYPE_OUT_1INT"},
-{"glGetShaderiv", "TYPE_OUT_1INT"},
-
-{"glCombinerParameterfvNV", "TYPE_1FLOAT"},
-{"glCombinerParameterivNV", "TYPE_1INT"},
-
-{"glGetFinalCombinerInputParameterfvNV", "TYPE_OUT_1FLOAT"},
-{"glGetCombinerOutputParameterfvNV", "TYPE_OUT_1FLOAT"},
-{"glGetCombinerInputParameterfvNV", "TYPE_OUT_1FLOAT"},
-{"glGetObjectParameterfvARB", "TYPE_OUT_1FLOAT"},
-
-{"glCombinerStageParameterfvNV", "TYPE_4FLOAT"},
-{"glGetCombinerStageParameterfvNV", "TYPE_OUT_4FLOAT"},
-
-{"glTexBumpParameterivATI", "TYPE_1INT"},
-{"glTexBumpParameterfvATI", "TYPE_1FLOAT"},
-{"glGetTexBumpParameterivATI", "TYPE_OUT_1INT"},
-{"glGetTexBumpParameterfvATI", "TYPE_OUT_1FLOAT"},
-
-{"glGetProgramLocalParameterfvARB", "TYPE_OUT_4FLOAT"},
-{"glGetProgramLocalParameterdvARB", "TYPE_OUT_4DOUBLE"},
-{"glGetProgramEnvParameterfvARB", "TYPE_OUT_4FLOAT"},
-{"glGetProgramEnvParameterdvARB", "TYPE_OUT_4DOUBLE"},
-{"glGetProgramLocalParameterIivNV", "TYPE_OUT_1INT"},
-{"glGetProgramLocalParameterIuivNV", "TYPE_OUT_1UINT"},
-{"glGetProgramEnvParameterIivNV", "TYPE_OUT_1INT"},
-{"glGetProgramEnvParameterIuivNV", "TYPE_OUT_1UINT"},
-
-{"glGetProgramParameterfvNV", "TYPE_OUT_4FLOAT"},
-{"glGetProgramParameterdvNV", "TYPE_OUT_4DOUBLE"},
-{"glGetProgramNamedParameterfvNV", "TYPE_OUT_4FLOAT"},
-{"glGetProgramNamedParameterdvNV", "TYPE_OUT_4DOUBLE"},
-
-{"glCullParameterfvEXT", "TYPE_4FLOAT"},
-{"glCullParameterdvEXT", "TYPE_4DOUBLE"},
-
-{"glGetTrackMatrixivNV", "TYPE_OUT_1INT"},
-{"glExecuteProgramNV", "TYPE_4FLOAT"},
-
-{"glEdgeFlagv", "TYPE_1UCHAR"},
-
-{"glClipPlane", "TYPE_4DOUBLE"},
-{"glGetClipPlane", "TYPE_OUT_4DOUBLE"},
-
-{"glSetFragmentShaderConstantATI", "TYPE_4FLOAT"},
-
-{"glGetObjectBufferfvATI", "TYPE_OUT_1FLOAT"},
-{"glGetObjectBufferivATI", "TYPE_OUT_1INT"},
-{"glGetArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
-{"glGetArrayObjectivATI", "TYPE_OUT_1INT"},
-{"glGetVariantArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
-{"glGetVariantArrayObjectivATI", "TYPE_OUT_1INT"},
-{"glGetVertexAttribArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
-{"glGetVertexAttribArrayObjectivATI", "TYPE_OUT_1INT"},
-
-{"glPixelTransformParameterivEXT", "TYPE_1INT"},
-{"glPixelTransformParameterfvEXT", "TYPE_1FLOAT"},
-{"glGetPixelTransformParameterivEXT", "TYPE_OUT_1INT"},
-{"glGetPixelTransformParameterfvEXT", "TYPE_OUT_1FLOAT"},
-
-{"glColorTableParameterfv", "TYPE_4FLOAT"},
-{"glColorTableParameteriv", "TYPE_4INT"},
-{"glGetColorTableParameterfv", "TYPE_OUT_4FLOAT"},
-{"glGetColorTableParameteriv", "TYPE_OUT_4INT"},
-{"glColorTableParameterfvEXT", "TYPE_4FLOAT"},
-{"glColorTableParameterivEXT", "TYPE_4INT"},
-{"glGetColorTableParameterfvEXT", "TYPE_OUT_4FLOAT"},
-{"glGetColorTableParameterivEXT", "TYPE_OUT_4INT"},
-
-{"glGetMinmaxParameterfv", "TYPE_OUT_1FLOAT"},
-{"glGetMinmaxParameteriv", "TYPE_OUT_1INT"},
-{"glGetHistogramParameterfv", "TYPE_OUT_1FLOAT"},
-{"glGetHistogramParameteriv", "TYPE_OUT_1INT"},
-{"glGetMinmaxParameterfvEXT", "TYPE_OUT_1FLOAT"},
-{"glGetMinmaxParameterivEXT", "TYPE_OUT_1INT"},
-{"glGetHistogramParameterfvEXT", "TYPE_OUT_1FLOAT"},
-{"glGetHistogramParameterivEXT", "TYPE_OUT_1INT"},
+static KnownLastArgFunc knownLastArgFuncs[] = {
+ {"glFogCoordfv", "TYPE_1FLOAT"},
+ {"glFogCoorddv", "TYPE_1DOUBLE"},
+ {"glFogCoordfvEXT", "TYPE_1FLOAT"},
+ {"glFogCoorddvEXT", "TYPE_1DOUBLE"},
+ {"glFogCoordhvNV", "TYPE_1USHORT"},
+
+ {"glGetFenceivNV", "TYPE_OUT_1INT"},
+
+ {"glGetTexLevelParameteriv", "TYPE_OUT_1INT"},
+ {"glGetTexLevelParameterfv", "TYPE_OUT_1FLOAT"},
+
+ {"glGetRenderbufferParameterivEXT", "TYPE_OUT_1INT"},
+ {"glGetFramebufferAttachmentParameterivEXT", "TYPE_OUT_1INT"},
+ {"glGetFinalCombinerInputParameterivNV", "TYPE_OUT_1INT"},
+ {"glGetCombinerOutputParameterivNV", "TYPE_OUT_1INT"},
+ {"glGetCombinerInputParameterivNV", "TYPE_OUT_1INT"},
+ {"glGetOcclusionQueryivNV", "TYPE_OUT_1INT"},
+ {"glGetOcclusionQueryuivNV", "TYPE_OUT_1UINT"},
+ {"glGetObjectParameterivARB", "TYPE_OUT_1INT"},
+ {"glGetQueryivARB", "TYPE_OUT_1INT"},
+ {"glGetQueryiv", "TYPE_OUT_1INT"},
+ {"glGetQueryObjectivARB", "TYPE_OUT_1INT"},
+ {"glGetQueryObjectiv", "TYPE_OUT_1INT"},
+ {"glGetQueryObjectuivARB", "TYPE_OUT_1UINT"},
+ {"glGetQueryObjectuiv", "TYPE_OUT_1UINT"},
+ {"glGetProgramivARB", "TYPE_OUT_1INT"},
+ {"glGetProgramiv", "TYPE_OUT_1INT"},
+ {"glGetProgramivNV", "TYPE_OUT_1INT"},
+ {"glGetShaderiv", "TYPE_OUT_1INT"},
+
+ {"glCombinerParameterfvNV", "TYPE_1FLOAT"},
+ {"glCombinerParameterivNV", "TYPE_1INT"},
+
+ {"glGetFinalCombinerInputParameterfvNV", "TYPE_OUT_1FLOAT"},
+ {"glGetCombinerOutputParameterfvNV", "TYPE_OUT_1FLOAT"},
+ {"glGetCombinerInputParameterfvNV", "TYPE_OUT_1FLOAT"},
+ {"glGetObjectParameterfvARB", "TYPE_OUT_1FLOAT"},
+
+ {"glCombinerStageParameterfvNV", "TYPE_4FLOAT"},
+ {"glGetCombinerStageParameterfvNV", "TYPE_OUT_4FLOAT"},
+
+ {"glTexBumpParameterivATI", "TYPE_1INT"},
+ {"glTexBumpParameterfvATI", "TYPE_1FLOAT"},
+ {"glGetTexBumpParameterivATI", "TYPE_OUT_1INT"},
+ {"glGetTexBumpParameterfvATI", "TYPE_OUT_1FLOAT"},
+
+ {"glGetProgramLocalParameterfvARB", "TYPE_OUT_4FLOAT"},
+ {"glGetProgramLocalParameterdvARB", "TYPE_OUT_4DOUBLE"},
+ {"glGetProgramEnvParameterfvARB", "TYPE_OUT_4FLOAT"},
+ {"glGetProgramEnvParameterdvARB", "TYPE_OUT_4DOUBLE"},
+ {"glGetProgramLocalParameterIivNV", "TYPE_OUT_1INT"},
+ {"glGetProgramLocalParameterIuivNV", "TYPE_OUT_1UINT"},
+ {"glGetProgramEnvParameterIivNV", "TYPE_OUT_1INT"},
+ {"glGetProgramEnvParameterIuivNV", "TYPE_OUT_1UINT"},
+
+ {"glGetProgramParameterfvNV", "TYPE_OUT_4FLOAT"},
+ {"glGetProgramParameterdvNV", "TYPE_OUT_4DOUBLE"},
+ {"glGetProgramNamedParameterfvNV", "TYPE_OUT_4FLOAT"},
+ {"glGetProgramNamedParameterdvNV", "TYPE_OUT_4DOUBLE"},
+
+ {"glCullParameterfvEXT", "TYPE_4FLOAT"},
+ {"glCullParameterdvEXT", "TYPE_4DOUBLE"},
+
+ {"glGetTrackMatrixivNV", "TYPE_OUT_1INT"},
+ {"glExecuteProgramNV", "TYPE_4FLOAT"},
+
+ {"glEdgeFlagv", "TYPE_1UCHAR"},
+
+ {"glClipPlane", "TYPE_4DOUBLE"},
+ {"glGetClipPlane", "TYPE_OUT_4DOUBLE"},
+
+ {"glSetFragmentShaderConstantATI", "TYPE_4FLOAT"},
+
+ {"glGetObjectBufferfvATI", "TYPE_OUT_1FLOAT"},
+ {"glGetObjectBufferivATI", "TYPE_OUT_1INT"},
+ {"glGetArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
+ {"glGetArrayObjectivATI", "TYPE_OUT_1INT"},
+ {"glGetVariantArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
+ {"glGetVariantArrayObjectivATI", "TYPE_OUT_1INT"},
+ {"glGetVertexAttribArrayObjectfvATI", "TYPE_OUT_1FLOAT"},
+ {"glGetVertexAttribArrayObjectivATI", "TYPE_OUT_1INT"},
+
+ {"glPixelTransformParameterivEXT", "TYPE_1INT"},
+ {"glPixelTransformParameterfvEXT", "TYPE_1FLOAT"},
+ {"glGetPixelTransformParameterivEXT", "TYPE_OUT_1INT"},
+ {"glGetPixelTransformParameterfvEXT", "TYPE_OUT_1FLOAT"},
+
+ {"glColorTableParameterfv", "TYPE_4FLOAT"},
+ {"glColorTableParameteriv", "TYPE_4INT"},
+ {"glGetColorTableParameterfv", "TYPE_OUT_4FLOAT"},
+ {"glGetColorTableParameteriv", "TYPE_OUT_4INT"},
+ {"glColorTableParameterfvEXT", "TYPE_4FLOAT"},
+ {"glColorTableParameterivEXT", "TYPE_4INT"},
+ {"glGetColorTableParameterfvEXT", "TYPE_OUT_4FLOAT"},
+ {"glGetColorTableParameterivEXT", "TYPE_OUT_4INT"},
+
+ {"glGetMinmaxParameterfv", "TYPE_OUT_1FLOAT"},
+ {"glGetMinmaxParameteriv", "TYPE_OUT_1INT"},
+ {"glGetHistogramParameterfv", "TYPE_OUT_1FLOAT"},
+ {"glGetHistogramParameteriv", "TYPE_OUT_1INT"},
+ {"glGetMinmaxParameterfvEXT", "TYPE_OUT_1FLOAT"},
+ {"glGetMinmaxParameterivEXT", "TYPE_OUT_1INT"},
+ {"glGetHistogramParameterfvEXT", "TYPE_OUT_1FLOAT"},
+ {"glGetHistogramParameterivEXT", "TYPE_OUT_1INT"},
/* Not sure at all for the 2 followingo ones ! */
-{"glGetBooleanIndexedvEXT", "TYPE_OUT_4UCHAR"},
-{"glGetIntegerIndexedvEXT", "TYPE_OUT_4INT"},
+ {"glGetBooleanIndexedvEXT", "TYPE_OUT_4UCHAR"},
+ {"glGetIntegerIndexedvEXT", "TYPE_OUT_4INT"},
-{"glReferencePlaneSGIX", "TYPE_4DOUBLE"},
+ {"glReferencePlaneSGIX", "TYPE_4DOUBLE"},
-{"glGetTransformFeedbackVaryingNV", "TYPE_OUT_1INT"},
+ {"glGetTransformFeedbackVaryingNV", "TYPE_OUT_1INT"},
};
-int is_known_arg_vector(FuncDesc* desc, char** p_signature_type_name, char** p_c_type_name)
+int is_known_arg_vector(FuncDesc * desc, char **p_signature_type_name,
+ char **p_c_type_name)
{
- static ForIsKnownArgVector my_tab[] =
- {
- { "b", "CHAR", "GLbyte", "signed char" },
- { "Boolean", "CHAR", "GLboolean", "unsigned char" },
- { "s", "SHORT", "GLshort", "short" },
- { "i", "INT", "GLint", "int" },
- { "Integer", "INT", "GLint", "int" },
- { "ub", "CHAR", "GLubyte", "unsigned char" },
- { "h", "SHORT", "GLhalf", "unsigned short" },
- { "us", "SHORT", "GLushort", "unsigned short" },
- { "ui", "INT", "GLuint", "unsigned int" },
- { "Nb", "CHAR", "GLbyte", "signed char" },
- { "Ns", "SHORT", "GLshort", "short" },
- { "Ni", "INT", "GLint", "int" },
- { "Nub", "CHAR", "GLubyte", "unsigned char" },
- { "Nus", "SHORT", "GLushort", "unsigned short" },
- { "Nui", "INT", "GLuint", "unsigned int" },
-
- { "f", "FLOAT", "GLfloat", "float" },
- { "Float", "FLOAT", "GLfloat", "float" },
- { "d", "DOUBLE", "GLdouble", "double" },
- };
-
- if (desc->nargs == 0)
- return 0;
-
- int i , j;
-
- if (strstr(desc->name, "glVertexAttribs") ||
- strstr(desc->name, "glProgramParameters") ||
- strstr(desc->name, "glProgramEnvParameters") ||
- strstr(desc->name, "glProgramLocalParameters") ||
- (strstr(desc->name, "glUniform") && (strstr(desc->name, "iv") || strstr(desc->name, "fv"))))
- return 0;
-
- static char signatures[N_ELEMENTS(my_tab)][N_FIELDS_IN_ARG_VECTOR][20] = {0};
- char signature[10];
-
- for(i=0;i<N_ELEMENTS(knownLastArgFuncs);i++)
- {
- if (strcmp(desc->name, knownLastArgFuncs[i].func_name) == 0)
- {
- if (p_signature_type_name)
- {
- *p_signature_type_name = knownLastArgFuncs[i].signature_type_name;
- }
- if (p_c_type_name)
- {
- if (strstr(knownLastArgFuncs[i].signature_type_name, "FLOAT"))
- *p_c_type_name = "float";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "DOUBLE"))
- *p_c_type_name = "double";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "UINT"))
- *p_c_type_name = "unsigned int";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "INT"))
- *p_c_type_name = "int";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "USHORT"))
- *p_c_type_name = "unsigned short";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "SHORT"))
- *p_c_type_name = "short";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "UCHAR"))
- *p_c_type_name = "unsigned char";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "CHAR"))
- *p_c_type_name = "char";
- else
- assert(0);
- }
- return 1;
+ static ForIsKnownArgVector my_tab[] = {
+ {"b", "CHAR", "GLbyte", "signed char"},
+ {"Boolean", "CHAR", "GLboolean", "unsigned char"},
+ {"s", "SHORT", "GLshort", "short"},
+ {"i", "INT", "GLint", "int"},
+ {"Integer", "INT", "GLint", "int"},
+ {"ub", "CHAR", "GLubyte", "unsigned char"},
+ {"h", "SHORT", "GLhalf", "unsigned short"},
+ {"us", "SHORT", "GLushort", "unsigned short"},
+ {"ui", "INT", "GLuint", "unsigned int"},
+ {"Nb", "CHAR", "GLbyte", "signed char"},
+ {"Ns", "SHORT", "GLshort", "short"},
+ {"Ni", "INT", "GLint", "int"},
+ {"Nub", "CHAR", "GLubyte", "unsigned char"},
+ {"Nus", "SHORT", "GLushort", "unsigned short"},
+ {"Nui", "INT", "GLuint", "unsigned int"},
+
+ {"f", "FLOAT", "GLfloat", "float"},
+ {"Float", "FLOAT", "GLfloat", "float"},
+ {"d", "DOUBLE", "GLdouble", "double"},
+ };
+
+ if (desc->nargs == 0)
+ return 0;
+
+ int i, j;
+
+ if (strstr(desc->name, "glVertexAttribs") ||
+ strstr(desc->name, "glProgramParameters") ||
+ strstr(desc->name, "glProgramEnvParameters") ||
+ strstr(desc->name, "glProgramLocalParameters") ||
+ (strstr(desc->name, "glUniform")
+ && (strstr(desc->name, "iv") || strstr(desc->name, "fv"))))
+ return 0;
+
+ static char signatures[N_ELEMENTS(my_tab)][N_FIELDS_IN_ARG_VECTOR][20] =
+ { 0 };
+ char signature[10];
+
+ for (i = 0; i < N_ELEMENTS(knownLastArgFuncs); i++) {
+ if (strcmp(desc->name, knownLastArgFuncs[i].func_name) == 0) {
+ if (p_signature_type_name) {
+ *p_signature_type_name =
+ knownLastArgFuncs[i].signature_type_name;
+ }
+ if (p_c_type_name) {
+ if (strstr(knownLastArgFuncs[i].signature_type_name, "FLOAT"))
+ *p_c_type_name = "float";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "DOUBLE"))
+ *p_c_type_name = "double";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "UINT"))
+ *p_c_type_name = "unsigned int";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "INT"))
+ *p_c_type_name = "int";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "USHORT"))
+ *p_c_type_name = "unsigned short";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "SHORT"))
+ *p_c_type_name = "short";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "UCHAR"))
+ *p_c_type_name = "unsigned char";
+ else if (strstr
+ (knownLastArgFuncs[i].signature_type_name, "CHAR"))
+ *p_c_type_name = "char";
+ else
+ assert(0);
+ }
+ return 1;
+ }
}
- }
-
- for(i=0;i<N_ELEMENTS(my_tab);i++)
- {
- for(j=1;j<=N_FIELDS_IN_ARG_VECTOR;j++)
- {
- if (strstr(desc->name, "glIndex") && strstr(desc->name, "v"))
- sprintf(signature, "%sv", my_tab[i].letter);
- else
- sprintf(signature, "%d%sv", j, my_tab[i].letter);
- if (strstr(desc->name, signature) &&
- strstr(desc->args[desc->nargs - 1], my_tab[i].gl_c_type_name) &&
- strstr(desc->args[desc->nargs - 1], "*"))
- {
- if (p_signature_type_name)
- {
- if (signatures[i][j-1][0] == 0)
- sprintf(signatures[i][j-1], "TYPE_%d%s", j, my_tab[i].signature_type_name);
- *p_signature_type_name = signatures[i][j-1];
+
+ for (i = 0; i < N_ELEMENTS(my_tab); i++) {
+ for (j = 1; j <= N_FIELDS_IN_ARG_VECTOR; j++) {
+ if (strstr(desc->name, "glIndex") && strstr(desc->name, "v"))
+ sprintf(signature, "%sv", my_tab[i].letter);
+ else
+ sprintf(signature, "%d%sv", j, my_tab[i].letter);
+ if (strstr(desc->name, signature) &&
+ strstr(desc->args[desc->nargs - 1], my_tab[i].gl_c_type_name) &&
+ strstr(desc->args[desc->nargs - 1], "*")) {
+ if (p_signature_type_name) {
+ if (signatures[i][j - 1][0] == 0)
+ sprintf(signatures[i][j - 1], "TYPE_%d%s", j,
+ my_tab[i].signature_type_name);
+ *p_signature_type_name = signatures[i][j - 1];
+ }
+ if (p_c_type_name)
+ *p_c_type_name = my_tab[i].c_type_name;
+ return 1;
+ }
}
- if (p_c_type_name) *p_c_type_name = my_tab[i].c_type_name;
- return 1;
- }
}
- }
- return 0;
+ return 0;
}
-static void print_server_side_argument(FILE* server_stub, int j, char* glType)
+static void print_server_side_argument(FILE * server_stub, int j, char *glType)
{
- const char* symbolic_type = get_type_string(glType);
- if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
- fprintf(server_stub, "ARG_TO_CHAR(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0)
- fprintf(server_stub, "ARG_TO_UNSIGNED_CHAR(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
- fprintf(server_stub, "ARG_TO_SHORT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0)
- fprintf(server_stub, "ARG_TO_UNSIGNED_SHORT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_INT") == 0)
- fprintf(server_stub, "ARG_TO_INT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0)
- fprintf(server_stub, "ARG_TO_UNSIGNED_INT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
- fprintf(server_stub, "ARG_TO_FLOAT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
- fprintf(server_stub, "(const float*)(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
- fprintf(server_stub, "ARG_TO_DOUBLE(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_16DOUBLE") == 0)
- fprintf(server_stub, "(const double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0)
- fprintf(server_stub, "(unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_128UCHAR") == 0)
- fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_NULL_TERMINATED_STRING") == 0)
- fprintf(server_stub, "(const char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_SHORT") == 0)
- fprintf(server_stub, "(const short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_SHORT") == 0)
- fprintf(server_stub, "(const unsigned short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_INT") == 0)
- fprintf(server_stub, "(const int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_INT") == 0)
- fprintf(server_stub, "(const unsigned int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_FLOAT") == 0)
- fprintf(server_stub, "(const float*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_DOUBLE") == 0)
- fprintf(server_stub, "(const double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_CHAR") == 0)
- fprintf(server_stub, "(const char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_SIGNED_CHAR") == 0)
- fprintf(server_stub, "(const signed char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_VOID") == 0)
- fprintf(server_stub, "(const void*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_CHAR") == 0)
- fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_SHORT") == 0)
- fprintf(server_stub, "(short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_SHORT") == 0)
- fprintf(server_stub, "(unsigned short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_INT") == 0)
- fprintf(server_stub, "(int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_INT") == 0)
- fprintf(server_stub, "(unsigned int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_FLOAT") == 0)
- fprintf(server_stub, "(float*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_DOUBLE") == 0)
- fprintf(server_stub, "(double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_VOID") == 0)
- fprintf(server_stub, "(void*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_CHAR") == 0)
- fprintf(server_stub, "(char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_CHAR") == 0)
- fprintf(server_stub, "(unsigned char*)(args[%d])", j);
-
- else
- {
- fprintf(stderr, "Unknown : %s\n", symbolic_type);
- assert(0);
- }
+ const char *symbolic_type = get_type_string(glType);
+ if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
+ fprintf(server_stub, "ARG_TO_CHAR(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0)
+ fprintf(server_stub, "ARG_TO_UNSIGNED_CHAR(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
+ fprintf(server_stub, "ARG_TO_SHORT(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0)
+ fprintf(server_stub, "ARG_TO_UNSIGNED_SHORT(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_INT") == 0)
+ fprintf(server_stub, "ARG_TO_INT(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0)
+ fprintf(server_stub, "ARG_TO_UNSIGNED_INT(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
+ fprintf(server_stub, "ARG_TO_FLOAT(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
+ fprintf(server_stub, "(const float*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
+ fprintf(server_stub, "ARG_TO_DOUBLE(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_16DOUBLE") == 0)
+ fprintf(server_stub, "(const double*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0)
+ fprintf(server_stub, "(unsigned char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_128UCHAR") == 0)
+ fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_NULL_TERMINATED_STRING") == 0)
+ fprintf(server_stub, "(const char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_SHORT") == 0)
+ fprintf(server_stub, "(const short*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_SHORT") == 0)
+ fprintf(server_stub, "(const unsigned short*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_INT") == 0)
+ fprintf(server_stub, "(const int*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_INT") == 0)
+ fprintf(server_stub, "(const unsigned int*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_FLOAT") == 0)
+ fprintf(server_stub, "(const float*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_DOUBLE") == 0)
+ fprintf(server_stub, "(const double*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_CHAR") == 0)
+ fprintf(server_stub, "(const char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_SIGNED_CHAR") == 0)
+ fprintf(server_stub, "(const signed char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_VOID") == 0)
+ fprintf(server_stub, "(const void*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_CHAR") == 0)
+ fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_SHORT") == 0)
+ fprintf(server_stub, "(short*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_SHORT") == 0)
+ fprintf(server_stub, "(unsigned short*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_INT") == 0)
+ fprintf(server_stub, "(int*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_INT") == 0)
+ fprintf(server_stub, "(unsigned int*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_FLOAT") == 0)
+ fprintf(server_stub, "(float*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_DOUBLE") == 0)
+ fprintf(server_stub, "(double*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_VOID") == 0)
+ fprintf(server_stub, "(void*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_CHAR") == 0)
+ fprintf(server_stub, "(char*)(args[%d])", j);
+ else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_CHAR") == 0)
+ fprintf(server_stub, "(unsigned char*)(args[%d])", j);
+
+ else {
+ fprintf(stderr, "Unknown : %s\n", symbolic_type);
+ assert(0);
+ }
}
-static const char* func_dealt_by_hand[500] = { NULL };
-
-
-static const char* ignore_func[] =
-{
- "glGetPointerv",
- "glRectdv",
- "glRectfv",
- "glRectiv",
- "glRectsv",
- "glMultiDrawArrays",
- "glMultiDrawArraysEXT",
- "glMultiDrawElements",
- "glMultiDrawElementsEXT",
- "glUnmapBuffer",
- "glUnmapBufferARB",
- "glLoadTransposeMatrixf",
- "glLoadTransposeMatrixd",
- "glMultTransposeMatrixf",
- "glMultTransposeMatrixd",
- "glLoadTransposeMatrixfARB",
- "glLoadTransposeMatrixdARB",
- "glMultTransposeMatrixfARB",
- "glMultTransposeMatrixdARB",
-
- "glPixelDataRangeNV",
- "glFlushPixelDataRangeNV",
- "glVertexArrayRangeNV",
- "glFlushVertexArrayRangeNV",
- "glVertexWeightfEXT",
-
- "glGetBufferPointerv",
- "glGetBufferPointervARB",
- "glGetVertexAttribPointerv",
- "glGetVertexAttribPointervARB",
- "glVertexAttribPointer",
- "glVertexAttribPointerARB",
- "glGetVariantPointervEXT",
- NULL,
+static const char *func_dealt_by_hand[500] = { NULL };
+
+static const char *ignore_func[] = {
+ "glGetPointerv",
+ "glRectdv",
+ "glRectfv",
+ "glRectiv",
+ "glRectsv",
+ "glMultiDrawArrays",
+ "glMultiDrawArraysEXT",
+ "glMultiDrawElements",
+ "glMultiDrawElementsEXT",
+ "glUnmapBuffer",
+ "glUnmapBufferARB",
+ "glLoadTransposeMatrixf",
+ "glLoadTransposeMatrixd",
+ "glMultTransposeMatrixf",
+ "glMultTransposeMatrixd",
+ "glLoadTransposeMatrixfARB",
+ "glLoadTransposeMatrixdARB",
+ "glMultTransposeMatrixfARB",
+ "glMultTransposeMatrixdARB",
+
+ "glPixelDataRangeNV",
+ "glFlushPixelDataRangeNV",
+ "glVertexArrayRangeNV",
+ "glFlushVertexArrayRangeNV",
+ "glVertexWeightfEXT",
+
+ "glGetBufferPointerv",
+ "glGetBufferPointervARB",
+ "glGetVertexAttribPointerv",
+ "glGetVertexAttribPointervARB",
+ "glVertexAttribPointer",
+ "glVertexAttribPointerARB",
+ "glGetVariantPointervEXT",
+ NULL,
};
void get_func_dealt_by_hand()
{
- FILE* f = fopen(GL_INCLUDE_PATH"gl_func_perso.h", "r");
- char buffer[256];
- int i = 0;
- char* c;
- while(fgets(buffer, 256, f))
- {
- if (strstr(buffer, "MAGIC_MACRO("))
- {
- func_dealt_by_hand[i] = strdup(strstr(buffer, "MAGIC_MACRO(") + strlen("MAGIC_MACRO("));
- * strstr(func_dealt_by_hand[i], ")") = 0;
- c = strstr(func_dealt_by_hand[i], "_");
- if (c && c != func_dealt_by_hand[i]) *c = 0;
- i ++;
+ FILE *f = fopen(GL_INCLUDE_PATH "gl_func_perso.h", "r");
+ char buffer[256];
+ int i = 0;
+ char *c;
+ while (fgets(buffer, 256, f)) {
+ if (strstr(buffer, "MAGIC_MACRO(")) {
+ func_dealt_by_hand[i] =
+ strdup(strstr(buffer, "MAGIC_MACRO(") + strlen("MAGIC_MACRO("));
+ *strstr(func_dealt_by_hand[i], ")") = 0;
+ c = strstr(func_dealt_by_hand[i], "_");
+ if (c && c != func_dealt_by_hand[i])
+ *c = 0;
+ i++;
+ }
+ }
+ fclose(f);
+
+ int j = 0;
+ while (ignore_func[j]) {
+ func_dealt_by_hand[i] = ignore_func[j];
+ i++;
+ j++;
}
- }
- fclose(f);
-
- int j = 0;
- while(ignore_func[j])
- {
- func_dealt_by_hand[i] = ignore_func[j];
- i++;
- j++;
- }
}
-static const char* just_for_server_side_list[] =
-{
- "glEnableClientState",
- "glDisableClientState",
- "glPushClientAttrib",
- "glPopClientAttrib",
- "glPixelStorei",
- "glPixelStoref",
- "glClientActiveTexture",
- "glClientActiveTextureARB",
- "glEnableVertexAttribArray",
- "glEnableVertexAttribArrayARB",
- "glDisableVertexAttribArray",
- "glDisableVertexAttribArrayARB",
- "glDrawElementArrayATI",
- "glDrawRangeElementArrayATI",
- "glGenSymbolsEXT",
- "glFreeObjectBufferATI",
- "glUnmapObjectBufferATI",
- "glLockArraysEXT",
- "glUnlockArraysEXT",
- "glDepthFunc",
- "glFogf",
- "glFogi",
- "glClipPlane",
- "glGetClipPlane",
-
+static const char *just_for_server_side_list[] = {
+ "glEnableClientState",
+ "glDisableClientState",
+ "glPushClientAttrib",
+ "glPopClientAttrib",
+ "glPixelStorei",
+ "glPixelStoref",
+ "glClientActiveTexture",
+ "glClientActiveTextureARB",
+ "glEnableVertexAttribArray",
+ "glEnableVertexAttribArrayARB",
+ "glDisableVertexAttribArray",
+ "glDisableVertexAttribArrayARB",
+ "glDrawElementArrayATI",
+ "glDrawRangeElementArrayATI",
+ "glGenSymbolsEXT",
+ "glFreeObjectBufferATI",
+ "glUnmapObjectBufferATI",
+ "glLockArraysEXT",
+ "glUnlockArraysEXT",
+ "glDepthFunc",
+ "glFogf",
+ "glFogi",
+ "glClipPlane",
+ "glGetClipPlane",
+
/* begin of openquartz optimization */
#if 1
- "glMatrixMode",
- "glOrtho",
- "glFrustum",
- "glPushMatrix",
- "glPopMatrix",
- "glLoadIdentity",
- "glLoadMatrixd",
- "glLoadMatrixf",
- "glMultMatrixd",
- "glMultMatrixf",
- "glRotated",
- "glRotatef",
- "glScaled",
- "glScalef",
- "glTranslated",
- "glTranslatef",
+ "glMatrixMode",
+ "glOrtho",
+ "glFrustum",
+ "glPushMatrix",
+ "glPopMatrix",
+ "glLoadIdentity",
+ "glLoadMatrixd",
+ "glLoadMatrixf",
+ "glMultMatrixd",
+ "glMultMatrixf",
+ "glRotated",
+ "glRotatef",
+ "glScaled",
+ "glScalef",
+ "glTranslated",
+ "glTranslatef",
#endif
/* end of openquartz optimization */
-
- "glGetError",
- "glActiveTextureARB",
-
- "glViewport",
- "glScissor",
-
- "glBindBufferARB",
- "glDeleteBuffersARB",
- "glGenBuffersARB",
- "glBufferDataARB",
- "glBufferSubDataARB",
- "glGetBufferSubDataARB",
- "glGetBufferParameterivARB",
- "glBindBuffer",
- "glDeleteBuffers",
- "glGenBuffers",
- "glBufferData",
- "glBufferSubData",
- "glGetBufferSubData",
- "glGetBufferParameteriv",
-
- "glPushAttrib",
- "glPopAttrib",
- "glEnable",
- "glDisable",
- "glIsEnabled",
- "glBindTexture",
- "glBindTextureEXT",
- "glFogfv",
- "glFogiv",
- "glBitmap",
- "glGetTexImage",
- "glReadPixels",
- "glDrawPixels",
- "glSelectBuffer",
- "glFeedbackBuffer",
-
- "glTexImage1D",
- "glTexImage2D",
- "glTexImage3D",
- "glTexSubImage1D",
- "glTexSubImage2D",
- "glTexSubImage3D",
-
- "glTexImage3DEXT",
- "glTexSubImage1DEXT",
- "glTexSubImage2DEXT",
- "glTexSubImage3DEXT",
-
- "glGetCompressedTexImage",
- "glCompressedTexImage1D",
- "glCompressedTexImage2D",
- "glCompressedTexImage3D",
- "glCompressedTexSubImage1D",
- "glCompressedTexSubImage2D",
- "glCompressedTexSubImage3D",
-
- "glGetCompressedTexImageARB",
- "glCompressedTexImage1DARB",
- "glCompressedTexImage2DARB",
- "glCompressedTexImage3DARB",
- "glCompressedTexSubImage1DARB",
- "glCompressedTexSubImage2DARB",
- "glCompressedTexSubImage3DARB",
-
- "glCallLists",
- "glNewList",
- "glDeleteLists",
- "glGenLists",
-
- "glGenTextures",
- "glDeleteTextures",
- "glDeleteTexturesEXT",
- "glMap1f",
- "glMap1d",
- "glMap2f",
- "glMap2d",
- "glGetMapdv",
- "glGetMapfv",
- "glGetMapiv",
- "glGetBooleanv",
- "glGetIntegerv",
- "glGetFloatv",
- "glGetDoublev",
-
- "glGetPixelMapfv",
- "glGetPixelMapuiv",
- "glGetPixelMapusv",
- "glGetProgramStringARB",
- "glGetProgramStringNV",
- "glArrayElement",
- "glDrawArrays",
- "glDrawElements",
- "glDrawRangeElements",
- "glDrawRangeElementsEXT",
- "glGetProgramInfoLog",
- "glGetTexLevelParameteriv",
- "glGetInfoLogARB",
- "glGetShaderInfoLog",
- "glGetAttachedObjectsARB",
- "glGetAttachedShaders",
- "glGetActiveUniformARB",
- "glGetActiveUniform",
- "glGetUniformLocationARB",
- "glGetUniformLocation",
- "glGetUniformfvARB",
- "glGetUniformfv",
- "glGetUniformivARB",
- "glGetUniformiv",
- "glGetUniformuivEXT",
- "glGetShaderSourceARB",
- "glGetShaderSource",
- "glGetActiveAttribARB",
- "glGetActiveAttrib",
- "glGetAttribLocationARB",
- "glGetAttribLocation",
-
- "glNewObjectBufferATI",
- "glUpdateObjectBufferATI",
-
- "glSetLocalConstantEXT",
- "glSetInvariantEXT",
- "glVariantbvEXT",
- "glVariantsvEXT",
- "glVariantivEXT",
- "glVariantfvEXT",
- "glVariantdvEXT",
- "glVariantubvEXT",
- "glVariantusvEXT",
- "glVariantuivEXT",
- "glGetVariantBooleanvEXT",
- "glGetVariantIntegervEXT",
- "glGetVariantFloatvEXT",
- "glGetInvariantBooleanvEXT",
- "glGetInvariantIntegervEXT",
- "glGetInvariantFloatvEXT",
- "glGetLocalConstantBooleanvEXT",
- "glGetLocalConstantIntegervEXT",
- "glGetLocalConstantFloatvEXT",
-
- "glMatrixIndexubvARB",
- "glMatrixIndexusvARB",
- "glMatrixIndexuivARB",
-
- "glColorTable",
- "glColorSubTable",
- "glGetColorTable",
- "glConvolutionFilter1D",
- "glConvolutionFilter2D",
- "glGetConvolutionFilter",
- "glSeparableFilter2D",
- "glGetSeparableFilter",
- "glGetHistogram",
- "glGetMinmax",
- "glColorTableEXT",
- "glColorSubTableEXT",
- "glGetColorTableEXT",
- "glConvolutionFilter1DEXT",
- "glConvolutionFilter2DEXT",
- "glGetConvolutionFilterEXT",
- "glSeparableFilter2DEXT",
- "glGetSeparableFilterEXT",
- "glGetHistogramEXT",
- "glGetMinmaxEXT",
-
- "glGetTexParameterfv",
-
- "glGetVertexAttribivARB",
- "glGetVertexAttribfvARB",
- "glGetVertexAttribdvARB",
- "glGetVertexAttribiv",
- "glGetVertexAttribfv",
- "glGetVertexAttribdv",
-
- "glGetDetailTexFuncSGIS",
- "glGetSharpenTexFuncSGIS",
-
- "fake_gluBuild2DMipmaps",
-
- "glRenderMode",
-
- "glEnableVariantClientStateEXT",
- "glDisableVariantClientStateEXT",
-
- "glGetActiveVaryingNV",
-
- NULL,
+
+ "glGetError",
+ "glActiveTextureARB",
+
+ "glViewport",
+ "glScissor",
+
+ "glBindBufferARB",
+ "glDeleteBuffersARB",
+ "glGenBuffersARB",
+ "glBufferDataARB",
+ "glBufferSubDataARB",
+ "glGetBufferSubDataARB",
+ "glGetBufferParameterivARB",
+ "glBindBuffer",
+ "glDeleteBuffers",
+ "glGenBuffers",
+ "glBufferData",
+ "glBufferSubData",
+ "glGetBufferSubData",
+ "glGetBufferParameteriv",
+
+ "glPushAttrib",
+ "glPopAttrib",
+ "glEnable",
+ "glDisable",
+ "glIsEnabled",
+ "glBindTexture",
+ "glBindTextureEXT",
+ "glFogfv",
+ "glFogiv",
+ "glBitmap",
+ "glGetTexImage",
+ "glReadPixels",
+ "glDrawPixels",
+ "glSelectBuffer",
+ "glFeedbackBuffer",
+
+ "glTexImage1D",
+ "glTexImage2D",
+ "glTexImage3D",
+ "glTexSubImage1D",
+ "glTexSubImage2D",
+ "glTexSubImage3D",
+
+ "glTexImage3DEXT",
+ "glTexSubImage1DEXT",
+ "glTexSubImage2DEXT",
+ "glTexSubImage3DEXT",
+
+ "glGetCompressedTexImage",
+ "glCompressedTexImage1D",
+ "glCompressedTexImage2D",
+ "glCompressedTexImage3D",
+ "glCompressedTexSubImage1D",
+ "glCompressedTexSubImage2D",
+ "glCompressedTexSubImage3D",
+
+ "glGetCompressedTexImageARB",
+ "glCompressedTexImage1DARB",
+ "glCompressedTexImage2DARB",
+ "glCompressedTexImage3DARB",
+ "glCompressedTexSubImage1DARB",
+ "glCompressedTexSubImage2DARB",
+ "glCompressedTexSubImage3DARB",
+
+ "glCallLists",
+ "glNewList",
+ "glDeleteLists",
+ "glGenLists",
+
+ "glGenTextures",
+ "glDeleteTextures",
+ "glDeleteTexturesEXT",
+ "glMap1f",
+ "glMap1d",
+ "glMap2f",
+ "glMap2d",
+ "glGetMapdv",
+ "glGetMapfv",
+ "glGetMapiv",
+ "glGetBooleanv",
+ "glGetIntegerv",
+ "glGetFloatv",
+ "glGetDoublev",
+
+ "glGetPixelMapfv",
+ "glGetPixelMapuiv",
+ "glGetPixelMapusv",
+ "glGetProgramStringARB",
+ "glGetProgramStringNV",
+ "glArrayElement",
+ "glDrawArrays",
+ "glDrawElements",
+ "glDrawRangeElements",
+ "glDrawRangeElementsEXT",
+ "glGetProgramInfoLog",
+ "glGetTexLevelParameteriv",
+ "glGetInfoLogARB",
+ "glGetShaderInfoLog",
+ "glGetAttachedObjectsARB",
+ "glGetAttachedShaders",
+ "glGetActiveUniformARB",
+ "glGetActiveUniform",
+ "glGetUniformLocationARB",
+ "glGetUniformLocation",
+ "glGetUniformfvARB",
+ "glGetUniformfv",
+ "glGetUniformivARB",
+ "glGetUniformiv",
+ "glGetUniformuivEXT",
+ "glGetShaderSourceARB",
+ "glGetShaderSource",
+ "glGetActiveAttribARB",
+ "glGetActiveAttrib",
+ "glGetAttribLocationARB",
+ "glGetAttribLocation",
+
+ "glNewObjectBufferATI",
+ "glUpdateObjectBufferATI",
+
+ "glSetLocalConstantEXT",
+ "glSetInvariantEXT",
+ "glVariantbvEXT",
+ "glVariantsvEXT",
+ "glVariantivEXT",
+ "glVariantfvEXT",
+ "glVariantdvEXT",
+ "glVariantubvEXT",
+ "glVariantusvEXT",
+ "glVariantuivEXT",
+ "glGetVariantBooleanvEXT",
+ "glGetVariantIntegervEXT",
+ "glGetVariantFloatvEXT",
+ "glGetInvariantBooleanvEXT",
+ "glGetInvariantIntegervEXT",
+ "glGetInvariantFloatvEXT",
+ "glGetLocalConstantBooleanvEXT",
+ "glGetLocalConstantIntegervEXT",
+ "glGetLocalConstantFloatvEXT",
+
+ "glMatrixIndexubvARB",
+ "glMatrixIndexusvARB",
+ "glMatrixIndexuivARB",
+
+ "glColorTable",
+ "glColorSubTable",
+ "glGetColorTable",
+ "glConvolutionFilter1D",
+ "glConvolutionFilter2D",
+ "glGetConvolutionFilter",
+ "glSeparableFilter2D",
+ "glGetSeparableFilter",
+ "glGetHistogram",
+ "glGetMinmax",
+ "glColorTableEXT",
+ "glColorSubTableEXT",
+ "glGetColorTableEXT",
+ "glConvolutionFilter1DEXT",
+ "glConvolutionFilter2DEXT",
+ "glGetConvolutionFilterEXT",
+ "glSeparableFilter2DEXT",
+ "glGetSeparableFilterEXT",
+ "glGetHistogramEXT",
+ "glGetMinmaxEXT",
+
+ "glGetTexParameterfv",
+
+ "glGetVertexAttribivARB",
+ "glGetVertexAttribfvARB",
+ "glGetVertexAttribdvARB",
+ "glGetVertexAttribiv",
+ "glGetVertexAttribfv",
+ "glGetVertexAttribdv",
+
+ "glGetDetailTexFuncSGIS",
+ "glGetSharpenTexFuncSGIS",
+
+ "fake_gluBuild2DMipmaps",
+
+ "glRenderMode",
+
+ "glEnableVariantClientStateEXT",
+ "glDisableVariantClientStateEXT",
+
+ "glGetActiveVaryingNV",
+
+ NULL,
};
-static int just_for_server_side_func(char* funcname)
+static int just_for_server_side_func(char *funcname)
{
- int i;
- for(i=0;just_for_server_side_list[i];i++)
- {
- if (strcmp(just_for_server_side_list[i], funcname) == 0)
- return 1;
- }
- return 0;
+ int i;
+ for (i = 0; just_for_server_side_list[i]; i++) {
+ if (strcmp(just_for_server_side_list[i], funcname) == 0)
+ return 1;
+ }
+ return 0;
}
-int parse(FILE* f, FuncDesc* funcDesc, int funcDescCount, int ignoreEXT)
+int parse(FILE * f, FuncDesc * funcDesc, int funcDescCount, int ignoreEXT)
{
- char buffer[256];
- while(fgets(buffer, 256, f))
- {
-
- if (strncmp(buffer, "GLAPI", 5) == 0 && strstr(buffer, "APIENTRY") && strstr(buffer, "("))
- {
- int i = 0;
- int skip = 0;
- if (func_dealt_by_hand[0] == 0)
- {
- get_func_dealt_by_hand();
- }
- while (func_dealt_by_hand[i])
- {
- if (strstr(buffer, func_dealt_by_hand[i]))
- {
- skip = 1;
- break;
- }
- i++;
- }
- if (skip)
- continue;
-
- char** args = malloc(15 * sizeof(char*));
- int narg = 0;
- char* type = buffer + 6;
- char* n = strstr(type, "GLAPIENTRY") ? strstr(type, "GLAPIENTRY") : strstr(type, "APIENTRY");
- int skip_length = strstr(type, "GLAPIENTRY") ? 11 : 9;
- n[-1] = 0;
- type = strdup(type);
- n += skip_length;
- char* fonc = n;
- n = strstr(n, "(");
- if (n[-1] == ' ') n[-1] = 0;
- n[0] = 0;
- fonc = strdup(fonc);
- /*if (strstr(fonc, "glLockArraysEXT") || strstr(fonc, "glUnlockArraysEXT"))
- {
- }
- else*/
-
-
- if (ignoreEXT == 1 && isExtByName(fonc))
- {
- free(type);
- free(fonc);
- continue;
- }
- n++;
- while(1)
- {
- char* virg = strstr(n, ",");
- if (virg)
- {
- args[narg] = n;
- virg[0] = 0;
- args[narg] = get_arg_type(args[narg]);
- narg++;
- n = virg+1;
- }
- else
- break;
- }
- while (strstr(n, ")") == 0)
- {
- fgets(buffer, 256, f);
- n = buffer;
- while(1)
- {
- char* virg = strstr(n, ",");
- if (virg)
- {
+ char buffer[256];
+ while (fgets(buffer, 256, f)) {
+
+ if (strncmp(buffer, "GLAPI", 5) == 0 && strstr(buffer, "APIENTRY")
+ && strstr(buffer, "(")) {
+ int i = 0;
+ int skip = 0;
+ if (func_dealt_by_hand[0] == 0) {
+ get_func_dealt_by_hand();
+ }
+ while (func_dealt_by_hand[i]) {
+ if (strstr(buffer, func_dealt_by_hand[i])) {
+ skip = 1;
+ break;
+ }
+ i++;
+ }
+ if (skip)
+ continue;
+
+ char **args = malloc(15 * sizeof(char *));
+ int narg = 0;
+ char *type = buffer + 6;
+ char *n =
+ strstr(type, "GLAPIENTRY") ? strstr(type,
+ "GLAPIENTRY") : strstr(type,
+ "APIENTRY");
+ int skip_length = strstr(type, "GLAPIENTRY") ? 11 : 9;
+ n[-1] = 0;
+ type = strdup(type);
+ n += skip_length;
+ char *fonc = n;
+ n = strstr(n, "(");
+ if (n[-1] == ' ')
+ n[-1] = 0;
+ n[0] = 0;
+ fonc = strdup(fonc);
+ /*if (strstr(fonc, "glLockArraysEXT") || strstr(fonc, "glUnlockArraysEXT"))
+ {
+ }
+ else */
+
+ if (ignoreEXT == 1 && isExtByName(fonc)) {
+ free(type);
+ free(fonc);
+ continue;
+ }
+ n++;
+ while (1) {
+ char *virg = strstr(n, ",");
+ if (virg) {
+ args[narg] = n;
+ virg[0] = 0;
+ args[narg] = get_arg_type(args[narg]);
+ narg++;
+ n = virg + 1;
+ } else
+ break;
+ }
+ while (strstr(n, ")") == 0) {
+ fgets(buffer, 256, f);
+ n = buffer;
+ while (1) {
+ char *virg = strstr(n, ",");
+ if (virg) {
+ args[narg] = n;
+ virg[0] = 0;
+ args[narg] = get_arg_type(args[narg]);
+ narg++;
+ n = virg + 1;
+ } else
+ break;
+ }
+ }
+ char *par = strstr(n, ")");
args[narg] = n;
- virg[0] = 0;
+ par[0] = 0;
args[narg] = get_arg_type(args[narg]);
narg++;
- n = virg+1;
- }
- else
- break;
- }
- }
- char* par = strstr(n, ")");
- args[narg] = n;
- par[0] = 0;
- args[narg] = get_arg_type(args[narg]);
- narg++;
-
-
- /*printf("%s %s (", type, fonc);
- for(i=0;i<narg;i++)
- {
- printf("%s,", args[i]);
- }
- printf(")\n");*/
-
- for(i=0;i<funcDescCount;i++)
- {
- if (strcmp(funcDesc[i].name, fonc) == 0)
- {
- if (ignoreEXT == 0)
- funcDesc[i].isExt = 1;
- break;
+
+ /*printf("%s %s (", type, fonc);
+ for(i=0;i<narg;i++)
+ {
+ printf("%s,", args[i]);
+ }
+ printf(")\n"); */
+
+ for (i = 0; i < funcDescCount; i++) {
+ if (strcmp(funcDesc[i].name, fonc) == 0) {
+ if (ignoreEXT == 0)
+ funcDesc[i].isExt = 1;
+ break;
+ }
+ }
+ if (i == funcDescCount) {
+ funcDesc[funcDescCount].type = type;
+ funcDesc[funcDescCount].name = fonc;
+ funcDesc[funcDescCount].nargs = narg;
+ funcDesc[funcDescCount].args = args;
+ funcDesc[funcDescCount].isExt = ignoreEXT == 0;
+ funcDescCount++;
+ } else {
+ free(fonc);
+ free(args);
+ free(type);
+ }
+ /*
+ for(i=0;i<narg;i++)
+ {
+ free(args[i]);
+ }
+ free(fonc);
+ free(type); */
}
- }
- if (i == funcDescCount)
- {
- funcDesc[funcDescCount].type = type;
- funcDesc[funcDescCount].name = fonc;
- funcDesc[funcDescCount].nargs = narg;
- funcDesc[funcDescCount].args = args;
- funcDesc[funcDescCount].isExt = ignoreEXT == 0;
- funcDescCount++;
- }
- else
- {
- free(fonc);
- free(args);
- free(type);
- }
- /*
- for(i=0;i<narg;i++)
- {
- free(args[i]);
}
- free(fonc);
- free(type);*/
- }
- }
- return funcDescCount;
+ return funcDescCount;
}
-typedef struct
-{
- char* str;
- int i;
+typedef struct {
+ char *str;
+ int i;
} StringIntStruct;
-StringIntStruct argDependingOnPreviousArgTab[] =
-{
- { "glLoadProgramNV", 3},
- { "ProgramNamedParameter", 2},
- { "glDeleteBuffers", 1},
- { "glDrawBuffers", 1},
- { "glGenPrograms", 1},
- { "glDeletePrograms", 1},
- { "glGenQueries", 1},
- { "glDeleteQueries", 1},
- { "glGenFencesNV", 1},
- { "glDeleteFencesNV", 1},
- { "glGenOcclusionQueriesNV", 1},
- { "glDeleteOcclusionQueriesNV", 1},
- { "glRequestResidentProgramsNV", 1},
- { "glDeleteTextures", 1},
- { "glGenFramebuffersEXT", 1},
- { "glDeleteFramebuffersEXT", 1},
- { "glGenRenderbuffersEXT", 1},
- { "glDeleteRenderbuffersEXT", 1},
- { "glUniform1fv", 2},
- { "glUniform2fv", 2},
- { "glUniform3fv", 2},
- { "glUniform4fv", 2},
- { "glUniform1iv", 2},
- { "glUniform2iv", 2},
- { "glUniform3iv", 2},
- { "glUniform4iv", 2},
- { "glUniform1uivEXT", 2},
- { "glUniform2uivEXT", 2},
- { "glUniform3uivEXT", 2},
- { "glUniform4uivEXT", 2},
- { "glProgramParameters4fvNV", 3},
- { "glProgramParameters4dvNV", 3},
- { "glProgramLocalParameters4fvEXT", 3},
- { "glProgramLocalParametersI4ivNV", 3},
- { "glProgramLocalParametersI4uivNV", 3},
- { "glProgramEnvParameters4fvEXT", 3},
- { "glProgramEnvParametersI4ivNV", 3},
- { "glProgramEnvParametersI4uivNV", 3},
- { "glAreProgramsResidentNV", 1} ,
- { "glAreProgramsResidentNV", 2} ,
- { "glAreTexturesResident", 1} ,
- { "glAreTexturesResident", 2} ,
- { "glPrioritizeTextures", 1} ,
- { "glPrioritizeTextures", 2} ,
- { "glProgramStringARB", 3} ,
-
- { "glVertexAttribs", 2},
-
- { "glUniformMatrix", 3 },
-
- { "glGetVertexAttribfv", 2},
- { "glGetVertexAttribiv", 2},
- { "glGetVertexAttribdv", 2},
- { "glGetVertexAttribIivEXT", 2},
- { "glGetVertexAttribIuivEXT", 2},
-
- { "glPointParameterfv", 1},
- { "glPointParameteriv", 1},
-
- { "glWeightbvARB", 1},
- { "glWeightsvARB", 1},
- { "glWeightivARB", 1},
- { "glWeightfvARB", 1},
- { "glWeightdvARB", 1},
- { "glWeightubvARB", 1},
- { "glWeightusvARB", 1},
- { "glWeightuivARB", 1},
-
- { "glTexEnvfv", 2},
- { "glTexEnviv", 2},
- { "glGetTexEnvfv", 2},
- { "glGetTexEnviv", 2},
- { "glTexGendv", 2},
- { "glTexGenfv", 2},
- { "glTexGeniv", 2},
- { "glGetTexGendv", 2},
- { "glGetTexGenfv", 2},
- { "glGetTexGeniv", 2},
-
- { "glLightfv", 2},
- { "glLightiv", 2},
- { "glGetLightfv", 2},
- { "glGetLightiv", 2},
- { "glFragmentLightfvSGIX", 2},
- { "glFragmentLightivSGIX", 2},
- { "glGetFragmentLightfvSGIX", 2},
- { "glGetFragmentLightivSGIX", 2},
-
-
- { "glLightModelfv", 1},
- { "glLightModeliv", 1},
- { "glFragmentLightModelfvSGIX", 1},
- { "glFragmentLightModelivSGIX", 1},
-
- { "glMaterialfv", 2},
- { "glMaterialiv", 2},
- { "glGetMaterialfv", 2},
- { "glGetMaterialiv", 2},
- { "glFragmentMaterialfvSGIX", 2},
- { "glFragmentMaterialivSGIX", 2},
- { "glGetFragmentMaterialfvSGIX", 2},
- { "glGetFragmentMaterialivSGIX", 2},
-
- { "glFogiv", 1},
- { "glFogfv", 1},
-
- { "glTexParameterfv", 2},
- { "glTexParameteriv", 2},
- { "glGetTexParameterfv", 2},
- { "glGetTexParameteriv", 2},
-
- { "glTexParameterIivEXT", 2},
- { "glTexParameterIuivEXT", 2},
- { "glGetTexParameterIivEXT", 2},
- { "glGetTexParameterIuivEXT", 2},
-
- { "glPixelMapfv", 2},
- { "glPixelMapuiv", 2},
- { "glPixelMapusv", 2},
-
- { "glDetailTexFuncSGIS", 2 },
- { "glSharpenTexFuncSGIS", 2 },
-
- { "glSpriteParameterfvSGIX", 1 },
- { "glSpriteParameterivSGIX", 1 },
-
- { "ConvolutionParameter", 2},
-
- { "glProgramBufferParametersfvNV", 4},
- { "glProgramBufferParametersIivNV", 4},
- { "glProgramBufferParametersIuivNV", 4},
-
- { "glTransformFeedbackAttribsNV", 1},
- { "glTransformFeedbackVaryingsNV", 2},
+StringIntStruct argDependingOnPreviousArgTab[] = {
+ {"glLoadProgramNV", 3},
+ {"ProgramNamedParameter", 2},
+ {"glDeleteBuffers", 1},
+ {"glDrawBuffers", 1},
+ {"glGenPrograms", 1},
+ {"glDeletePrograms", 1},
+ {"glGenQueries", 1},
+ {"glDeleteQueries", 1},
+ {"glGenFencesNV", 1},
+ {"glDeleteFencesNV", 1},
+ {"glGenOcclusionQueriesNV", 1},
+ {"glDeleteOcclusionQueriesNV", 1},
+ {"glRequestResidentProgramsNV", 1},
+ {"glDeleteTextures", 1},
+ {"glGenFramebuffersEXT", 1},
+ {"glDeleteFramebuffersEXT", 1},
+ {"glGenRenderbuffersEXT", 1},
+ {"glDeleteRenderbuffersEXT", 1},
+ {"glUniform1fv", 2},
+ {"glUniform2fv", 2},
+ {"glUniform3fv", 2},
+ {"glUniform4fv", 2},
+ {"glUniform1iv", 2},
+ {"glUniform2iv", 2},
+ {"glUniform3iv", 2},
+ {"glUniform4iv", 2},
+ {"glUniform1uivEXT", 2},
+ {"glUniform2uivEXT", 2},
+ {"glUniform3uivEXT", 2},
+ {"glUniform4uivEXT", 2},
+ {"glProgramParameters4fvNV", 3},
+ {"glProgramParameters4dvNV", 3},
+ {"glProgramLocalParameters4fvEXT", 3},
+ {"glProgramLocalParametersI4ivNV", 3},
+ {"glProgramLocalParametersI4uivNV", 3},
+ {"glProgramEnvParameters4fvEXT", 3},
+ {"glProgramEnvParametersI4ivNV", 3},
+ {"glProgramEnvParametersI4uivNV", 3},
+ {"glAreProgramsResidentNV", 1},
+ {"glAreProgramsResidentNV", 2},
+ {"glAreTexturesResident", 1},
+ {"glAreTexturesResident", 2},
+ {"glPrioritizeTextures", 1},
+ {"glPrioritizeTextures", 2},
+ {"glProgramStringARB", 3},
+
+ {"glVertexAttribs", 2},
+
+ {"glUniformMatrix", 3},
+
+ {"glGetVertexAttribfv", 2},
+ {"glGetVertexAttribiv", 2},
+ {"glGetVertexAttribdv", 2},
+ {"glGetVertexAttribIivEXT", 2},
+ {"glGetVertexAttribIuivEXT", 2},
+
+ {"glPointParameterfv", 1},
+ {"glPointParameteriv", 1},
+
+ {"glWeightbvARB", 1},
+ {"glWeightsvARB", 1},
+ {"glWeightivARB", 1},
+ {"glWeightfvARB", 1},
+ {"glWeightdvARB", 1},
+ {"glWeightubvARB", 1},
+ {"glWeightusvARB", 1},
+ {"glWeightuivARB", 1},
+
+ {"glTexEnvfv", 2},
+ {"glTexEnviv", 2},
+ {"glGetTexEnvfv", 2},
+ {"glGetTexEnviv", 2},
+ {"glTexGendv", 2},
+ {"glTexGenfv", 2},
+ {"glTexGeniv", 2},
+ {"glGetTexGendv", 2},
+ {"glGetTexGenfv", 2},
+ {"glGetTexGeniv", 2},
+
+ {"glLightfv", 2},
+ {"glLightiv", 2},
+ {"glGetLightfv", 2},
+ {"glGetLightiv", 2},
+ {"glFragmentLightfvSGIX", 2},
+ {"glFragmentLightivSGIX", 2},
+ {"glGetFragmentLightfvSGIX", 2},
+ {"glGetFragmentLightivSGIX", 2},
+
+ {"glLightModelfv", 1},
+ {"glLightModeliv", 1},
+ {"glFragmentLightModelfvSGIX", 1},
+ {"glFragmentLightModelivSGIX", 1},
+
+ {"glMaterialfv", 2},
+ {"glMaterialiv", 2},
+ {"glGetMaterialfv", 2},
+ {"glGetMaterialiv", 2},
+ {"glFragmentMaterialfvSGIX", 2},
+ {"glFragmentMaterialivSGIX", 2},
+ {"glGetFragmentMaterialfvSGIX", 2},
+ {"glGetFragmentMaterialivSGIX", 2},
+
+ {"glFogiv", 1},
+ {"glFogfv", 1},
+
+ {"glTexParameterfv", 2},
+ {"glTexParameteriv", 2},
+ {"glGetTexParameterfv", 2},
+ {"glGetTexParameteriv", 2},
+
+ {"glTexParameterIivEXT", 2},
+ {"glTexParameterIuivEXT", 2},
+ {"glGetTexParameterIivEXT", 2},
+ {"glGetTexParameterIuivEXT", 2},
+
+ {"glPixelMapfv", 2},
+ {"glPixelMapuiv", 2},
+ {"glPixelMapusv", 2},
+
+ {"glDetailTexFuncSGIS", 2},
+ {"glSharpenTexFuncSGIS", 2},
+
+ {"glSpriteParameterfvSGIX", 1},
+ {"glSpriteParameterivSGIX", 1},
+
+ {"ConvolutionParameter", 2},
+
+ {"glProgramBufferParametersfvNV", 4},
+ {"glProgramBufferParametersIivNV", 4},
+ {"glProgramBufferParametersIuivNV", 4},
+
+ {"glTransformFeedbackAttribsNV", 1},
+ {"glTransformFeedbackVaryingsNV", 2},
};
-int is_arg_of_length_depending_on_previous_args(FuncDesc* funcDesc, int j)
+int is_arg_of_length_depending_on_previous_args(FuncDesc * funcDesc, int j)
{
- int i;
- if (strstr(funcDesc->args[j], "*") == NULL)
+ int i;
+ if (strstr(funcDesc->args[j], "*") == NULL)
+ return 0;
+ for (i = 0; i < N_ELEMENTS(argDependingOnPreviousArgTab); i++) {
+ if (strstr(funcDesc->name, argDependingOnPreviousArgTab[i].str)
+ && j == argDependingOnPreviousArgTab[i].i)
+ return 1;
+ }
return 0;
- for(i=0;i< N_ELEMENTS(argDependingOnPreviousArgTab); i++)
- {
- if (strstr(funcDesc->name, argDependingOnPreviousArgTab[i].str) && j == argDependingOnPreviousArgTab[i].i)
- return 1;
- }
- return 0;
}
-static void fprintf_prototype_args(FILE* f, FuncDesc* funcDesc)
+static void fprintf_prototype_args(FILE * f, FuncDesc * funcDesc)
{
- int j;
- for(j=0;j<funcDesc->nargs;j++)
- {
- if (j != 0) fprintf(f,", ");
- if (strstr(funcDesc->args[j], "[16]"))
- {
- if (strstr(funcDesc->args[j], "float"))
- {
- fprintf(f, "const GLfloat arg_%d[16]", j);
- }
- else if (strstr(funcDesc->args[j], "double"))
- {
- fprintf(f, "const GLdouble arg_%d[16]", j);
- }
- else
- {
- exit(-1);
- }
+ int j;
+ for (j = 0; j < funcDesc->nargs; j++) {
+ if (j != 0)
+ fprintf(f, ", ");
+ if (strstr(funcDesc->args[j], "[16]")) {
+ if (strstr(funcDesc->args[j], "float")) {
+ fprintf(f, "const GLfloat arg_%d[16]", j);
+ } else if (strstr(funcDesc->args[j], "double")) {
+ fprintf(f, "const GLdouble arg_%d[16]", j);
+ } else {
+ exit(-1);
+ }
+ } else if (strstr(funcDesc->args[j], "[128]")
+ && strstr(funcDesc->args[j], "GLubyte"))
+ fprintf(f,
+ (strstr(funcDesc->args[j], "const")) ?
+ "const GLubyte* arg_%d" : "GLubyte* arg_%d", j);
+ else
+ fprintf(f, "%s arg_%d", funcDesc->args[j], j);
}
- else if (strstr(funcDesc->args[j], "[128]") && strstr(funcDesc->args[j], "GLubyte"))
- fprintf(f, (strstr(funcDesc->args[j], "const")) ? "const GLubyte* arg_%d" : "GLubyte* arg_%d", j);
- else
- fprintf(f, "%s arg_%d", funcDesc->args[j], j);
- }
+ if (j == 0)
+ fprintf(f, "void");
}
-static void gen_mangled_gl(FuncDesc *funcs_p, int func_cnt)
+static void gen_mangled_gl(FuncDesc * funcs_p, int func_cnt)
{
int i;
FILE *header = fopen("gl_mangled.h", "w");
FILE *source = fopen("gl_mangled.c", "w");
- char** args;
+ char **args;
assert(header && source);
/* Manually add glGetString */
- args = malloc(1 * sizeof(char*));
+ args = malloc(1 * sizeof(char *));
args[0] = strdup("GLenum");
funcs_p[func_cnt].type = strdup("const GLubyte *");
funcs_p[func_cnt].name = strdup("glGetString");
funcs_p[func_cnt].args = args;
func_cnt++;
- fprintf(header, "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(header,
+ "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
fprintf(header, "#include <GL/gl.h>\n\n");
fprintf(header, "typedef struct mglHDL {\n");
for (i = 0; i < func_cnt; ++i) {
fprintf(header, "\t%s (*%s)(", funcs_p[i].type, funcs_p[i].name);
- if (funcs_p[i].nargs == 1 && !strncmp(funcs_p[i].args[0], "void", 4)) {
+ if (funcs_p[i].nargs == 1 && !strncmp(funcs_p[i].args[0], "void", 4)) {
free(funcs_p[i].args[0]);
funcs_p[i].nargs = 0;
fprintf(header, "void");
fprintf(header, "int mgl_unload(void);\n\n");
for (i = 0; i < func_cnt; ++i) {
- fprintf(header, "#define %s mgl_hdl.%s\n", funcs_p[i].name, funcs_p[i].name);
+ fprintf(header, "#define %s mgl_hdl.%s\n", funcs_p[i].name,
+ funcs_p[i].name);
}
fprintf(header, "\n");
- fprintf(source, "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(source,
+ "/* This file is generated by parse_gl_h.c - DO NOT EDIT ! */\n\n");
fprintf(source, "#include <stdio.h>\n#include \"gl_mangled.h\"\n\n");
fprintf(source, "#ifdef _WIN32\n#include <Windows.h>\n"
"typedef HINSTANCE handle_t;\n#else\n#include <dlfcn.h>\n"
fprintf(source, "mglHDL mgl_hdl;\n");
fprintf(source, "static handle_t mgl_lib_hdl;\n\n");
- fprintf(source, "static inline handle_t mgl_load_lib(const char *libname)\n{\n"
+ fprintf(source,
+ "static inline handle_t mgl_load_lib(const char *libname)\n{\n"
"#ifdef _WIN32\n\treturn LoadLibrary(libname);\n"
"#else\n\treturn dlopen(libname, RTLD_LAZY | RTLD_LOCAL);\n"
"#endif\n}\n\n");
fprintf(source, "static inline void *mgl_load_sym(const char *symname)\n{\n"
"#ifdef _WIN32\n\treturn GetProcAddress(mgl_lib_hdl, symname);\n"
- "#else\n\treturn dlsym(mgl_lib_hdl, symname);\n"
- "#endif\n}\n\n");
+ "#else\n\treturn dlsym(mgl_lib_hdl, symname);\n" "#endif\n}\n\n");
fprintf(source, "int mgl_unload(void)\n{\n"
"#ifdef _WIN32\n\treturn FreeLibrary(mgl_lib_hdl);\n"
- "#else\n\treturn dlclose(mgl_lib_hdl);\n"
- "#endif\n}\n\n");
+ "#else\n\treturn dlclose(mgl_lib_hdl);\n" "#endif\n}\n\n");
fprintf(source, "int mgl_load_symbols(const char *libname)\n{\n"
"\tif (!(mgl_lib_hdl = mgl_load_lib(libname))) {\n"
fclose(source);
}
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- FuncDesc funcDesc[3000];
- int funcDescCount = 0;
- FILE* f;
-
- printf("***** path : %s\n", GL_INCLUDE_PATH"mesa_gl.h");
- f = fopen(GL_INCLUDE_PATH"mesa_gl.h", "r");
- assert(f);
- /*if (!f)
- f = fopen("/usr/include/GL/gl.h", "r");*/
- funcDescCount = parse(f, funcDesc, 0, 1);
- fclose(f);
-
- if ((argc > 1) && !strncmp(argv[1], "mangle", 6)) {
- gen_mangled_gl(funcDesc, funcDescCount);
- return 0;
- }
-
- f = fopen(GL_INCLUDE_PATH"mesa_glext.h", "r");
- assert(f);
- /*if (!f)
- f = fopen("/usr/include/GL/glext.h", "r");*/
- funcDescCount = parse(f, funcDesc, funcDescCount, 0);
- fclose(f);
-
- FILE* header = fopen("gl_func.h", "w");
- FILE* client_stub = fopen("client_stub.c", "w");
- FILE* server_stub = fopen("server_stub.c", "w");
-
- fprintf(header, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
- fprintf(header, "union gl_ret_type {\n"
- "const char *s;\n"
- "int i;\n"
- "char c;\n"
- "};\n");
-
- fprintf(header, "#define COMPOSE(x,y) x##y\n");
- fprintf(header, "#define MAGIC_MACRO(x) COMPOSE(x,_func)\n");
- fprintf(header, "enum {\n"
- "#include \"gl_func_perso.h\"\n");
-
- fprintf(client_stub, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
-
- fprintf(server_stub, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
-
- int i;
- for(i=0;i<funcDescCount;i++)
- {
- funcDesc[i].ok = 0;
- char* name = funcDesc[i].name;
- char* type = funcDesc[i].type;
- if ((strcmp(type, "void") == 0 || strcmp(type, "GLboolean") == 0 ||
- strcmp(type, "GLuint") == 0 || strcmp(type, "GLint") == 0 ||
- strcmp(type, "GLenum") == 0) || strcmp(type, "GLhandleARB") == 0 ||
- strcmp(type, "GLhalf") == 0 || strcmp(type, "GLhalfNV") == 0)
- {
- int pointer_of_unknown_size = 0;
- int j;
-
- if (funcDesc[i].nargs == 1 && strcmp(funcDesc[i].args[0], "void") == 0)
- {
- funcDesc[i].nargs = 0;
- }
- for(j=0;j<funcDesc[i].nargs-1;j++)
- {
- if (!is_arg_of_length_depending_on_previous_args(&funcDesc[i], j) &&
- strstr(funcDesc[i].args[j], "const GLchar") == NULL &&
- strstr(funcDesc[i].args[j], "[16]") == NULL)
- {
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "*") != NULL;
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "[") != NULL;
- }
- }
-
- if (pointer_of_unknown_size == 0)
- {
- char* signature_type_name;
- if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL))
- {
- if (strstr(signature_type_name, "TYPE_OUT"))
- funcDesc[i].has_out_parameters = 1;
- }
- else
- {
- if (funcDesc[i].nargs-1 >= 0)
- {
- j = funcDesc[i].nargs-1;
- if (!is_arg_of_length_depending_on_previous_args(&funcDesc[i], j) &&
- strstr(funcDesc[i].args[j], "const GLchar") == NULL &&
- strstr(funcDesc[i].args[j], "[16]") == NULL)
- {
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "*") != NULL;
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "[") != NULL;
+ FuncDesc funcDesc[3000];
+ int funcDescCount = 0;
+ FILE *f;
+
+ printf("***** path : %s\n", GL_INCLUDE_PATH "mesa_gl.h");
+ f = fopen(GL_INCLUDE_PATH "mesa_gl.h", "r");
+ assert(f);
+ /*if (!f)
+ f = fopen("/usr/include/GL/gl.h", "r"); */
+ funcDescCount = parse(f, funcDesc, 0, 1);
+ fclose(f);
+
+ if ((argc > 1) && !strncmp(argv[1], "mangle", 6)) {
+ gen_mangled_gl(funcDesc, funcDescCount);
+ return 0;
+ }
+
+ f = fopen(GL_INCLUDE_PATH "mesa_glext.h", "r");
+ assert(f);
+ /*if (!f)
+ f = fopen("/usr/include/GL/glext.h", "r"); */
+ funcDescCount = parse(f, funcDesc, funcDescCount, 0);
+ fclose(f);
+
+ FILE *header = fopen("gl_func.h", "w");
+ FILE *client_stub = fopen("client_stub.c", "w");
+ FILE *server_stub = fopen("server_stub.c", "w");
+
+ fprintf(header,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(header,
+ "union gl_ret_type {\n" "const char *s;\n" "int i;\n" "char c;\n"
+ "};\n");
+
+ fprintf(header, "#define COMPOSE(x,y) x##y\n");
+ fprintf(header, "#define MAGIC_MACRO(x) COMPOSE(x,_func)\n");
+ fprintf(header, "enum {\n" "#include \"gl_func_perso.h\"\n");
+
+ fprintf(client_stub,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+
+ fprintf(server_stub,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+
+ int i;
+ for (i = 0; i < funcDescCount; i++) {
+ funcDesc[i].ok = 0;
+ char *name = funcDesc[i].name;
+ char *type = funcDesc[i].type;
+ if ((strcmp(type, "void") == 0 || strcmp(type, "GLboolean") == 0 ||
+ strcmp(type, "GLuint") == 0 || strcmp(type, "GLint") == 0 ||
+ strcmp(type, "GLenum") == 0) || strcmp(type, "GLhandleARB") == 0 ||
+ strcmp(type, "GLhalf") == 0 || strcmp(type, "GLhalfNV") == 0) {
+ int pointer_of_unknown_size = 0;
+ int j;
+
+ if (funcDesc[i].nargs == 1
+ && strcmp(funcDesc[i].args[0], "void") == 0) {
+ funcDesc[i].nargs = 0;
+ }
+ for (j = 0; j < funcDesc[i].nargs - 1; j++) {
+ if (!is_arg_of_length_depending_on_previous_args
+ (&funcDesc[i], j)
+ && strstr(funcDesc[i].args[j], "const GLchar") == NULL
+ && strstr(funcDesc[i].args[j], "[16]") == NULL) {
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "*") != NULL;
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "[") != NULL;
+ }
+ }
+
+ if (pointer_of_unknown_size == 0) {
+ char *signature_type_name;
+ if (is_known_arg_vector
+ (&funcDesc[i], &signature_type_name, NULL)) {
+ if (strstr(signature_type_name, "TYPE_OUT"))
+ funcDesc[i].has_out_parameters = 1;
+ } else {
+ if (funcDesc[i].nargs - 1 >= 0) {
+ j = funcDesc[i].nargs - 1;
+ if (!is_arg_of_length_depending_on_previous_args
+ (&funcDesc[i], j)
+ && strstr(funcDesc[i].args[j],
+ "const GLchar") == NULL
+ && strstr(funcDesc[i].args[j], "[16]") == NULL) {
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "*") != NULL;
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "[") != NULL;
+ }
+ }
+ }
+ }
+ if (pointer_of_unknown_size && funcDesc[i].nargs == 1) {
+ if (strstr(funcDesc[i].name, "Matrixf")
+ || strstr(funcDesc[i].name, "Matrixd")) {
+ free(funcDesc[i].args[0]);
+ if (strstr(funcDesc[i].name, "Matrixf"))
+ funcDesc[i].args[0] = strdup("GLfloat m[16]");
+ else
+ funcDesc[i].args[0] = strdup("GLdouble m[16]");
+ pointer_of_unknown_size = 0;
+ } else if (strcmp(funcDesc[i].name, "glPolygonStipple") == 0) {
+ free(funcDesc[i].args[0]);
+ funcDesc[i].args[0] = strdup("const GLubyte mask[128]");
+ pointer_of_unknown_size = 0;
+ } else if (strcmp(funcDesc[i].name, "glGetPolygonStipple") == 0) {
+ free(funcDesc[i].args[0]);
+ funcDesc[i].args[0] = strdup("GLubyte mask[128]");
+ funcDesc[i].has_out_parameters = 1;
+ pointer_of_unknown_size = 0;
+ }
+ }
+ if (just_for_server_side_func(name) || pointer_of_unknown_size == 0) {
+ fprintf(header, " %s_func,\n", funcDesc[i].name);
+ funcDesc[i].ok = 1;
+ if (just_for_server_side_func(name))
+ funcDesc[i].just_for_server_side = 1;
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (strstr(get_type_string(funcDesc[i].args[j]), "OUT"))
+ funcDesc[i].has_out_parameters = 1;
+ }
+ } else {
+ fprintf(stderr,
+ "not handled either manually or automatically : %s\n",
+ funcDesc[i].name);
}
- }
- }
- }
- if (pointer_of_unknown_size && funcDesc[i].nargs == 1)
- {
- if (strstr(funcDesc[i].name, "Matrixf") || strstr(funcDesc[i].name, "Matrixd"))
- {
- free(funcDesc[i].args[0]);
- if (strstr(funcDesc[i].name, "Matrixf"))
- funcDesc[i].args[0] = strdup("GLfloat m[16]");
- else
- funcDesc[i].args[0] = strdup("GLdouble m[16]");
- pointer_of_unknown_size = 0;
- }
- else if (strcmp(funcDesc[i].name, "glPolygonStipple") == 0)
- {
- free(funcDesc[i].args[0]);
- funcDesc[i].args[0] = strdup("const GLubyte mask[128]");
- pointer_of_unknown_size = 0;
- }
- else if (strcmp(funcDesc[i].name, "glGetPolygonStipple") == 0)
- {
- free(funcDesc[i].args[0]);
- funcDesc[i].args[0] = strdup("GLubyte mask[128]");
- funcDesc[i].has_out_parameters = 1;
- pointer_of_unknown_size = 0;
- }
- }
- if (just_for_server_side_func(name) || pointer_of_unknown_size == 0)
- {
- fprintf(header, " %s_func,\n", funcDesc[i].name);
- funcDesc[i].ok = 1;
- if (just_for_server_side_func(name))
- funcDesc[i].just_for_server_side = 1;
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (strstr(get_type_string(funcDesc[i].args[j]), "OUT"))
- funcDesc[i].has_out_parameters = 1;
}
- }
- else
- {
- fprintf(stderr, "not handled either manually or automatically : %s\n", funcDesc[i].name);
- }
}
- }
-
- fprintf(header, " GL_N_CALLS\n};\n");
-
-
- fprintf(server_stub, "void execute_func(int func_number, void **args, union gl_ret_type *pret)\n");
- fprintf(server_stub, "{\n");
- fprintf(server_stub, " switch(func_number)\n");
- fprintf(server_stub, " {\n");
-
-
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
- fprintf(header, "static const int %s_signature[] = { %s, %d, ",
- funcDesc[i].name,
- get_type_string(funcDesc[i].type),
- funcDesc[i].has_out_parameters);
- fprintf(header, "%d", funcDesc[i].nargs);
- int j;
- char* signature_type_name;
- int n_args_to_check = is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL) ? funcDesc[i].nargs - 1 : funcDesc[i].nargs;
-
- for(j=0;j<n_args_to_check;j++)
- {
- if (is_arg_of_length_depending_on_previous_args(&funcDesc[i], j))
- {
- fprintf(header, ", %s_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS", get_type_string(funcDesc[i].args[j]));
- }
- else
- fprintf(header, ", %s", get_type_string(funcDesc[i].args[j]));
- }
-
- if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL))
- {
- fprintf(header, ", %s", signature_type_name);
- }
- fprintf(header, "};\n");
-
-
- if (funcDesc[i].just_for_server_side == 0)
- {
- if (isExt(&funcDesc[i]))
- fprintf(client_stub, "GLAPI %s APIENTRY EXT_FUNC(%s) (", funcDesc[i].type, funcDesc[i].name);
- else
- fprintf(client_stub, "GLAPI %s APIENTRY %s(", funcDesc[i].type, funcDesc[i].name);
- fprintf_prototype_args(client_stub, &funcDesc[i]);
- fprintf(client_stub, ")\n");
- fprintf(client_stub, "{\n");
- if (strcmp(funcDesc[i].type, "void") != 0)
- {
- fprintf(client_stub, " %s ret;\n", funcDesc[i].type);
- if (isExt(&funcDesc[i]))
- fprintf(client_stub, " CHECK_PROC_WITH_RET(%s);\n", funcDesc[i].name);
- }
- else
- {
- if (isExt(&funcDesc[i]))
- fprintf(client_stub, " CHECK_PROC(%s);\n", funcDesc[i].name);
- }
-
- /*
- fprintf(client_stub, " do_opengl_call(%s_func, %s",
- funcDesc[i].name, (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret");
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- fprintf(client_stub, ", arg_%d", j);
- }
- fprintf(client_stub, ");\n");
- */
-
- if (funcDesc[i].nargs)
- {
- fprintf(client_stub, " long args[] = { ");
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (j > 0) fprintf(client_stub, ", ");
- if (strstr(funcDesc[i].args[j], "*"))
- {
- fprintf(client_stub, "POINTER_TO_ARG(arg_%d)", j);
+
+ fprintf(header, " GL_N_CALLS\n};\n");
+
+ fprintf(server_stub,
+ "static void execute_func(int func_number, void **args, union gl_ret_type *pret)\n");
+ fprintf(server_stub, "{\n");
+ fprintf(server_stub, " switch(func_number)\n");
+ fprintf(server_stub, " {\n");
+
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
+ fprintf(header, "static const int %s_signature[] = { %s, %d, ",
+ funcDesc[i].name,
+ get_type_string(funcDesc[i].type),
+ funcDesc[i].has_out_parameters);
+ fprintf(header, "%d", funcDesc[i].nargs);
+ int j;
+ char *signature_type_name;
+ int n_args_to_check =
+ is_known_arg_vector(&funcDesc[i], &signature_type_name,
+ NULL) ? funcDesc[i].nargs -
+ 1 : funcDesc[i].nargs;
+
+ for (j = 0; j < n_args_to_check; j++) {
+ if (is_arg_of_length_depending_on_previous_args
+ (&funcDesc[i], j)) {
+ fprintf(header, ", %s_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS",
+ get_type_string(funcDesc[i].args[j]));
+ } else
+ fprintf(header, ", %s",
+ get_type_string(funcDesc[i].args[j]));
}
- else
+
+ if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL)) {
+ fprintf(header, ", %s", signature_type_name);
+ }
+ fprintf(header, "};\n");
+
+ if (funcDesc[i].just_for_server_side == 0) {
+ if (isExt(&funcDesc[i]))
+ fprintf(client_stub, "GLAPI %s APIENTRY EXT_FUNC(%s) (",
+ funcDesc[i].type, funcDesc[i].name);
+ else
+ fprintf(client_stub, "GLAPI %s APIENTRY %s(",
+ funcDesc[i].type, funcDesc[i].name);
+ fprintf_prototype_args(client_stub, &funcDesc[i]);
+ fprintf(client_stub, ")\n");
+ fprintf(client_stub, "{\n");
+ if (strcmp(funcDesc[i].type, "void") != 0) {
+ fprintf(client_stub, " %s ret;\n", funcDesc[i].type);
+ if (isExt(&funcDesc[i]))
+ fprintf(client_stub, " CHECK_PROC_WITH_RET(%s);\n",
+ funcDesc[i].name);
+ } else {
+ if (isExt(&funcDesc[i]))
+ fprintf(client_stub, " CHECK_PROC(%s);\n",
+ funcDesc[i].name);
+ }
+
+ /*
+ fprintf(client_stub, " do_opengl_call(%s_func, %s",
+ funcDesc[i].name, (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret");
+ for(j=0;j<funcDesc[i].nargs;j++)
+ {
+ fprintf(client_stub, ", arg_%d", j);
+ }
+ fprintf(client_stub, ");\n");
+ */
+
+ if (funcDesc[i].nargs) {
+ fprintf(client_stub, " long args[] = { ");
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (j > 0)
+ fprintf(client_stub, ", ");
+ if (strstr(funcDesc[i].args[j], "*")) {
+ fprintf(client_stub, "POINTER_TO_ARG(arg_%d)", j);
+ } else {
+ const char *symbolic_type =
+ get_type_string(funcDesc[i].args[j]);
+ if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
+ fprintf(client_stub, "CHAR_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR")
+ == 0)
+ fprintf(client_stub, "UNSIGNED_CHAR_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
+ fprintf(client_stub, "SHORT_TO_ARG");
+ else if (strcmp
+ (symbolic_type,
+ "TYPE_UNSIGNED_SHORT") == 0)
+ fprintf(client_stub, "UNSIGNED_SHORT_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_INT") == 0)
+ fprintf(client_stub, "INT_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT")
+ == 0)
+ fprintf(client_stub, "UNSIGNED_INT_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
+ fprintf(client_stub, "FLOAT_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
+ fprintf(client_stub, "POINTER_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
+ fprintf(client_stub, "DOUBLE_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_16DOUBLE") ==
+ 0)
+ fprintf(client_stub, "POINTER_TO_ARG");
+ else if (strcmp(symbolic_type, "TYPE_128UCHAR") == 0
+ || strcmp(symbolic_type,
+ "TYPE_OUT_128UCHAR") == 0)
+ fprintf(client_stub, "POINTER_TO_ARG");
+ else {
+ fprintf(stderr, "Unknown : %s\n",
+ symbolic_type);
+ assert(0);
+ }
+ fprintf(client_stub, "(arg_%d)", j);
+ }
+ }
+ fprintf(client_stub, "};\n");
+ }
+
+ fprintf(client_stub,
+ " do_opengl_call(%s_func, %s, %s, NULL);\n",
+ funcDesc[i].name,
+ (strcmp(funcDesc[i].type, "void") ==
+ 0) ? "NULL" : "&ret",
+ (funcDesc[i].nargs) ? "args" : "NULL");
+
+ if (strcmp(funcDesc[i].type, "void") != 0) {
+ fprintf(client_stub, " return ret;\n");
+ }
+ fprintf(client_stub, "}\n\n");
+ }
+
+ fprintf(server_stub, " case %s_func:\n", funcDesc[i].name);
+ fprintf(server_stub, " {\n");
+
+ if (isExt(&funcDesc[i])) {
+ fprintf(server_stub, " GET_EXT_PTR(%s, %s, (",
+ funcDesc[i].type, funcDesc[i].name);
+ fprintf_prototype_args(server_stub, &funcDesc[i]);
+ fprintf(server_stub, "));\n");
+ }
+
+ fprintf(server_stub, " ");
+
+ if (strcmp(funcDesc[i].type, "void") == 0) ;
+ else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_INT") == 0
+ || strcmp(get_type_string(funcDesc[i].type),
+ "TYPE_UNSIGNED_INT") == 0)
+ fprintf(server_stub, "pret->i = ");
+ else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_CHAR") == 0
+ || strcmp(get_type_string(funcDesc[i].type),
+ "TYPE_UNSIGNED_CHAR") == 0)
+ fprintf(server_stub, "pret->c = ");
+ else {
+ fprintf(stderr, "unknown ret type = %s\n",
+ get_type_string(funcDesc[i].type));
+ exit(-1);
+ }
+ /*if (strstr(funcDesc[i].name, "EXT"))
+ {
+ char* dup = strdup(funcDesc[i].name);
+ *strstr(dup, "EXT") = 0;
+ fprintf(server_stub, "%s(", dup);
+ free(dup);
+ }
+ else */
{
- const char* symbolic_type = get_type_string(funcDesc[i].args[j]);
- if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
- fprintf(client_stub, "CHAR_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0)
- fprintf(client_stub, "UNSIGNED_CHAR_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
- fprintf(client_stub, "SHORT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0)
- fprintf(client_stub, "UNSIGNED_SHORT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_INT") == 0)
- fprintf(client_stub, "INT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0)
- fprintf(client_stub, "UNSIGNED_INT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
- fprintf(client_stub, "FLOAT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
- fprintf(client_stub, "POINTER_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
- fprintf(client_stub, "DOUBLE_TO_ARG");
- else if ( strcmp(symbolic_type, "TYPE_16DOUBLE") == 0)
- fprintf(client_stub, "POINTER_TO_ARG");
- else if ( strcmp(symbolic_type, "TYPE_128UCHAR") == 0 || strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0)
- fprintf(client_stub, "POINTER_TO_ARG");
- else
- {
- fprintf(stderr, "Unknown : %s\n", symbolic_type);
- assert(0);
- }
- fprintf(client_stub, "(arg_%d)", j);
+ if (isExt(&funcDesc[i]))
+ fprintf(server_stub, "ptr_func_%s(", funcDesc[i].name);
+ else
+ fprintf(server_stub, "%s(", funcDesc[i].name);
}
- }
- fprintf(client_stub, "};\n");
- }
-
- fprintf(client_stub, " do_opengl_call(%s_func, %s, %s, NULL);\n",
- funcDesc[i].name, (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret",
- (funcDesc[i].nargs) ? "args" : "NULL");
-
- if (strcmp(funcDesc[i].type, "void") != 0)
- {
- fprintf(client_stub, " return ret;\n");
- }
- fprintf(client_stub, "}\n\n");
- }
-
- fprintf(server_stub, " case %s_func:\n", funcDesc[i].name);
- fprintf(server_stub, " {\n");
-
- if (isExt(&funcDesc[i]))
- {
- fprintf(server_stub, " GET_EXT_PTR(%s, %s, (", funcDesc[i].type, funcDesc[i].name);
- fprintf_prototype_args(server_stub, &funcDesc[i]);
- fprintf(server_stub, "));\n");
- }
-
- fprintf(server_stub, " ");
-
- if (strcmp(funcDesc[i].type, "void") == 0)
- ;
- else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_INT") == 0 ||
- strcmp(get_type_string(funcDesc[i].type), "TYPE_UNSIGNED_INT") == 0)
- fprintf(server_stub, "pret->i = ");
- else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_CHAR") == 0 ||
- strcmp(get_type_string(funcDesc[i].type), "TYPE_UNSIGNED_CHAR") == 0)
- fprintf(server_stub, "pret->c = ");
- else
- {
- fprintf(stderr, "unknown ret type = %s\n", get_type_string(funcDesc[i].type));
- exit(-1);
- }
- /*if (strstr(funcDesc[i].name, "EXT"))
- {
- char* dup = strdup(funcDesc[i].name);
- *strstr(dup, "EXT") = 0;
- fprintf(server_stub, "%s(", dup);
- free(dup);
- }
- else*/
- {
- if (isExt(&funcDesc[i]))
- fprintf(server_stub, "ptr_func_%s(", funcDesc[i].name);
- else
- fprintf(server_stub, "%s(", funcDesc[i].name);
- }
- char* c_type_name;
- if (is_known_arg_vector(&funcDesc[i], NULL, &c_type_name))
- {
- for(j=0;j<funcDesc[i].nargs - 1;j++)
- {
- if (j != 0) fprintf(server_stub,", ");
- print_server_side_argument(server_stub, j, funcDesc[i].args[j]);
- }
- if (j != 0) fprintf(server_stub,", ");
- if (strstr(funcDesc[i].args[funcDesc[i].nargs - 1], "const"))
- fprintf(server_stub, "(const %s*)args[%d]", c_type_name, j);
- else
- fprintf(server_stub, "(%s*)args[%d]", c_type_name, j);
- }
- else
- {
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (j != 0) fprintf(server_stub,", ");
- print_server_side_argument(server_stub, j, funcDesc[i].args[j]);
+ char *c_type_name;
+ if (is_known_arg_vector(&funcDesc[i], NULL, &c_type_name)) {
+ for (j = 0; j < funcDesc[i].nargs - 1; j++) {
+ if (j != 0)
+ fprintf(server_stub, ", ");
+ print_server_side_argument(server_stub, j,
+ funcDesc[i].args[j]);
+ }
+ if (j != 0)
+ fprintf(server_stub, ", ");
+ if (strstr(funcDesc[i].args[funcDesc[i].nargs - 1], "const"))
+ fprintf(server_stub, "(const %s*)args[%d]", c_type_name, j);
+ else
+ fprintf(server_stub, "(%s*)args[%d]", c_type_name, j);
+ } else {
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (j != 0)
+ fprintf(server_stub, ", ");
+ print_server_side_argument(server_stub, j,
+ funcDesc[i].args[j]);
+ }
+ }
+ fprintf(server_stub, ");\n");
+
+ fprintf(server_stub, " break;\n");
+ fprintf(server_stub, " }\n");
}
- }
- fprintf(server_stub, ");\n");
-
- fprintf(server_stub, " break;\n");
- fprintf(server_stub, " }\n");
}
- }
-
- fprintf(server_stub, " default:\n");
- fprintf(server_stub, " DEBUGF(\"unknown=%%d\", func_number);\n");
- fprintf(server_stub, " break;\n");
- fprintf(server_stub, " }\n");
- fprintf(server_stub, "}\n");
-
- fprintf(header, "#undef MAGIC_MACRO\n");
- fprintf(header, "#define MAGIC_MACRO(x) COMPOSE(x,_signature)\n");
- fprintf(header, "static const int* tab_opengl_calls[GL_N_CALLS] =\n");
- fprintf(header, "{\n");
- fprintf(header, "#include \"gl_func_perso.h\"\n");
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
- fprintf(header, " %s_signature,\n", funcDesc[i].name);
+
+ fprintf(server_stub, " default:\n");
+ fprintf(server_stub, " DEBUGF(\"unknown=%%d\", func_number);\n");
+ fprintf(server_stub, " break;\n");
+ fprintf(server_stub, " }\n");
+ fprintf(server_stub, "}\n");
+
+ fprintf(header, "#undef MAGIC_MACRO\n");
+ fprintf(header, "#define MAGIC_MACRO(x) COMPOSE(x,_signature)\n");
+ fprintf(header, "static const int* tab_opengl_calls[GL_N_CALLS] =\n");
+ fprintf(header, "{\n");
+ fprintf(header, "#include \"gl_func_perso.h\"\n");
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
+ fprintf(header, " %s_signature,\n", funcDesc[i].name);
+ }
}
- }
- fprintf(header, "};\n\n");
-
- fprintf(header, "#undef MAGIC_MACRO\n");
- fprintf(header, "#define MAGIC_MACRO(x) #x\n");
- fprintf(header, "static const char* tab_opengl_calls_name[GL_N_CALLS] =\n");
- fprintf(header, "{\n");
- fprintf(header, "#include \"gl_func_perso.h\"\n");
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
- fprintf(header, " \"%s\",\n", funcDesc[i].name);
+ fprintf(header, "};\n\n");
+
+ fprintf(header, "#undef MAGIC_MACRO\n");
+ fprintf(header, "#define MAGIC_MACRO(x) #x\n");
+ fprintf(header, "static const char* tab_opengl_calls_name[GL_N_CALLS] =\n");
+ fprintf(header, "{\n");
+ fprintf(header, "#include \"gl_func_perso.h\"\n");
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
+ fprintf(header, " \"%s\",\n", funcDesc[i].name);
+ }
}
- }
- fprintf(header, "};\n\n");
-
- fclose(header);
- fclose(server_stub);
- fclose(client_stub);
-
- return 0;
+ fprintf(header, "};\n\n");
+
+ fclose(header);
+ fclose(server_stub);
+ fclose(client_stub);
+
+ return 0;
}
#ifndef _OPENGL_UTILS
#define _OPENGL_UTILS
-void *g_malloc(size_t size);
-void *g_realloc(void *ptr, size_t size);
-void g_free(void *ptr);
-
typedef struct {
unsigned int *values;
int nbValues;
#include "virtio.h"
-VirtIODevice *virtio_gl_init(DeviceState *dev)
+VirtIODevice *virtio_gl_init(DeviceState * dev)
{
- return NULL;
+ return NULL;
}
-
typedef target_phys_addr_t arg_t;
#include "opengl_process.h"
#include "opengl_exec.h"
+#include "helper_opengl.h"
#include <sys/time.h>
#include "tizen/src/debug_ch.h"
-MULTI_DEBUG_CHANNEL(qemu, virtio-gl);
-
-int decode_call_int(ProcessStruct *p, char *in_args, int args_len, char *r_buffer);
+MULTI_DEBUG_CHANNEL(qemu, virtio - gl);
/* Uncomment to enable debugging - WARNING!!! changes ABI! */
//#define DEBUG_GLIO
-typedef struct VirtIOGL
-{
- VirtIODevice vdev;
- VirtQueue *vq;
+typedef struct VirtIOGL {
+ VirtIODevice vdev;
+ VirtQueue *vq;
} VirtIOGL;
-struct d_hdr
-{
- int pid;
- int rq_l;
- int rrq_l;
+struct d_hdr {
+ int pid;
+ int rq_l;
+ int rrq_l;
#ifdef DEBUG_GLIO
- int sum;
+ int sum;
#endif
};
#define SIZE_IN_HEADER 4
#endif
-static void virtio_gl_handle(VirtIODevice *vdev, VirtQueue *vq)
+static void virtio_gl_handle(VirtIODevice * vdev, VirtQueue * vq)
{
- VirtQueueElement elem;
- int nkill = 1;
-
- TRACE("virtio_gl_handle called. \n");
-
- while(virtqueue_pop(vq, &elem)) {
- struct d_hdr *hdr = (struct d_hdr*)elem.out_sg[0].iov_base;
- ProcessStruct *process;
- int i, remain;
- int ret = 0;
-
- if(!elem.out_num) {
- fprintf(stderr, "Bad packet\n");
- virtqueue_push(vq, &elem, ret);
- virtio_notify(vdev, vq);
- return;
- }
-
- process = vmgl_get_process(hdr->pid);
-
- if(hdr->rq_l) {
-
- if(hdr->rrq_l) {
- if(process->rq) { // Usually only the quit packet...
- free(process->rq);
- free(process->rrq);
- }
- // process->rq = process->rq_p = qemu_malloc(hdr->rq_l);
- // process->rrq = process->rrq_p = qemu_malloc(hdr->rrq_l);
- process->rq = process->rq_p = g_malloc(hdr->rq_l);
- process->rrq = process->rrq_p = g_malloc(hdr->rrq_l);
- process->rq_l = hdr->rq_l - SIZE_OUT_HEADER;
- process->rrq_l = hdr->rrq_l;
+ VirtQueueElement elem;
+ int nkill = 1;
+
+ TRACE("virtio_gl_handle called. \n");
+
+ while (virtqueue_pop(vq, &elem)) {
+ struct d_hdr *hdr = (struct d_hdr *)elem.out_sg[0].iov_base;
+ ProcessStruct *process;
+ int i, remain;
+ int ret = 0;
+
+ if (!elem.out_num) {
+ fprintf(stderr, "Bad packet\n");
+ virtqueue_push(vq, &elem, ret);
+ virtio_notify(vdev, vq);
+ return;
+ }
+
+ process = vmgl_get_process(hdr->pid);
+
+ if (hdr->rq_l) {
+
+ if (hdr->rrq_l) {
+ if (process->rq) { // Usually only the quit packet...
+ free(process->rq);
+ free(process->rrq);
+ }
+ // process->rq = process->rq_p = qemu_malloc(hdr->rq_l);
+ // process->rrq = process->rrq_p = qemu_malloc(hdr->rrq_l);
+ process->rq = process->rq_p = g_malloc(hdr->rq_l);
+ process->rrq = process->rrq_p = g_malloc(hdr->rrq_l);
+ process->rq_l = hdr->rq_l - SIZE_OUT_HEADER;
+ process->rrq_l = hdr->rrq_l;
#ifdef DEBUG_GLIO
- process->sum = hdr->sum;
+ process->sum = hdr->sum;
#endif
- }
+ }
- i = 0;
- remain = process->rq_l - (process->rq_p - process->rq);
- while(remain && i < elem.out_num){
- char *src = (char *)elem.out_sg[i].iov_base;
- int ilen = elem.out_sg[i].iov_len;
- int len = remain;
+ i = 0;
+ remain = process->rq_l - (process->rq_p - process->rq);
+ while (remain && i < elem.out_num) {
+ char *src = (char *)elem.out_sg[i].iov_base;
+ int ilen = elem.out_sg[i].iov_len;
+ int len = remain;
- if(i == 0) {
- src += SIZE_OUT_HEADER;
- ilen -= SIZE_OUT_HEADER;
- }
+ if (i == 0) {
+ src += SIZE_OUT_HEADER;
+ ilen -= SIZE_OUT_HEADER;
+ }
- if(len > ilen)
- len = ilen;
+ if (len > ilen)
+ len = ilen;
- memcpy(process->rq_p, src, len);
- process->rq_p += len;
- remain -= len;
- i++;
- }
+ memcpy(process->rq_p, src, len);
+ process->rq_p += len;
+ remain -= len;
+ i++;
+ }
- if(process->rq_p >= process->rq + process->rq_l) {
+ if (process->rq_p >= process->rq + process->rq_l) {
#ifdef DEBUG_GLIO
- int sum = 0;
- for(i = 0; i < process->rq_l ; i++)
- sum += process->rq[i];
- if(sum != process->sum)
- fprintf(stderr, "Checksum fail\n");
+ int sum = 0;
+ for (i = 0; i < process->rq_l; i++)
+ sum += process->rq[i];
+ if (sum != process->sum)
+ fprintf(stderr, "Checksum fail\n");
#endif
- *(int*)process->rrq = nkill = decode_call_int(process,
- process->rq, /* command_buffer */
- process->rq_l, /* cmd buffer length */
- process->rrq + SIZE_IN_HEADER); /* return buffer */
+ *(int *)process->rrq = nkill = decode_call_int(process, process->rq, /* command_buffer */
+ process->rq_l, /* cmd buffer length */
+ process->rrq + SIZE_IN_HEADER); /* return buffer */
- //qemu_free(process->rq);
- g_free(process->rq);
- process->rq = NULL;
+ //qemu_free(process->rq);
+ g_free(process->rq);
+ process->rq = NULL;
#ifdef DEBUG_GLIO
- sum = 0;
- for(i = SIZE_IN_BUFFER; i < process->rrq_l ; i++)
- sum += process->rrq[i];
- *(int*)(process->rrq+sizeof(int)) = sum;
+ sum = 0;
+ for (i = SIZE_IN_BUFFER; i < process->rrq_l; i++)
+ sum += process->rrq[i];
+ *(int *)(process->rrq + sizeof(int)) = sum;
#endif
- }
- }
+ }
+ }
- if(hdr->rrq_l && process->rq == NULL) {
+ if (hdr->rrq_l && process->rq == NULL) {
- i = 0;
- remain = process->rrq_l - (process->rrq_p - process->rrq);
- while(remain && i < elem.in_num) {
- char *dst = elem.in_sg[i].iov_base;
- int len = remain;
- int ilen = elem.in_sg[i].iov_len;
+ i = 0;
+ remain = process->rrq_l - (process->rrq_p - process->rrq);
+ while (remain && i < elem.in_num) {
+ char *dst = elem.in_sg[i].iov_base;
+ int len = remain;
+ int ilen = elem.in_sg[i].iov_len;
- if(len > ilen)
- len = ilen;
+ if (len > ilen)
+ len = ilen;
- memcpy(dst, process->rrq_p, len);
- process->rrq_p += len;
- remain -= len;
- ret += len;
- i++;
- }
+ memcpy(dst, process->rrq_p, len);
+ process->rrq_p += len;
+ remain -= len;
+ ret += len;
+ i++;
+ }
- if(remain <= 0) {
- //qemu_free(process->rrq);
- g_free(process->rrq);
- if(!nkill)
- gl_disconnect(process);
- }
- }
+ if (remain <= 0) {
+ //qemu_free(process->rrq);
+ g_free(process->rrq);
+ if (!nkill)
+ gl_disconnect(process);
+ }
+ }
- virtqueue_push(vq, &elem, ret);
+ virtqueue_push(vq, &elem, ret);
- virtio_notify(vdev, vq);
- }
+ virtio_notify(vdev, vq);
+ }
}
-static uint32_t virtio_gl_get_features(VirtIODevice *vdev, uint32_t f)
+static uint32_t virtio_gl_get_features(VirtIODevice * vdev, uint32_t f)
{
- return 0;
+ return 0;
}
-static void virtio_gl_save(QEMUFile *f, void *opaque)
+static void virtio_gl_save(QEMUFile * f, void *opaque)
{
- VirtIOGL *s = opaque;
+ VirtIOGL *s = opaque;
- virtio_save(&s->vdev, f);
+ virtio_save(&s->vdev, f);
}
-static int virtio_gl_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_gl_load(QEMUFile * f, void *opaque, int version_id)
{
- VirtIOGL *s = opaque;
+ VirtIOGL *s = opaque;
- if (version_id != 1)
- return -EINVAL;
+ if (version_id != 1)
+ return -EINVAL;
- virtio_load(&s->vdev, f);
- return 0;
+ virtio_load(&s->vdev, f);
+ return 0;
}
-VirtIODevice *virtio_gl_init(DeviceState *dev)
+VirtIODevice *virtio_gl_init(DeviceState * dev)
{
- VirtIOGL *s;
+ VirtIOGL *s;
- s = (VirtIOGL *)virtio_common_init("virtio-gl", VIRTIO_ID_GL,
- 0, sizeof(VirtIOGL));
- if (!s)
- return NULL;
+ s = (VirtIOGL *) virtio_common_init("virtio-gl", VIRTIO_ID_GL,
+ 0, sizeof(VirtIOGL));
+ if (!s)
+ return NULL;
- s->vdev.get_features = virtio_gl_get_features;
- s->vq = virtio_add_queue(&s->vdev, 128, virtio_gl_handle);
- register_savevm(dev, "virtio-gl", -1, 1, virtio_gl_save, virtio_gl_load, s);
+ s->vdev.get_features = virtio_gl_get_features;
+ s->vq = virtio_add_queue(&s->vdev, 128, virtio_gl_handle);
+ register_savevm(dev, "virtio-gl", -1, 1, virtio_gl_save, virtio_gl_load, s);
- return &s->vdev;
+ return &s->vdev;
}
-
/*
* MARU display driver
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
#ifndef CONFIG_USE_SHM
/* sdl library */
dcl->dpy_update = qemu_ds_sdl_update;
- dcl->dpy_resize = qemu_ds_sdl_resize;
+ dcl->dpy_resize = qemu_ds_sdl_switch;
dcl->dpy_refresh = qemu_ds_sdl_refresh;
#else
/* shared memroy */
dcl->dpy_update = qemu_ds_shm_update;
- dcl->dpy_resize = qemu_ds_shm_resize;
+ dcl->dpy_resize = qemu_ds_shm_switch;
dcl->dpy_refresh = qemu_ds_shm_refresh;
#endif
#endif
}
-void maruskin_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
+void maruskin_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height)
{
#ifndef CONFIG_USE_SHM
- maruskin_sdl_init(swt_handle, lcd_size_width, lcd_size_height, is_resize);
+ maruskin_sdl_init(swt_handle, lcd_size_width, lcd_size_height);
#else
- maruskin_shm_init(swt_handle, lcd_size_width, lcd_size_height, is_resize);
+ maruskin_shm_init(swt_handle, lcd_size_width, lcd_size_height);
#endif
}
-DisplaySurface* get_qemu_display_surface(void) {
-#ifndef CONFIG_USE_SHM
- return maruskin_sdl_get_display();
-#else
- //TODO:
-#endif
-
- return NULL;
-}
-
-MaruScreenshot* get_maru_screenshot(void) {
+MaruScreenshot *get_maru_screenshot(void)
+{
return maru_screenshot;
}
-
+/* set_maru_screenshot() implemented in maruskin_operation.c */
/*
* MARU display driver
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
void maru_display_init(DisplayState *ds);
void maru_display_fini(void);
-void maruskin_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
-DisplaySurface* get_qemu_display_surface(void);
-MaruScreenshot* get_maru_screenshot(void);
+void maruskin_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height);
+
+MaruScreenshot *get_maru_screenshot(void);
+void set_maru_screenshot(DisplayState *surface);
#endif /* __MARU_DISPLAY_H__ */
#include <pixman.h>
#include "console.h"
#include "maru_sdl.h"
+#include "maru_display.h"
#include "emul_state.h"
-/*
-#include "SDL_gfx/SDL_rotozoom.h"
-#include "maru_sdl_rotozoom.h"
-*/
+#include "emulator.h"
#include "maru_finger.h"
#include "hw/maru_pm.h"
#include "hw/maru_brightness.h"
+#include "hw/maru_overlay.h"
#include "debug_ch.h"
-/* #include "SDL_opengl.h" */
-
-#ifdef MANGLE_OPENGL_SYMBOLS
-#include "gl_mangled.h"
-#endif
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
-
-DisplaySurface* qemu_display_surface = NULL;
+static QEMUBH *sdl_init_bh;
+static QEMUBH *sdl_resize_bh;
+static DisplayState *dpy_surface;
static SDL_Surface *surface_screen;
static SDL_Surface *surface_qemu;
static double current_scale_factor = 1.0;
static double current_screen_degree;
-static int current_screen_width;
-static int current_screen_height;
-static int sdl_initialized;
static int sdl_alteration;
-
-static int sdl_skip_update;
-
-#if 0
-static int sdl_opengl = 0; //0 : just SDL surface, 1 : using SDL with OpenGL
-GLuint texture;
-#endif
+static unsigned int sdl_skip_update;
+static unsigned int sdl_skip_count;
+static int blank_cnt;
+#define MAX_BLANK_FRAME_CNT 120
#define SDL_THREAD
static int sdl_thread_initialized;
#endif
-#define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME)
+#define SDL_FLAGS (SDL_SWSURFACE | SDL_ASYNCBLIT | SDL_NOFRAME)
#define SDL_BPP 32
/* Image processing functions using the pixman library */
static SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src,
- SDL_Surface *rz_dst,
- int angle)
+ SDL_Surface *rz_dst)
{
pixman_image_t *src = NULL;
pixman_image_t *dst = NULL;
break;
case 90:
pixman_f_transform_rotate(&matrix_f, NULL, 0.0, 1.0);
- pixman_f_transform_translate(&matrix_f, NULL, (double)rz_dst->h, 0.0);
+ pixman_f_transform_translate(&matrix_f, NULL,
+ (double)rz_dst->h, 0.0);
break;
case 180:
pixman_f_transform_rotate(&matrix_f, NULL, -1.0, 0.0);
break;
case 270:
pixman_f_transform_rotate(&matrix_f, NULL, 0.0, -1.0);
- pixman_f_transform_translate(&matrix_f, NULL, 0.0, (double)rz_dst->w);
+ pixman_f_transform_translate(&matrix_f, NULL,
+ 0.0, (double)rz_dst->w);
break;
default:
fprintf(stdout, "not supported angle factor (angle=%d)\n", angle);
return rz_dst;
}
-void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h)
+void qemu_ds_sdl_update(DisplayState *ds,
+ int x, int y, int w, int h)
{
/* call sdl update */
#ifdef SDL_THREAD
#endif
}
-void qemu_ds_sdl_resize(DisplayState *ds)
+void qemu_ds_sdl_switch(DisplayState *ds)
{
- int w, h;
+ int console_width = 0, console_height = 0;
- w = ds_get_width(ds);
- h = ds_get_height(ds);
+ dpy_surface = ds;
+ console_width = ds_get_width(ds);
+ console_height = ds_get_height(ds);
- INFO("qemu_ds_sdl_resize = (%d, %d)\n", w, h);
+ INFO("qemu_ds_sdl_switch : (%d, %d)\n",
+ console_width, console_height);
+
+ sdl_skip_update = 0;
+ sdl_skip_count = 0;
#ifdef SDL_THREAD
pthread_mutex_lock(&sdl_mutex);
}
/* create surface_qemu */
- if (w == get_emul_lcd_width() && h == get_emul_lcd_height()) {
- surface_qemu = SDL_CreateRGBSurfaceFrom(ds_get_data(ds), w, h,
+ if (console_width == get_emul_lcd_width() &&
+ console_height == get_emul_lcd_height()) {
+ INFO("create SDL screen : (%d, %d)\n",
+ console_width, console_height);
+
+ surface_qemu = SDL_CreateRGBSurfaceFrom(
+ ds_get_data(ds),
+ console_width, console_height,
ds_get_bits_per_pixel(ds),
ds_get_linesize(ds),
ds->surface->pf.rmask,
ds->surface->pf.bmask,
ds->surface->pf.amask);
} else {
- INFO("create blank screen = (%d, %d)\n", get_emul_lcd_width(), get_emul_lcd_height());
- surface_qemu = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
+ INFO("create blank screen : (%d, %d)\n",
+ get_emul_lcd_width(), get_emul_lcd_height());
+
+ surface_qemu = SDL_CreateRGBSurface(
+ SDL_SWSURFACE,
+ console_width, console_height,
ds_get_bits_per_pixel(ds), 0, 0, 0, 0);
}
ERR("Unable to set the RGBSurface: %s\n", SDL_GetError());
return;
}
-
}
-static int maru_sdl_poll_event(SDL_Event *ev)
-{
- int ret = 0;
-
- if (sdl_initialized == 1) {
- //pthread_mutex_lock(&sdl_mutex);
- ret = SDL_PollEvent(ev);
- //pthread_mutex_unlock(&sdl_mutex);
- }
-
- return ret;
-}
void qemu_ds_sdl_refresh(DisplayState *ds)
{
- SDL_Event ev1, *ev = &ev1;
- static uint32_t sdl_skip_count = 0;
-
- // surface may be NULL in init func.
- qemu_display_surface = ds->surface;
-
- while (maru_sdl_poll_event(ev)) {
- switch (ev->type) {
- case SDL_VIDEORESIZE:
- {
- pthread_mutex_lock(&sdl_mutex);
+ if (sdl_alteration == 1) {
+ sdl_alteration = 0;
+ sdl_skip_update = 0;
+ sdl_skip_count = 0;
+ }
- maruskin_sdl_init(0, get_emul_lcd_width(), get_emul_lcd_height(), true);
+ /* If the display is turned off,
+ the screen does not update until the display is turned on */
+ if (sdl_skip_update && brightness_off) {
+ if (blank_cnt > MAX_BLANK_FRAME_CNT) {
+ /* do nothing */
+ return;
+ } else if (blank_cnt == MAX_BLANK_FRAME_CNT) {
+ /* draw guide image */
+ // TODO:
+ } else if (blank_cnt == 0) {
+ INFO("skipping of the display updating is started\n");
+ }
- pthread_mutex_unlock(&sdl_mutex);
- vga_hw_invalidate();
- sdl_skip_update = 0;
- sdl_skip_count = 0;
- break;
- }
+ blank_cnt++;
- default:
- break;
+ return;
+ } else {
+ if (blank_cnt != 0) {
+ INFO("skipping of the display updating is ended\n");
+ blank_cnt = 0;
}
}
- /* If the LCD is turned off,
- the screen does not update until the LCD is turned on */
- if (sdl_skip_update && brightness_off) {
- return;
- }
+ vga_hw_update();
/* Usually, continuously updated.
- When the LCD is turned off,
+ When the display is turned off,
ten more updates the screen for a black screen. */
- vga_hw_update();
if (brightness_off) {
if (++sdl_skip_count > 10) {
sdl_skip_update = 1;
#endif
}
-//extern int capability_check_gl;
-static void _sdl_init(void)
-{
- int w, h, rwidth, rheight, temp;
-
- INFO("Set up a video mode with the specified width, height and bits-per-pixel\n");
-
- //get current setting information and calculate screen size
- rwidth = get_emul_lcd_width();
- rheight = get_emul_lcd_height();
- current_scale_factor = get_emul_win_scale();
- w = current_screen_width = rwidth * current_scale_factor;
- h = current_screen_height = rheight * current_scale_factor;
-
- short rotaton_type = get_emul_rotation();
- if (rotaton_type == ROTATION_PORTRAIT) {
- current_screen_degree = 0.0;
- } else if (rotaton_type == ROTATION_LANDSCAPE) {
- current_screen_degree = 90.0;
- temp = w;
- w = h;
- h = temp;
- temp = rwidth;
- rwidth = rheight;
- rheight = temp;
- } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
- current_screen_degree = 180.0;
- } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
- current_screen_degree = 270.0;
- temp = w;
- w = h;
- h = temp;
- temp = rwidth;
- rwidth = rheight;
- rheight = temp;
- }
-
-#if 0
- if (capability_check_gl != 0) {
- ERR("GL check returned non-zero\n");
- surface_screen = NULL;
- } else {
- surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_OPENGL);
- }
-
- if (surface_screen == NULL) {
- sdl_opengl = 0;
- INFO("No OpenGL support on this system!??\n");
- ERR("%s\n", SDL_GetError());
-#endif
-
- surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_FLAGS);
- if (surface_screen == NULL) {
- ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, get_emul_sdl_bpp(), SDL_GetError());
- return;
- }
-#if 0
- } else {
- sdl_opengl = 1;
- INFO("OpenGL is supported on this system.\n");
- }
-#endif
-
- /* create buffer for image processing */
- SDL_FreeSurface(scaled_screen);
- scaled_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
- w, h, get_emul_sdl_bpp(),
- surface_qemu->format->Rmask, surface_qemu->format->Gmask,
- surface_qemu->format->Bmask, surface_qemu->format->Amask);
- SDL_FreeSurface(rotated_screen);
- rotated_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
- rwidth, rheight, get_emul_sdl_bpp(),
- surface_qemu->format->Rmask, surface_qemu->format->Gmask,
- surface_qemu->format->Bmask, surface_qemu->format->Amask);
-
-#if 0
- if (sdl_opengl == 1) {
- /* Set the OpenGL state */
- glClear(GL_COLOR_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, w, h, 0, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glViewport(0, 0, w, h);
- glLoadIdentity();
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- //glGenerateMipmapEXT(GL_TEXTURE_2D); // GL_MIPMAP_LINEAR
- }
-#endif
-
- /* rearrange multi-touch finger points */
- if (get_emul_multi_touch_state()->multitouch_enable == 1 ||
- get_emul_multi_touch_state()->multitouch_enable == 2) {
- rearrange_finger_points(get_emul_lcd_width(), get_emul_lcd_height(),
- current_scale_factor, rotaton_type);
- }
-}
-
-#if 0
-static int point_degree = 0;
-static void draw_outline_circle(int cx, int cy, int r, int num_segments)
-{
- int ii;
- float theta = 2 * 3.1415926 / (num_segments);
- float c = cosf(theta);//precalculate the sine and cosine
- float s = sinf(theta);
- float t;
-
- float x = r;//we start at angle = 0
- float y = 0;
-
- glEnable(GL_LINE_STIPPLE);
- glLoadIdentity();
- glColor3f(0.9, 0.9, 0.9);
- glLineStipple(1, 0xcccc);
- glLineWidth(3.f);
-
- glTranslatef(cx, cy, 0);
- glRotated(point_degree++ % 360, 0, 0, 1);
-
- glBegin(GL_LINE_LOOP);
- for(ii = 0; ii < num_segments; ii++) {
- glVertex2f(x, y); //output vertex
-
- //apply the rotation matrix
- t = x;
- x = c * x - s * y;
- y = s * t + c * y;
- }
- glEnd();
-
- glDisable(GL_LINE_STIPPLE);
-}
-
-static void draw_fill_circle(int cx, int cy, int r)
-{
- glEnable(GL_POINT_SMOOTH);
- glLoadIdentity();
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(0.1, 0.1, 0.1, 0.6);
- glPointSize(r - 2);
-
- glBegin(GL_POINTS);
- glVertex2f(cx, cy);
- glEnd();
-
- glDisable(GL_POINT_SMOOTH);
- glDisable(GL_BLEND);
-}
-#endif
-
static void qemu_update(void)
{
- if (sdl_alteration == 1) {
- sdl_alteration = 0;
- _sdl_init();
- } else if (sdl_alteration == -1) {
+ if (sdl_alteration == -1) {
SDL_FreeSurface(scaled_screen);
SDL_FreeSurface(rotated_screen);
SDL_FreeSurface(surface_qemu);
surface_qemu = NULL;
- SDL_Quit();
return;
}
if (surface_qemu != NULL) {
- int i;
-
-#if 0
- if (sdl_opengl == 1)
- { //gl surface
- glEnable(GL_TEXTURE_2D);
- glLoadIdentity();
- glColor3f(1.0, 1.0, 1.0);
- glTexImage2D(GL_TEXTURE_2D,
- 0, 3, surface_qemu->w, surface_qemu->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, surface_qemu->pixels);
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- /* rotation */
- if (current_screen_degree == 270.0) { //reverse landscape
- glRotated(90, 0, 0, 1);
- glTranslatef(0, -current_screen_height, 0);
- } else if (current_screen_degree == 180.0) { //reverse portrait
- glRotated(180, 0, 0, 1);
- glTranslatef(-current_screen_width, -current_screen_height, 0);
- } else if (current_screen_degree == 90.0) { //landscape
- glRotated(270, 0, 0, 1);
- glTranslatef(-current_screen_width, 0, 0);
- }
+ int i = 0;
- glBegin(GL_QUADS);
- glTexCoord2i(0, 0);
- glVertex3f(0, 0, 0);
- glTexCoord2i(1, 0);
- glVertex3f(current_screen_width, 0, 0);
- glTexCoord2i(1, 1);
- glVertex3f(current_screen_width, current_screen_height, 0);
- glTexCoord2i(0, 1);
- glVertex3f(0, current_screen_height, 0);
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
-
- /* draw multi-touch finger points */
- MultiTouchState *mts = get_emul_multi_touch_state();
- if (mts->multitouch_enable != 0) {
- FingerPoint *finger = NULL;
- int finger_point_size_half = mts->finger_point_size / 2;
-
- for (i = 0; i < mts->finger_cnt; i++) {
- finger = get_finger_point_from_slot(i);
- if (finger != NULL && finger->id != 0) {
- draw_outline_circle(finger->origin_x, finger->origin_y, finger_point_size_half, 10); //TODO: optimize
- draw_fill_circle(finger->origin_x, finger->origin_y, mts->finger_point_size);
- }
- }
- } //end of draw multi-touch
+ set_maru_screenshot(dpy_surface);
- glFlush();
+ if (current_scale_factor != 1.0) {
+ rotated_screen = maru_do_pixman_rotate(
+ surface_qemu, rotated_screen,
+ (int)current_screen_degree);
+ scaled_screen = maru_do_pixman_scale(
+ rotated_screen, scaled_screen);
- SDL_GL_SwapBuffers();
+ SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL);
}
- else
- { //sdl surface
-#endif
- if (current_scale_factor != 1.0)
- {
+ else {/* current_scale_factor == 1.0 */
+ if (current_screen_degree != 0.0) {
rotated_screen = maru_do_pixman_rotate(
surface_qemu, rotated_screen,
(int)current_screen_degree);
- scaled_screen = maru_do_pixman_scale(
- rotated_screen, scaled_screen,
- (int)current_screen_degree);
- SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL);
- }
- else /* current_scale_factor == 1.0 */
- {
- if (current_screen_degree != 0.0) {
- rotated_screen = maru_do_pixman_rotate(
- surface_qemu, rotated_screen,
- (int)current_screen_degree);
- SDL_BlitSurface(rotated_screen, NULL, surface_screen, NULL);
- } else {
- /* as-is */
- SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL);
- }
+
+ SDL_BlitSurface(rotated_screen, NULL, surface_screen, NULL);
+ } else {
+ /* as-is */
+ SDL_BlitSurface(surface_qemu, NULL, surface_screen, NULL);
}
+ }
- /* draw multi-touch finger points */
- MultiTouchState *mts = get_emul_multi_touch_state();
- if (mts->multitouch_enable != 0 && mts->finger_point_surface != NULL) {
- FingerPoint *finger = NULL;
- int finger_point_size_half = mts->finger_point_size / 2;
- SDL_Rect rect;
-
- for (i = 0; i < mts->finger_cnt; i++) {
- finger = get_finger_point_from_slot(i);
- if (finger != NULL && finger->id != 0) {
- rect.x = finger->origin_x - finger_point_size_half;
- rect.y = finger->origin_y - finger_point_size_half;
- rect.w = rect.h = mts->finger_point_size;
-
- SDL_BlitSurface((SDL_Surface *)mts->finger_point_surface, NULL, surface_screen, &rect);
- }
+ /* draw multi-touch finger points */
+ MultiTouchState *mts = get_emul_multi_touch_state();
+ if (mts->multitouch_enable != 0 && mts->finger_point_surface != NULL) {
+ FingerPoint *finger = NULL;
+ int finger_point_size_half = mts->finger_point_size / 2;
+ SDL_Rect rect;
+
+ for (i = 0; i < mts->finger_cnt; i++) {
+ finger = get_finger_point_from_slot(i);
+ if (finger != NULL && finger->id != 0) {
+ rect.x = finger->origin_x - finger_point_size_half;
+ rect.y = finger->origin_y - finger_point_size_half;
+ rect.w = rect.h = mts->finger_point_size;
+
+ SDL_BlitSurface(
+ (SDL_Surface *)mts->finger_point_surface,
+ NULL, surface_screen, &rect);
}
- } /* end of draw multi-touch */
- }
+ }
+ } /* end of draw multi-touch */
+ }
SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
}
#ifdef SDL_THREAD
-static void* run_qemu_update(void* arg)
+static void *run_qemu_update(void *arg)
{
- while(1) {
+ while(1) {
pthread_mutex_lock(&sdl_mutex);
- pthread_cond_wait(&sdl_cond, &sdl_mutex);
+ pthread_cond_wait(&sdl_cond, &sdl_mutex);
qemu_update();
pthread_mutex_unlock(&sdl_mutex);
- }
+ }
return NULL;
}
#endif
-void maruskin_sdl_init(uint64 swt_handle,
- int lcd_size_width, int lcd_size_height, bool is_resize)
+static void maru_sdl_resize_bh(void *opaque)
{
- gchar SDL_windowhack[32];
- SDL_SysWMinfo info;
- long window_id = swt_handle;
+ int surface_width = 0, surface_height = 0;
+ int display_width = 0, display_height = 0;
+ int temp = 0;
- INFO("maru sdl initialization = %d\n", is_resize);
+ INFO("Set up a video mode with the specified width, "
+ "height and bits-per-pixel\n");
- if (is_resize == FALSE) { //once
- sprintf(SDL_windowhack, "%ld", window_id);
- g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
- INFO("register SDL environment variable. (SDL_WINDOWID = %s)\n", SDL_windowhack);
+#ifdef SDL_THREAD
+ pthread_mutex_lock(&sdl_mutex);
+#endif
- if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
- ERR("unable to init SDL: %s\n", SDL_GetError());
- }
+ sdl_alteration = 1;
+ sdl_skip_update = 0;
- set_emul_lcd_size(lcd_size_width, lcd_size_height);
- set_emul_sdl_bpp(SDL_BPP);
+ /* get current setting information and calculate screen size */
+ display_width = get_emul_lcd_width();
+ display_height = get_emul_lcd_height();
+ current_scale_factor = get_emul_win_scale();
+
+ short rotaton_type = get_emul_rotation();
+ if (rotaton_type == ROTATION_PORTRAIT) {
+ current_screen_degree = 0.0;
+ } else if (rotaton_type == ROTATION_LANDSCAPE) {
+ current_screen_degree = 90.0;
+ temp = display_width;
+ display_width = display_height;
+ display_height = temp;
+ } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
+ current_screen_degree = 180.0;
+ } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
+ current_screen_degree = 270.0;
+ temp = display_width;
+ display_width = display_height;
+ display_height = temp;
}
- if (sdl_initialized == 0) {
- sdl_initialized = 1;
+ surface_width = display_width * current_scale_factor;
+ surface_height = display_height * current_scale_factor;
- //SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- init_multi_touch_state();
+ surface_screen = SDL_SetVideoMode(
+ surface_width, surface_height,
+ get_emul_sdl_bpp(), SDL_FLAGS);
-#ifndef _WIN32
- SDL_VERSION(&info.version);
- SDL_GetWMInfo(&info);
+ INFO("SDL_SetVideoMode\n");
+
+ if (surface_screen == NULL) {
+ ERR("Could not open SDL display (%dx%dx%d) : %s\n",
+ surface_width, surface_height,
+ get_emul_sdl_bpp(), SDL_GetError());
+ return;
+ }
+
+ /* create buffer for image processing */
+ SDL_FreeSurface(scaled_screen);
+ scaled_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ surface_width, surface_height,
+ get_emul_sdl_bpp(),
+ surface_qemu->format->Rmask,
+ surface_qemu->format->Gmask,
+ surface_qemu->format->Bmask,
+ surface_qemu->format->Amask);
+
+ SDL_FreeSurface(rotated_screen);
+ rotated_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ display_width, display_height,
+ get_emul_sdl_bpp(),
+ surface_qemu->format->Rmask,
+ surface_qemu->format->Gmask,
+ surface_qemu->format->Bmask,
+ surface_qemu->format->Amask);
+
+ /* rearrange multi-touch finger points */
+ if (get_emul_multi_touch_state()->multitouch_enable == 1 ||
+ get_emul_multi_touch_state()->multitouch_enable == 2) {
+ rearrange_finger_points(get_emul_lcd_width(), get_emul_lcd_height(),
+ current_scale_factor, rotaton_type);
+ }
+
+#ifdef SDL_THREAD
+ pthread_mutex_unlock(&sdl_mutex);
#endif
+}
+
+static void maru_sdl_init_bh(void *opaque)
+{
+ SDL_SysWMinfo info;
+
+ INFO("SDL_Init\n");
+
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ ERR("unable to init SDL: %s\n", SDL_GetError());
+ //TODO:
}
- sdl_alteration = 1;
+#ifndef _WIN32
+ SDL_VERSION(&info.version);
+ SDL_GetWMInfo(&info);
+#endif
+
+ qemu_bh_schedule(sdl_resize_bh);
#ifdef SDL_THREAD
if (sdl_thread_initialized == 0) {
sdl_thread_initialized = 1;
- pthread_t thread_id;
+
INFO("sdl update thread create\n");
- if (pthread_create(&thread_id, NULL, run_qemu_update, NULL) != 0) {
+
+ pthread_t thread_id;
+ if (pthread_create(
+ &thread_id, NULL, run_qemu_update, NULL) != 0) {
ERR("pthread_create fail\n");
return;
}
#endif
}
+void maruskin_sdl_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height)
+{
+ gchar SDL_windowhack[32] = { 0, };
+ long window_id = swt_handle;
+
+ INFO("maru sdl init\n");
+
+ sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL);
+ sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL);
+
+ sprintf(SDL_windowhack, "%ld", window_id);
+ g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
+
+ INFO("register SDL environment variable. "
+ "(SDL_WINDOWID = %s)\n", SDL_windowhack);
+
+ set_emul_lcd_size(lcd_size_width, lcd_size_height);
+ set_emul_sdl_bpp(SDL_BPP);
+ init_multi_touch_state();
+
+ qemu_bh_schedule(sdl_init_bh);
+}
+
void maruskin_sdl_quit(void)
{
+ INFO("maru sdl quit\n");
+
/* remove multi-touch finger points */
- get_emul_multi_touch_state()->multitouch_enable = 0;
- clear_finger_slot();
cleanup_multi_touch_state();
-#if 0
- if (sdl_opengl == 1) {
- glDeleteTextures(1, &texture);
+ if (sdl_init_bh != NULL) {
+ qemu_bh_delete(sdl_init_bh);
}
+ if (sdl_resize_bh != NULL) {
+ qemu_bh_delete(sdl_resize_bh);
+ }
+
+#ifdef SDL_THREAD
+ pthread_mutex_lock(&sdl_mutex);
#endif
sdl_alteration = -1;
SDL_Quit();
#ifdef SDL_THREAD
+ pthread_mutex_unlock(&sdl_mutex);
pthread_cond_destroy(&sdl_cond);
#endif
+
pthread_mutex_destroy(&sdl_mutex);
}
-
void maruskin_sdl_resize(void)
{
- SDL_Event ev;
-
- /* this fails if SDL is not initialized */
- memset(&ev, 0, sizeof(ev));
- ev.resize.type = SDL_VIDEORESIZE;
+ INFO("maru sdl resize\n");
- /* This function is thread safe,
- and can be called from other threads safely. */
- SDL_PushEvent(&ev);
+ qemu_bh_schedule(sdl_resize_bh);
}
-
-DisplaySurface* maruskin_sdl_get_display(void) {
- return qemu_display_surface;
-}
-
/*
* SDL_WINDOWID hack
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jinhyung Jo <jinhyung.jo@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
* SeokYeon Hwang <syeon.hwang@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
#include <SDL_syswm.h>
#include "qemu-common.h"
-
void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h);
-void qemu_ds_sdl_resize(DisplayState *ds);
+void qemu_ds_sdl_switch(DisplayState *ds);
void qemu_ds_sdl_refresh(DisplayState *ds);
-void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
+void maruskin_sdl_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height);
void maruskin_sdl_resize(void);
void maruskin_sdl_quit(void);
-DisplaySurface* maruskin_sdl_get_display(void);
-
#endif /* MARU_SDL_H_ */
//TODO:
}
-void qemu_ds_shm_resize(DisplayState *ds)
+void qemu_ds_shm_switch(DisplayState *ds)
{
//TODO:
}
vga_hw_update();
}
-void maruskin_shm_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
+void maruskin_shm_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height)
{
- INFO("maru shm initialization = %d\n", is_resize);
+ INFO("maru shm initialization\n");
- if (is_resize == FALSE) { //once
- set_emul_lcd_size(lcd_size_width, lcd_size_height);
- set_emul_sdl_bpp(32);
- }
+ set_emul_lcd_size(lcd_size_width, lcd_size_height);
+ set_emul_sdl_bpp(32);
}
void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h);
-void qemu_ds_shm_resize(DisplayState *ds);
+void qemu_ds_shm_switch(DisplayState *ds);
void qemu_ds_shm_refresh(DisplayState *ds);
-void maruskin_shm_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
+void maruskin_shm_init(uint64 swt_handle,
+ int lcd_size_width, int lcd_size_height);
#endif /* MARU_SHM_H_ */
#ifdef TARGET_I386
static void mloop_evhandle_kbd_add(char *name)
{
- TRACE("mloop_evhandle_kbd_add\n");
+ TRACE("try to add a keyboard device.\n");
if (name == NULL) {
ERR("packet data is NULL.\n");
static void mloop_evhandle_kbd_del(char *name)
{
- TRACE("mloop_evhandle_kbd_del\n");
+ TRACE("try to remove a keyboard device.\n");
if (name == NULL) {
ERR("packet data is NULL.\n");
{
char opts[PATH_MAX];
- INFO("mloop_evhandle_sdcard_attach\n");
+ INFO("try to attach sdcard.\n");
if (name == NULL) {
ERR("Packet data is NULL.\n");
qdict_put(qdict, "opts", qstring_from_str(opts));
virtio_sdcard = pci_device_hot_add(cur_mon, qdict);
-
- INFO("hot add virtio storage device with [%s]\n", opts);
- INFO("virtio-sdcard device: domain %d, bus %d, slot %d, function %d\n",
+ if (virtio_sdcard) {
+ INFO("hot add virtio storage device with [%s]\n", opts);
+ INFO("virtio-sdcard device: domain %d, bus %d, slot %d, function %d\n",
pci_find_domain(virtio_sdcard->bus), pci_bus_num(virtio_sdcard->bus),
PCI_SLOT(virtio_sdcard->devfn), PCI_FUNC(virtio_sdcard->devfn));
+ } else {
+ ERR("failed to create a device for sdcard.\n");
+ }
QDECREF(qdict);
}
static void mloop_evhandle_sdcard_detach(char *name)
{
- INFO("mloop_evhandle_sdcard_detach\n");
+ INFO("try to detach sdcard.\n");
if (name == NULL) {
ERR("packet data is NULL.\n");
if (img) {
if (strlen(img) > PACKET_LEN-5) {
- // Need log
ERR("The length of disk image path is greater than "
"lenth of maximum packet.\n");
return;
if (img) {
if (strlen(img) > PACKET_LEN-5) {
- // Need log
ERR("The length of disk image path is greater than "
"lenth of maximum packet.\n");
return;
pack.size = 5;
mloop_evsock_send(&mloop, &pack);
}
-
#include <sys/shm.h>
#include <sys/sysctl.h>
#include <SystemConfiguration/SystemConfiguration.h>
+#include <CoreServices/CoreServices.h>
MULTI_DEBUG_CHANNEL(qemu, osutil);
+int g_shmid;
extern char tizen_target_img_path[];
extern int tizen_base_port;
CFDictionaryRef proxySettings;
void make_vm_lock_os(void)
{
- int shmid;
char *shared_memory;
- shmid = shmget((key_t)tizen_base_port, MAXLEN, 0666|IPC_CREAT);
- if (shmid == -1) {
+ g_shmid = shmget((key_t)tizen_base_port, MAXLEN, 0666|IPC_CREAT);
+ if (g_shmid == -1) {
ERR("shmget failed\n");
perror("osutil-darwin: ");
return;
}
- shared_memory = shmat(shmid, (char *)0x00, 0);
+ shared_memory = shmat(g_shmid, (char *)0x00, 0);
if (shared_memory == (void *)-1) {
ERR("shmat failed\n");
perror("osutil-darwin: ");
return;
}
- sprintf(shared_memory, "%s", tizen_target_img_path);
+ g_sprintf(shared_memory, "%s", tizen_target_img_path);
INFO("shared memory key: %d, value: %s\n", tizen_base_port, (char *)shared_memory);
if (shmdt(shared_memory) == -1) {
free(data);
}
+int get_number_of_processors(void)
+{
+ int mib[2], sys_num = 0;
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_AVAILCPU;
+
+ sysctl(mib, 2, &sys_num, &len, NULL, 0);
+ if (sys_num < 1) {
+ mib[1] = HW_NCPU;
+ sysctl(mib, 2, &sys_num, &len, NULL, 0);
+
+ if (sys_num < 1) {
+ sys_num = 1;
+ }
+ }
+ INFO("* Number of processors : %d\n", sys_num);
+
+ return sys_num;
+}
+
+static void get_host_os_version(void)
+{
+ int major_version, minor_version, bugfix_version;
+
+ Gestalt(gestaltSystemVersionMajor, &major_version);
+ Gestalt(gestaltSystemVersionMinor, &minor_version);
+ Gestalt(gestaltSystemVersionBugFix, &bugfix_version);
+
+ INFO("* Mac OS X Version: %d.%d.%d\n", major_version, minor_version, bugfix_version);
+}
void print_system_info_os(void)
{
- INFO("* Mac\n");
+ INFO("* Mac\n");
/* uname */
INFO("* Host machine uname :\n");
}
free(sys_info);
+#if 0
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
len = sizeof(sys_num);
if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
INFO("* Number of processors : %d\n", sys_num);
}
+#endif
+ get_number_of_processors();
mib[0] = CTL_HW;
mib[1] = HW_PHYSMEM;
if (sysctl(mib, 2, &sys_num, &len, NULL, 0) >= 0) {
INFO("* Total memory : %llu bytes\n", sys_num);
}
+
+ get_host_os_version();
}
static int get_auto_proxy(char *http_proxy, char *https_proxy, char *ftp_proxy, char *socks_proxy)
}
else {
ERR("fail to get pacfile fp\n");
- return -1;
+ return -1;
}
remove(pac_tempfile);
ret = get_auto_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
if(strlen(http_proxy) == 0 && ret < 0) {
INFO("MANUAL PROXY MODE\n");
- get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
- }
+ get_proxy(http_proxy, https_proxy, ftp_proxy, socks_proxy);
+ }
}
}
-/*
+/*
* Emulator
*
* Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
* MunKyu Im <munkyu.im@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
/* Getting proxy commands */
static const char* gproxycmds[][2] = {
- { "gconftool-2 -g /system/proxy/mode" , "gsettings get org.gnome.system.proxy mode" },
- { "gconftool-2 -g /system/proxy/autoconfig_url", "gsettings get org.gnome.system.proxy autoconfig-url" },
- { "gconftool-2 -g /system/http_proxy/host", "gsettings get org.gnome.system.proxy.http host" },
- { "gconftool-2 -g /system/http_proxy/port", "gsettings get org.gnome.system.proxy.http port"},
- { "gconftool-2 -g /system/proxy/secure_host", "gsettings get org.gnome.system.proxy.https host" },
- { "gconftool-2 -g /system/proxy/secure_port", "gsettings get org.gnome.system.proxy.https port" },
- { "gconftool-2 -g /system/proxy/ftp_host", "gsettings get org.gnome.system.proxy.ftp host" },
- { "gconftool-2 -g /system/proxy/ftp_port", "gsettings get org.gnome.system.proxy.ftp port" },
- { "gconftool-2 -g /system/proxy/socks_host", "gsettings get org.gnome.system.proxy.socks host" },
- { "gconftool-2 -g /system/proxy/socks_port", "gsettings get org.gnome.system.proxy.socks port" },
+ { "gconftool-2 -g /system/proxy/mode" , "gsettings get org.gnome.system.proxy mode" },
+ { "gconftool-2 -g /system/proxy/autoconfig_url", "gsettings get org.gnome.system.proxy autoconfig-url" },
+ { "gconftool-2 -g /system/http_proxy/host", "gsettings get org.gnome.system.proxy.http host" },
+ { "gconftool-2 -g /system/http_proxy/port", "gsettings get org.gnome.system.proxy.http port"},
+ { "gconftool-2 -g /system/proxy/secure_host", "gsettings get org.gnome.system.proxy.https host" },
+ { "gconftool-2 -g /system/proxy/secure_port", "gsettings get org.gnome.system.proxy.https port" },
+ { "gconftool-2 -g /system/proxy/ftp_host", "gsettings get org.gnome.system.proxy.ftp host" },
+ { "gconftool-2 -g /system/proxy/ftp_port", "gsettings get org.gnome.system.proxy.ftp port" },
+ { "gconftool-2 -g /system/proxy/socks_host", "gsettings get org.gnome.system.proxy.socks host" },
+ { "gconftool-2 -g /system/proxy/socks_port", "gsettings get org.gnome.system.proxy.socks port" },
};
void check_vm_lock_os(void)
g_strlcat(bin_path, "/", PATH_MAX);
}
+int get_number_of_processors(void)
+{
+ int num_processors = 0;
+
+ num_processors = sysconf(_SC_NPROCESSORS_ONLN);
+ if (num_processors < 1) {
+ num_processors = 1;
+ }
+ TRACE("Number of processors : %d\n", num_processors);
+
+ return num_processors;
+}
+
void print_system_info_os(void)
{
INFO("* Linux\n");
/* depends on building */
INFO("* QEMU build machine linux kernel version : (%d, %d, %d)\n",
- LINUX_VERSION_CODE >> 16,
- (LINUX_VERSION_CODE >> 8) & 0xff,
- LINUX_VERSION_CODE & 0xff);
+ LINUX_VERSION_CODE >> 16,
+ (LINUX_VERSION_CODE >> 8) & 0xff,
+ LINUX_VERSION_CODE & 0xff);
/* depends on launching */
struct utsname host_uname_buf;
-/*
+/*
* Emulator
*
* Copyright (C) 2012, 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
* MunKyu Im <munkyu.im@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
g_strlcat(bin_path, "\\", PATH_MAX);
}
+int get_number_of_processors(void)
+{
+ SYSTEM_INFO sysi;
+ int num_processors = 0;
+
+ GetSystemInfo(&sysi);
+ TRACE("Processor type: %d, Core number: %d\n",
+ sysi.dwProcessorType, sysi.dwNumberOfProcessors);
+
+ num_processors = sysi.dwNumberOfProcessors;
+ if (num_processors < 1) {
+ num_processors = 1;
+ }
+
+ return num_processors;
+}
+
void print_system_info_os(void)
{
INFO("* Windows\n");
SYSTEM_INFO sysi;
ZeroMemory(&sysi, sizeof(SYSTEM_INFO));
+#if 0
GetSystemInfo(&sysi);
INFO("* Processor type : %d, Number of processors : %d\n",
sysi.dwProcessorType, sysi.dwNumberOfProcessors);
+#endif
+ get_number_of_processors();
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
ERR("pac file is not wrong! It could be the wrong pac address or pac file format\n");
fclose(fp_pacfile);
}
- }
+ }
else {
ERR("fail to get pacfile fp\n");
return -1;
lRet = RegQueryValueEx(hKey, "AutoConfigURL", 0, NULL, url, &dwLength);
if (lRet == ERROR_SUCCESS && dwLength != 0) {
get_auto_proxy(url, http_proxy, https_proxy, ftp_proxy, socks_proxy);
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
return 0;
}
}
}
if (*(char*)proxyenable == 0) {
free(proxyenable);
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
return 0;
}
if (lRet != ERROR_SUCCESS && dwLength == 0) {
ERR("Failed to query value from from %s\n",
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
return 0;
}
proxyserver = (BYTE*)malloc(dwLength);
if (proxyserver == NULL) {
ERR( "Failed to allocate a buffer\n");
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
return 0;
}
RegCloseKey(hKey);
return 0;
}
-
+
if((char*)proxyserver != NULL) {
INFO("proxy value: %s\n", (char*)proxyserver);
real_proxy = malloc(MAXLEN);
-
+
for(p = strtok((char*)proxyserver, ";"); p; p = strtok(NULL, ";")){
if(strstr(p, HTTP_PROTOCOL)) {
remove_string(p, real_proxy, HTTP_PROTOCOL);
inline size_t write_data(void *, size_t, size_t, FILE *);
inline void remove_string(char *, char *, const char *);
+int get_number_of_processors(void);
+
#endif // __OS_UTIL_H__
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>EmulatorSkin</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <dbi version="2.0"/>
+ <rotations>
+ <rotation name="Portrait">
+ <lcd id="0">
+ <region left="26" top="70" width="320" height="480"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_0.png</mainImage>
+ <keyPressedImage>default_0_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="159" top="552" width="54" height="54"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="362" top="487" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="362" top="63" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="362" top="140" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Landscape">
+ <lcd id="0">
+ <region left="70" top="34" width="480" height="320"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_L90.png</mainImage>
+ <keyPressedImage>default_L90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="552" top="167" width="54" height="54"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="486" top="3" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="63" top="3" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="139" top="3" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Portrait">
+ <lcd id="0">
+ <region left="34" top="70" width="320" height="480"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_180.png</mainImage>
+ <keyPressedImage>default_180_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="167" top="14" width="54" height="54"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="3" top="64" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="3" top="488" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="3" top="412" width="15" height="70"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Landscape">
+ <lcd id="0">
+ <region left="70" top="26" width="480" height="320"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_R90.png</mainImage>
+ <keyPressedImage>default_R90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="14" top="159" width="54" height="54"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="64" top="362" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="488" top="362" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="412" top="362" width="70" height="15"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ </rotations>
+ <colors>
+ <hoverColor B="255" G="255" R="255" />
+ </colors>
+</EmulatorUI>
--- /dev/null
+skin.name=Phone 1btn 320x480
+resolution.width=320
+resolution.height=480
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <dbi version="2.0"/>
- <rotations>
- <rotation name="Portrait">
- <lcd id="0">
- <region left="26" top="70" width="320" height="480"/>
- </lcd>
- <imageList>
- <mainImage>default_0.png</mainImage>
- <keyPressedImage>default_0_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="159" top="552" width="54" height="54"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="362" top="487" width="15" height="70"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="362" top="63" width="15" height="70"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="362" top="140" width="15" height="70"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Landscape">
- <lcd id="0">
- <region left="70" top="34" width="480" height="320"/>
- </lcd>
- <imageList>
- <mainImage>default_L90.png</mainImage>
- <keyPressedImage>default_L90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="552" top="167" width="54" height="54"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="486" top="3" width="70" height="15"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="63" top="3" width="70" height="15"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="139" top="3" width="70" height="15"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Portrait">
- <lcd id="0">
- <region left="34" top="70" width="320" height="480"/>
- </lcd>
- <imageList>
- <mainImage>default_180.png</mainImage>
- <keyPressedImage>default_180_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="167" top="14" width="54" height="54"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="3" top="64" width="15" height="70"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="3" top="488" width="15" height="70"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="3" top="412" width="15" height="70"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Landscape">
- <lcd id="0">
- <region left="70" top="26" width="480" height="320"/>
- </lcd>
- <imageList>
- <mainImage>default_R90.png</mainImage>
- <keyPressedImage>default_R90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="14" top="159" width="54" height="54"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="64" top="362" width="70" height="15"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="488" top="362" width="70" height="15"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="412" top="362" width="70" height="15"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- </rotations>
- <colors>
- <hoverColor B="255" G="255" R="255" />
- </colors>
-</EmulatorUI>
+++ /dev/null
-skin.name=Phone 1btn 320x480
-resolution.width=320
-resolution.height=480
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <dbi version="2.0"/>
+ <rotations>
+ <rotation name="Portrait">
+ <lcd id="0">
+ <region left="35" top="86" width="480" height="800"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_0.png</mainImage>
+ <keyPressedImage>default_0_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="238" top="887" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="541" top="819" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="541" top="81" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="541" top="167" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Landscape">
+ <lcd id="0">
+ <region left="86" top="46" width="800" height="480"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_L90.png</mainImage>
+ <keyPressedImage>default_L90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="887" top="249" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="818" top="2" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="80" top="2" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="165" top="2" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Portrait">
+ <lcd id="0">
+ <region left="46" top="89" width="480" height="800"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_180.png</mainImage>
+ <keyPressedImage>default_180_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="249" top="14" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="84" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="821" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="735" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Landscape">
+ <lcd id="0">
+ <region left="90" top="35" width="800" height="480"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_R90.png</mainImage>
+ <keyPressedImage>default_R90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="15" top="239" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="84" top="539" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="822" top="539" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="735" top="539" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ </rotations>
+ <colors>
+ <hoverColor B="255" G="255" R="255" />
+ </colors>
+</EmulatorUI>
--- /dev/null
+skin.name=Phone 1btn 480x800
+resolution.width=480
+resolution.height=800
+manager.priority=2
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <dbi version="2.0"/>
- <rotations>
- <rotation name="Portrait">
- <lcd id="0">
- <region left="35" top="86" width="480" height="800"/>
- </lcd>
- <imageList>
- <mainImage>default_0.png</mainImage>
- <keyPressedImage>default_0_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="238" top="887" width="74" height="74"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="541" top="819" width="20" height="74"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="541" top="81" width="20" height="74"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="541" top="167" width="20" height="74"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Landscape">
- <lcd id="0">
- <region left="86" top="46" width="800" height="480"/>
- </lcd>
- <imageList>
- <mainImage>default_L90.png</mainImage>
- <keyPressedImage>default_L90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="887" top="249" width="74" height="74"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="818" top="2" width="74" height="20"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="80" top="2" width="74" height="20"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="165" top="2" width="74" height="20"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Portrait">
- <lcd id="0">
- <region left="46" top="89" width="480" height="800"/>
- </lcd>
- <imageList>
- <mainImage>default_180.png</mainImage>
- <keyPressedImage>default_180_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="249" top="14" width="74" height="74"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="84" width="20" height="74"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="821" width="20" height="74"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="735" width="20" height="74"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Landscape">
- <lcd id="0">
- <region left="90" top="35" width="800" height="480"/>
- </lcd>
- <imageList>
- <mainImage>default_R90.png</mainImage>
- <keyPressedImage>default_R90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="15" top="239" width="74" height="74"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="84" top="539" width="74" height="20"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="822" top="539" width="74" height="20"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="735" top="539" width="74" height="20"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- </rotations>
- <colors>
- <hoverColor B="255" G="255" R="255" />
- </colors>
-</EmulatorUI>
+++ /dev/null
-skin.name=Phone 1btn 480x800
-resolution.width=480
-resolution.height=800
-manager.priority=2
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <dbi version="2.0"/>
+ <rotations>
+ <rotation name="Portrait">
+ <lcd id="0">
+ <region left="35" top="86" width="540" height="960"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_0.png</mainImage>
+ <keyPressedImage>default_0_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="129" top="1049" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>169</keyCode>
+ <keyName>Menu</keyName>
+ </eventInfo>
+ <tooltip>Menu</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="270" top="1049" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="411" top="1049" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>158</keyCode>
+ <keyName>Back</keyName>
+ </eventInfo>
+ <tooltip>Back</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="600" top="979" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="600" top="80" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="600" top="167" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Landscape">
+ <lcd id="0">
+ <region left="86" top="46" width="960" height="540"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_L90.png</mainImage>
+ <keyPressedImage>default_L90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="1049" top="419" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>169</keyCode>
+ <keyName>Menu</keyName>
+ </eventInfo>
+ <tooltip>Menu</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1049" top="279" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1049" top="139" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>158</keyCode>
+ <keyName>Back</keyName>
+ </eventInfo>
+ <tooltip>Back</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="978" top="1" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="80" top="1" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="166" top="1" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Portrait">
+ <lcd id="0">
+ <region left="46" top="89" width="540" height="960"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_180.png</mainImage>
+ <keyPressedImage>default_180_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="420" top="14" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>169</keyCode>
+ <keyName>Menu</keyName>
+ </eventInfo>
+ <tooltip>Menu</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="278" top="14" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="137" top="14" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>158</keyCode>
+ <keyName>Back</keyName>
+ </eventInfo>
+ <tooltip>Back</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="84" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="981" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="895" width="20" height="74"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Landscape">
+ <lcd id="0">
+ <region left="89" top="35" width="960" height="540"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_R90.png</mainImage>
+ <keyPressedImage>default_R90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="14" top="128" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>169</keyCode>
+ <keyName>Menu</keyName>
+ </eventInfo>
+ <tooltip>Menu</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="14" top="270" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="14" top="413" width="74" height="74"/>
+ <eventInfo>
+ <keyCode>158</keyCode>
+ <keyName>Back</keyName>
+ </eventInfo>
+ <tooltip>Back</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="84" top="600" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="980" top="600" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="894" top="600" width="74" height="20"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ </rotations>
+ <colors>
+ <hoverColor B="255" G="255" R="255" />
+ </colors>
+</EmulatorUI>
--- /dev/null
+skin.name=Phone 540x960
+resolution.width=540
+resolution.height=960
+manager.priority=4
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <dbi version="2.0"/>
+ <rotations>
+ <rotation name="Portrait">
+ <lcd id="0">
+ <region left="52" top="109" width="600" height="1024"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_0.png</mainImage>
+ <keyPressedImage>default_0_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="310" top="1139" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="690" top="1055" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="690" top="101" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="690" top="194" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Landscape">
+ <lcd id="0">
+ <region left="109" top="62" width="1024" height="600"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_L90.png</mainImage>
+ <keyPressedImage>default_L90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="1138" top="321" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1054" top="1" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="99" top="1" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="194" top="1" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Portrait">
+ <lcd id="0">
+ <region left="62" top="113" width="600" height="1024"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_180.png</mainImage>
+ <keyPressedImage>default_180_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="320" top="24" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="106" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="1059" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1" top="964" width="24" height="88"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Landscape">
+ <lcd id="0">
+ <region left="113" top="52" width="1024" height="600"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_R90.png</mainImage>
+ <keyPressedImage>default_R90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="23" top="310" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="105" top="690" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1058" top="690" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="965" top="690" width="88" height="24"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ </rotations>
+ <colors>
+ <hoverColor B="255" G="255" R="255" />
+ </colors>
+</EmulatorUI>
--- /dev/null
+skin.name=Phone 1btn 600x1024
+resolution.width=600
+resolution.height=1024
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <dbi version="2.0"/>
- <rotations>
- <rotation name="Portrait">
- <lcd id="0">
- <region left="52" top="109" width="600" height="1024"/>
- </lcd>
- <imageList>
- <mainImage>default_0.png</mainImage>
- <keyPressedImage>default_0_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="310" top="1139" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="690" top="1055" width="24" height="88"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="690" top="101" width="24" height="88"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="690" top="194" width="24" height="88"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Landscape">
- <lcd id="0">
- <region left="109" top="62" width="1024" height="600"/>
- </lcd>
- <imageList>
- <mainImage>default_L90.png</mainImage>
- <keyPressedImage>default_L90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="1138" top="321" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="1054" top="1" width="88" height="24"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="99" top="1" width="88" height="24"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="194" top="1" width="88" height="24"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Portrait">
- <lcd id="0">
- <region left="62" top="113" width="600" height="1024"/>
- </lcd>
- <imageList>
- <mainImage>default_180.png</mainImage>
- <keyPressedImage>default_180_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="320" top="24" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="1" top="106" width="24" height="88"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="1" top="1059" width="24" height="88"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="1" top="964" width="24" height="88"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Landscape">
- <lcd id="0">
- <region left="113" top="52" width="1024" height="600"/>
- </lcd>
- <imageList>
- <mainImage>default_R90.png</mainImage>
- <keyPressedImage>default_R90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="23" top="310" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="105" top="690" width="88" height="24"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="1058" top="690" width="88" height="24"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="965" top="690" width="88" height="24"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- </rotations>
- <colors>
- <hoverColor B="255" G="255" R="255" />
- </colors>
-</EmulatorUI>
+++ /dev/null
-skin.name=Phone 1btn 600x1024
-resolution.width=600
-resolution.height=1024
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <dbi version="2.0"/>
+ <rotations>
+ <rotation name="Portrait">
+ <lcd id="0">
+ <region left="67" top="116" width="720" height="1280"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_0.png</mainImage>
+ <keyPressedImage>default_0_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="390" top="1401" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="841" top="1309" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="841" top="108" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="841" top="219" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Landscape">
+ <lcd id="0">
+ <region left="116" top="78" width="1280" height="720"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_L90.png</mainImage>
+ <keyPressedImage>default_L90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="1400" top="392" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1308" top="2" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="108" top="2" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="217" top="2" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Portrait">
+ <lcd id="0">
+ <region left="78" top="117" width="720" height="1280"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_180.png</mainImage>
+ <keyPressedImage>default_180_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="390" top="30" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="110" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="1310" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="2" top="1200" width="24" height="96"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ <rotation name="Reverse Landscape">
+ <lcd id="0">
+ <region left="117" top="67" width="1280" height="720"/>
+ </lcd>
+ <imageList>
+ <mainImage>default_R90.png</mainImage>
+ <keyPressedImage>default_R90_p.png</keyPressedImage>
+ </imageList>
+ <keyMapList>
+ <keyMap>
+ <region left="28" top="391" width="84" height="84"/>
+ <eventInfo>
+ <keyCode>139</keyCode>
+ <keyName>Home</keyName>
+ </eventInfo>
+ <tooltip>Home</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="109" top="841" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>116</keyCode>
+ <keyName>Power</keyName>
+ </eventInfo>
+ <tooltip>Power</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1309" top="841" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>115</keyCode>
+ <keyName>Volume +</keyName>
+ </eventInfo>
+ <tooltip>Volume +</tooltip>
+ </keyMap>
+ <keyMap>
+ <region left="1199" top="841" width="96" height="24"/>
+ <eventInfo>
+ <keyCode>114</keyCode>
+ <keyName>Volume -</keyName>
+ </eventInfo>
+ <tooltip>Volume -</tooltip>
+ </keyMap>
+ </keyMapList>
+ </rotation>
+ </rotations>
+ <colors>
+ <hoverColor B="255" G="255" R="255" />
+ </colors>
+</EmulatorUI>
--- /dev/null
+skin.name=Phone 1btn 720x1280
+resolution.width=720
+resolution.height=1280
+manager.priority=2
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <dbi version="2.0"/>
- <rotations>
- <rotation name="Portrait">
- <lcd id="0">
- <region left="67" top="116" width="720" height="1280"/>
- </lcd>
- <imageList>
- <mainImage>default_0.png</mainImage>
- <keyPressedImage>default_0_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="390" top="1401" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="841" top="1309" width="24" height="96"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="841" top="108" width="24" height="96"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="841" top="219" width="24" height="96"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Landscape">
- <lcd id="0">
- <region left="116" top="78" width="1280" height="720"/>
- </lcd>
- <imageList>
- <mainImage>default_L90.png</mainImage>
- <keyPressedImage>default_L90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="1400" top="392" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="1308" top="2" width="96" height="24"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="108" top="2" width="96" height="24"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="217" top="2" width="96" height="24"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Portrait">
- <lcd id="0">
- <region left="78" top="117" width="720" height="1280"/>
- </lcd>
- <imageList>
- <mainImage>default_180.png</mainImage>
- <keyPressedImage>default_180_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="390" top="30" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="110" width="24" height="96"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="1310" width="24" height="96"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="2" top="1200" width="24" height="96"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Reverse Landscape">
- <lcd id="0">
- <region left="117" top="67" width="1280" height="720"/>
- </lcd>
- <imageList>
- <mainImage>default_R90.png</mainImage>
- <keyPressedImage>default_R90_p.png</keyPressedImage>
- </imageList>
- <keyMapList>
- <keyMap>
- <region left="28" top="391" width="84" height="84"/>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <region left="109" top="841" width="96" height="24"/>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <region left="1309" top="841" width="96" height="24"/>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <region left="1199" top="841" width="96" height="24"/>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- </rotations>
- <colors>
- <hoverColor B="255" G="255" R="255" />
- </colors>
-</EmulatorUI>
+++ /dev/null
-skin.name=Phone 1btn 720x1280
-resolution.width=720
-resolution.height=1280
-manager.priority=2
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<EmulatorUI xmlns="http://www.tizen.org/emulator/skin/dbi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <dbi version="2.0"/>
- <rotations>
- <rotation name="Portrait">
- <lcd id="0">
- </lcd>
- <keyMapList>
- <keyMap>
- <eventInfo>
- <keyCode>139</keyCode>
- <keyName>Home</keyName>
- </eventInfo>
- <tooltip>Home</tooltip>
- </keyMap>
- <keyMap>
- <eventInfo>
- <keyCode>116</keyCode>
- <keyName>Power</keyName>
- </eventInfo>
- <tooltip>Power</tooltip>
- </keyMap>
- <keyMap>
- <eventInfo>
- <keyCode>115</keyCode>
- <keyName>Volume +</keyName>
- </eventInfo>
- <tooltip>Volume +</tooltip>
- </keyMap>
- <keyMap>
- <eventInfo>
- <keyCode>114</keyCode>
- <keyName>Volume -</keyName>
- </eventInfo>
- <tooltip>Volume -</tooltip>
- </keyMap>
- </keyMapList>
- </rotation>
- <rotation name="Landscape">
- <lcd id="0">
- </lcd>
- </rotation>
- <rotation name="Reverse Portrait">
- <lcd id="0">
- </lcd>
- </rotation>
- <rotation name="Reverse Landscape">
- <lcd id="0">
- </lcd>
- </rotation>
- </rotations>
- <colors>
- <hoverColor B="255" G="255" R="255" />
- </colors>
-</EmulatorUI>
+++ /dev/null
-skin.name=General purpose 1btn
-resolution.width=all
-resolution.height=all
-manager.priority=0
/**
- *
+ * Multi-touch
*
* Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
}
}
- if (count != 0) {
+ /* if (count != 0) {
this.grabFingerID = 0;
- }
+ } */
return count;
}
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
+import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
+import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
@Override
public void displayOff() {
logger.info("display off");
- /* do nothing */
+
+ if (isDisplayDragging == true) {
+ logger.info("auto release : mouseEvent");
+ MouseEventData mouseEventData = new MouseEventData(
+ 0, MouseEventType.RELEASE.value(),
+ 0, 0, 0, 0, 0);
+
+ communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData);
+ }
}
@Override
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
+import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.exception.ScreenShotException;
public void run() {
stopRequest = false;
- Image temp;
int sizeFramebuffer = widthFB * heightFB;
while (!stopRequest) {
public void displayOff() {
logger.info("display off");
+ if (isDisplayDragging == true) {
+ logger.info("auto release : mouseEvent");
+ MouseEventData mouseEventData = new MouseEventData(
+ 0, MouseEventType.RELEASE.value(),
+ 0, 0, 0, 0, 0);
+
+ communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData);
+ }
+
if (pollThread.isAlive()) {
pollThread.setWaitIntervalTime(0);
import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.layout.GeneralPurposeSkinComposer;
import org.tizen.emulator.skin.layout.ISkinComposer;
-import org.tizen.emulator.skin.layout.PhoneShapeSkinComposer;
+import org.tizen.emulator.skin.layout.ProfileSpecificSkinComposer;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
import org.tizen.emulator.skin.util.SkinRotation;
private EmulatorSkin reopenSkin;
private boolean reopen;
- private SkinReopenPolicy( EmulatorSkin reopenSkin, boolean reopen ) {
+ private SkinReopenPolicy(EmulatorSkin reopenSkin, boolean reopen) {
this.reopenSkin = reopenSkin;
this.reopen = reopen;
}
public boolean isReopen() {
return reopen;
}
-
}
public enum SkinBasicColor {
protected EmulatorSkinState currentState;
- private boolean isDragStartedInLCD;
+ protected boolean isDisplayDragging;
+ protected Point shellGrabPosition;
private boolean isShutdownRequested;
private boolean isAboutToReopen;
private boolean isOnTop;
SkinUtil.setTopMost(shell, true);
}
+ this.shellGrabPosition = new Point(-1, -1);
+
this.displayCanvasStyle = displayCanvasStyle;
/* generate a pair tag color of key window */
imageRegistry = ImageRegistry.getInstance();
if (skinInfo.isPhoneShape() == true) { /* phone shape skin */
- skinComposer = new PhoneShapeSkinComposer(config, this,
+ skinComposer = new ProfileSpecificSkinComposer(config, this,
shell, currentState, imageRegistry, communicator);
- ((PhoneShapeSkinComposer) skinComposer).addPhoneShapeListener(shell);
+ ((ProfileSpecificSkinComposer) skinComposer).addPhoneShapeListener(shell);
} else { /* general purpose skin */
skinComposer = new GeneralPurposeSkinComposer(config, this,
shell, currentState, imageRegistry);
}
protected void skinFinalize() {
+ logger.info("skinFinalize");
+
skinComposer.composerFinalize();
}
+ /* window grabbing */
+ public void grabShell(int x, int y) {
+ shellGrabPosition.x = x;
+ shellGrabPosition.y = y;
+ }
+
+ public void ungrabShell() {
+ shellGrabPosition.x = -1;
+ shellGrabPosition.y = -1;
+ }
+
+ public boolean isShellGrabbing() {
+ return shellGrabPosition.x >= 0 && shellGrabPosition.y >= 0;
+ }
+
+ public Point getGrabPosition() {
+ if (isShellGrabbing() == false) {
+ return null;
+ }
+
+ return shellGrabPosition;
+ }
+
private void addMainWindowListener(final Shell shell) {
shellListener = new ShellListener() {
shellMenuDetectListener = new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
- Menu menu = EmulatorSkin.this.contextMenu;
+ if (isDisplayDragging == true || isShellGrabbing() == true
+ || isShutdownRequested == true) {
+ logger.info("menu is blocked");
+
+ e.doit = false;
+ return;
+ }
+
+ Menu menu = contextMenu;
+ keyForceRelease(true);
if (menu != null) {
shell.setMenu(menu);
canvasMenuDetectListener = new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
- Menu menu = EmulatorSkin.this.contextMenu;
+ if (isDisplayDragging == true || isShellGrabbing() == true
+ || isShutdownRequested == true) {
+ logger.info("menu is blocked");
+
+ e.doit = false;
+ return;
+ }
+
+ Menu menu = contextMenu;
keyForceRelease(true);
- if (menu != null && EmulatorSkin.this.isDragStartedInLCD == false) {
+ if (menu != null) {
lcdCanvas.setMenu(menu);
menu.setVisible(true);
+
e.doit = false;
} else {
lcdCanvas.setMenu(null);
@Override
public void mouseMove( MouseEvent e ) {
- if ( true == EmulatorSkin.this.isDragStartedInLCD ) { //true = mouse down
+ if (true == isDisplayDragging) { //true = mouse down
int eventType = MouseEventType.DRAG.value();
Point canvasSize = canvas.getSize();
if ( e.x < 0 ) {
e.x = 0;
eventType = MouseEventType.RELEASE.value();
- EmulatorSkin.this.isDragStartedInLCD = false;
+ isDisplayDragging = false;
} else if ( e.x >= canvasSize.x ) {
e.x = canvasSize.x - 1;
eventType = MouseEventType.RELEASE.value();
- EmulatorSkin.this.isDragStartedInLCD = false;
+ isDisplayDragging = false;
}
if ( e.y < 0 ) {
e.y = 0;
eventType = MouseEventType.RELEASE.value();
- EmulatorSkin.this.isDragStartedInLCD = false;
+ isDisplayDragging = false;
} else if ( e.y >= canvasSize.y ) {
e.y = canvasSize.y - 1;
eventType = MouseEventType.RELEASE.value();
- EmulatorSkin.this.isDragStartedInLCD = false;
+ isDisplayDragging = false;
}
int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
logger.info("mouseUp in display" +
" x:" + geometry[0] + " y:" + geometry[1]);
- if (true == EmulatorSkin.this.isDragStartedInLCD) {
- EmulatorSkin.this.isDragStartedInLCD = false;
+ if (true == isDisplayDragging) {
+ isDisplayDragging = false;
}
if (SwtUtil.isMacPlatform()) {
logger.info("mouseDown in display" +
" x:" + geometry[0] + " y:" + geometry[1]);
- if (false == EmulatorSkin.this.isDragStartedInLCD) {
- EmulatorSkin.this.isDragStartedInLCD = true;
+ if (false == isDisplayDragging) {
+ isDisplayDragging = true;
}
if (SwtUtil.isMacPlatform()) {
@Override
public void keyReleased(KeyEvent e) {
if (logger.isLoggable(Level.INFO)) {
- logger.info("'" + e.character + "':" +
- e.keyCode + ":" + e.stateMask + ":" + e.keyLocation);
+ String character =
+ (e.character == '\0') ? "\\0" :
+ (e.character == '\n') ? "\\n" :
+ (e.character == '\r') ? "\\r" :
+ ("" + e.character);
+
+ logger.info("'" + character + "':"
+ + e.keyCode + ":"
+ + e.stateMask + ":"
+ + e.keyLocation);
} else if (logger.isLoggable(Level.FINE)) {
logger.fine(e.toString());
}
int keyCode = e.keyCode;
int stateMask = e.stateMask;
- previous = null;
+ if (SwtUtil.isWindowsPlatform() == true) {
+ if (disappearEvent == true) {
+ /* generate a disappeared key event in Windows */
+ disappearEvent = false;
- /* generate a disappeared key event in Windows */
- if (SwtUtil.isWindowsPlatform() && disappearEvent) {
- disappearEvent = false;
- if (isMetaKey(e.keyCode) && e.character != '\0') {
- logger.info("send disappear release : keycode=" + disappearKeycode +
- ", stateMask=" + disappearStateMask +
- ", keyLocation=" + disappearKeyLocation);
+ if (isMetaKey(e.keyCode) && e.character != '\0') {
+ logger.info("send disappear release : keycode=" + disappearKeycode +
+ ", stateMask=" + disappearStateMask +
+ ", keyLocation=" + disappearKeyLocation);
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(),
- disappearKeycode, disappearStateMask, disappearKeyLocation);
- communicator.sendToQEMU(SendCommand.SEND_KEY_EVENT, keyEventData);
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(),
+ disappearKeycode, disappearStateMask, disappearKeyLocation);
+ communicator.sendToQEMU(SendCommand.SEND_KEY_EVENT, keyEventData);
- removePressedKey(keyEventData);
+ removePressedKey(keyEventData);
- disappearKeycode = 0;
- disappearStateMask = 0;
- disappearKeyLocation = 0;
+ disappearKeycode = 0;
+ disappearStateMask = 0;
+ disappearKeyLocation = 0;
+ }
+ }
+
+ if (previous != null) {
+ KeyEventData keyEventData = null;
+
+ /* separate a merged release event */
+ if (previous.keyCode == SWT.CR &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 && e.character == SWT.CR) {
+ logger.info("send upon release : keycode=" + (int)SWT.CR);
+
+ keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(),
+ SWT.CR, 0, 0);
+ } else if (previous.keyCode == SWT.SPACE &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.SPACE)) {
+ logger.info("send upon release : keycode=" + (int)SWT.SPACE);
+
+ keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(),
+ SWT.SPACE, 0, 0);
+ } else if (previous.keyCode == SWT.TAB &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.TAB)) {
+ logger.info("send upon release : keycode=" + (int)SWT.TAB);
+
+ keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(),
+ SWT.TAB, 0, 0);
+ } else if (previous.keyCode == SWT.KEYPAD_CR &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.CR) &&
+ (keyCode != SWT.KEYPAD_CR)) {
+ logger.info("send upon release : keycode=" + (int)SWT.KEYPAD_CR);
+
+ keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(),
+ SWT.KEYPAD_CR, 0, 2);
+ }
+
+ if (keyEventData != null) {
+ communicator.sendToQEMU(SendCommand.SEND_KEY_EVENT,
+ keyEventData);
+ removePressedKey(keyEventData);
+ }
}
}
else if (SwtUtil.isMacPlatform()) {
finger.clearFingerSlot();
logger.info("disable multi-touch");
}
- }
- }
+ }
+ }
+
+ previous = null;
KeyEventData keyEventData = new KeyEventData(
KeyEventType.RELEASED.value(), keyCode, stateMask, e.keyLocation);
previous = e;
if (logger.isLoggable(Level.INFO)) {
- logger.info("'" + e.character + "':" +
- e.keyCode + ":" + e.stateMask + ":" + e.keyLocation);
+ String character =
+ (e.character == '\0') ? "\\0" :
+ (e.character == '\n') ? "\\n" :
+ (e.character == '\r') ? "\\r" :
+ ("" + e.character);
+
+ logger.info("'" + character + "':"
+ + e.keyCode + ":"
+ + e.stateMask + ":"
+ + e.keyLocation);
} else if (logger.isLoggable(Level.FINE)) {
logger.fine(e.toString());
}
return;
}
- int portSdb = config.getArgInt(ArgsConstants.NET_BASE_PORT);
+ int portSdb = config.getArgInt(ArgsConstants.NET_BASE_PORT) + 1;
ProcessBuilder procSdb = new ProcessBuilder();
int answer = SkinUtil.openMessage(shell, null,
"If you force stop an emulator, it may cause some problems.\n" +
- "Are you sure you want to contiue?",
+ "Are you sure you want to continue?",
SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL, config);
if (answer == SWT.OK) {
}
public void shutdown() {
+ logger.info("shutdown the skin process");
isShutdownRequested = true;
EmulatorSkin.this.shell.close();
}
}
- } );
+ });
}
}
}
public void keyForceRelease(boolean isMetaFilter) {
+ if (isShutdownRequested == true) {
+ return;
+ }
+
/* key event compensation */
if (pressedKeyEventList.isEmpty() == false) {
for (KeyEventData data : pressedKeyEventList) {
KeyEventType.RELEASED.value(), data.keycode,
data.stateMask, data.keyLocation);
communicator.sendToQEMU(
- SendCommand.SEND_KEY_EVENT, keyEventData, false);
+ SendCommand.SEND_KEY_EVENT, keyEventData);
- logger.info("auto release : keycode=" + keyEventData.keycode +
- ", stateMask=" + keyEventData.stateMask +
- ", keyLocation=" + keyEventData.keyLocation);
+ logger.info("auto release : keycode=" + keyEventData.keycode
+ + ", stateMask=" + keyEventData.stateMask
+ + ", keyLocation=" + keyEventData.keyLocation);
}
}
/**
- *
+ * Emulator Skin Main
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
+import org.tizen.emulator.skin.util.CocoaUtil;
import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.JaxbUtil;
import org.tizen.emulator.skin.util.SkinUtil;
*/
public static void main(String[] args) {
- if(SwtUtil.isMacPlatform()) {
- //TODO: event handling of about dialog
+ /* make vm name and remove unused menu for macos-x */
+ if (SwtUtil.isMacPlatform()) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Emulator");
+ System.setProperty("com.apple.mrj.application.apple.menu.about.name",
+ "Emulator");
+ Display display = Display.getDefault();
+ display.syncExec(new Runnable() {
+ public void run() {
+ new CocoaUtil().removeTopMenuItems();
+ }
+ });
}
String simpleMsg = getSimpleMsg(args);
logger = SkinLogger.getSkinLogger(EmulatorSkinMain.class).getLogger();
logger.info("!!! Start Emualtor Skin !!!");
- logger.info("java.version: " + System.getProperty("java.version"));
- logger.info("java vendor: " + System.getProperty("java.vendor"));
- logger.info("vm version: " + System.getProperty("java.vm.version"));
- logger.info("vm vendor: " + System.getProperty("java.vm.vendor"));
- logger.info("vm name: " + System.getProperty("java.vm.name"));
- logger.info("os name: " + System.getProperty("os.name"));
- logger.info("os arch: " + System.getProperty("os.arch"));
- logger.info("os version: " + System.getProperty("os.version"));
+ logger.info("java.version : " + System.getProperty("java.version"));
+ logger.info("java vendor : " + System.getProperty("java.vendor"));
+ logger.info("vm version : " + System.getProperty("java.vm.version"));
+ logger.info("vm vendor : " + System.getProperty("java.vm.vendor"));
+ logger.info("vm name : " + System.getProperty("java.vm.name"));
+ logger.info("os name : " + System.getProperty("os.name"));
+ logger.info("os arch : " + System.getProperty("os.arch"));
+ logger.info("os version : " + System.getProperty("os.version"));
+ logger.info("swt platform : " + SWT.getPlatform());
+ logger.info("swt version : " + SWT.getVersion());
/* startup arguments parsing */
Map<String, String> argsMap = parsArgs(args);
}
};
+ sendThread.setDaemon(true);
sendThread.start();
try {
}
- public synchronized DataTranfer sendToQEMU(
+ public synchronized DataTranfer sendDataToQEMU(
SendCommand command, ISendData data, boolean useDataTransfer) {
DataTranfer dataTranfer = null;
return new Point(imageButton[0].getImageData().width,
imageButton[0].getImageData().height);
}
-}
+}
\ No newline at end of file
/* attach HW keys */
if (keyMapList != null && keyMapList.isEmpty() == false) {
for (KeyMapType keyEntry : keyMapList) {
- CustomButton HWKeyButton = new CustomButton(composite,
+ final CustomButton HWKeyButton = new CustomButton(composite,
SWT.NO_FOCUS, imageNormal, imageHover, imagePushed);
HWKeyButton.setText(keyEntry.getEventInfo().getKeyName());
HWKeyButton.setToolTipText(keyEntry.getTooltip());
HWKeyButton.addMouseListener(new MouseListener() {
@Override
public void mouseDown(MouseEvent e) {
+ logger.info(HWKeyButton.getText() + " key is pressed");
+
KeyEventData keyEventData = new KeyEventData(
KeyEventType.PRESSED.value(), keycode, 0, 0);
communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
@Override
public void mouseUp(MouseEvent e) {
+ logger.info(HWKeyButton.getText() + " key is released");
+
KeyEventData keyEventData = new KeyEventData(
KeyEventType.RELEASED.value(), keycode, 0, 0);
communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
String infoData = null;
- DataTranfer dataTranfer = communicator.sendToQEMU( SendCommand.DETAIL_INFO, null, true );
+ DataTranfer dataTranfer =
+ communicator.sendDataToQEMU(SendCommand.DETAIL_INFO, null, true);
byte[] receivedData = communicator.getReceivedData( dataTranfer );
if ( null != receivedData ) {
/**
*
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
if (y < monitorBounds.y) {
y = monitorBounds.y;
- } else if ((y + width) > (monitorBounds.y + monitorBounds.height)) {
+ } else if ((y + height) > (monitorBounds.y + monitorBounds.height)) {
y = (monitorBounds.y + monitorBounds.height) - height;
}
/**
- *
+ * General-Purpose Skin Layout
*
* Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.EmulatorSkinState;
import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
-import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
-import org.tizen.emulator.skin.comm.sock.data.DisplayStateData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
private MouseMoveListener shellMouseMoveListener;
private MouseListener shellMouseListener;
- private boolean isGrabbedShell;
- private Point grabPosition;
-
public GeneralPurposeSkinComposer(EmulatorConfig config, EmulatorSkin skin,
Shell shell, EmulatorSkinState currentState,
ImageRegistry imageRegistry) {
this.shell = shell;
this.currentState = currentState;
this.imageRegistry = imageRegistry;
- this.isGrabbedShell= false;
- this.grabPosition = new Point(0, 0);
this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
this.backgroundColor = new Color(shell.getDisplay(), new RGB(38, 38, 38));
//shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
shell.setLocation(x, y);
+ /* This string must match the definition of Emulator-Manager */
String emulatorName = SkinUtil.makeEmulatorName(config);
shell.setText("Emulator - " + emulatorName);
currentState.getCurrentResolutionHeight(), scale, rotationId);
if (displayBounds == null) {
- logger.severe("Failed to lcd information for phone shape skin.");
+ logger.severe("Failed to read display information for skin.");
SkinUtil.openMessage(shell, null,
- "Failed to read lcd information for phone shape skin.\n" +
+ "Failed to read display information for skin.\n" +
"Check the contents of skin dbi file.",
SWT.ICON_ERROR, config);
System.exit(-1);
}
/* set window size */
- if (currentState.getCurrentImage() != null) {
- ImageData imageData = currentState.getCurrentImage().getImageData();
- shell.setMinimumSize(imageData.width, imageData.height);
- }
-
- shell.pack();
-
if (currentState.getCurrentImage() != null) {
ImageData imageData = currentState.getCurrentImage().getImageData();
shell.setSize(imageData.width, imageData.height);
public void paintControl(final PaintEvent e) {
if (currentState.isNeedToUpdateDisplay() == true) {
currentState.setNeedToUpdateDisplay(false);
+ }
- if (skin.communicator.isSensorDaemonStarted() == true) {
- /* Let's do one more update for sdl display surface
- while skipping of framebuffer drawing */
- DisplayStateData lcdStateData = new DisplayStateData(
- currentState.getCurrentScale(), currentState.getCurrentRotationId());
- skin.communicator.sendToQEMU(
- SendCommand.CHANGE_LCD_STATE, lcdStateData, false);
- }
+ /* set window size once again (for ubuntu 12.04) */
+ if (currentState.getCurrentImage() != null) {
+ ImageData imageData = currentState.getCurrentImage().getImageData();
+ shell.setSize(imageData.width, imageData.height);
}
/* general shell does not support native transparency,
- * so draw image with GC. */
+ so draw image with GC */
if (currentState.getCurrentImage() != null) {
e.gc.drawImage(currentState.getCurrentImage(), 0, 0);
}
shellMouseMoveListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */) {
+ if (skin.isShellGrabbing() == true && e.button == 0/* left button */) {
/* move a window */
Point previousLocation = shell.getLocation();
- int x = previousLocation.x + (e.x - grabPosition.x);
- int y = previousLocation.y + (e.y - grabPosition.y);
+ Point grabLocation = skin.getGrabPosition();
+ if (grabLocation != null) {
+ int x = previousLocation.x + (e.x - grabLocation.x);
+ int y = previousLocation.y + (e.y - grabLocation.y);
- shell.setLocation(x, y);
+ shell.setLocation(x, y);
+ }
if (skin.keyWindow != null &&
skin.keyWindow.getDockPosition() != SWT.NONE) {
if (e.button == 1) { /* left button */
logger.info("mouseUp in Skin");
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
+ skin.ungrabShell();
if (skin.keyWindow != null &&
skin.keyWindow.getDockPosition() != SWT.NONE) {
if (1 == e.button) { /* left button */
logger.info("mouseDown in Skin");
- isGrabbedShell = true;
- grabPosition.x = e.x;
- grabPosition.y = e.y;
+ skin.grabShell(e.x, e.y);
}
}
/**
+ * Hardware Key
*
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
import org.tizen.emulator.skin.util.SkinUtil;
public class HWKey {
+ private String name;
private int keyCode;
private SkinRegion region;
private String tooltip;
+ /**
+ * Constructor
+ */
public HWKey() {
+ this.name = "unknown";
this.keyCode = SkinUtil.UNKNOWN_KEYCODE;
}
+ public HWKey(String name, int keyCode, SkinRegion region, String tooltip) {
+ this.name = name;
+ this.keyCode = keyCode;
+ this.region = region;
+ this.tooltip = tooltip;
+ }
+
+ /* name */
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
/* keycode */
public int getKeyCode() {
return keyCode;
+++ /dev/null
-/**
- *
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, 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 General Public License for more details.
- *
- * You should have received a copy of the GNU 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.emulator.skin.layout;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.skin.EmulatorSkin;
-import org.tizen.emulator.skin.EmulatorSkinState;
-import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
-import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
-import org.tizen.emulator.skin.comm.sock.data.DisplayStateData;
-import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
-import org.tizen.emulator.skin.config.EmulatorConfig;
-import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
-import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
-import org.tizen.emulator.skin.custom.CustomProgressBar;
-import org.tizen.emulator.skin.dbi.LcdType;
-import org.tizen.emulator.skin.dbi.RegionType;
-import org.tizen.emulator.skin.dbi.RotationType;
-import org.tizen.emulator.skin.image.ImageRegistry;
-import org.tizen.emulator.skin.image.ImageRegistry.IconName;
-import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
-import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.util.SkinRotation;
-import org.tizen.emulator.skin.util.SkinUtil;
-import org.tizen.emulator.skin.util.SwtUtil;
-
-public class PhoneShapeSkinComposer implements ISkinComposer {
- private Logger logger = SkinLogger.getSkinLogger(
- PhoneShapeSkinComposer.class).getLogger();
-
- private EmulatorConfig config;
- private EmulatorSkin skin;
- private Shell shell;
- private Canvas lcdCanvas;
- private EmulatorSkinState currentState;
- private ImageRegistry imageRegistry;
- private SocketCommunicator communicator;
-
- private PaintListener shellPaintListener;
- private MouseTrackListener shellMouseTrackListener;
- private MouseMoveListener shellMouseMoveListener;
- private MouseListener shellMouseListener;
-
- private boolean isGrabbedShell;
- private Point grabPosition;
-
- public PhoneShapeSkinComposer(EmulatorConfig config, EmulatorSkin skin,
- Shell shell, EmulatorSkinState currentState,
- ImageRegistry imageRegistry, SocketCommunicator communicator) {
- this.config = config;
- this.skin = skin;
- this.shell = shell;
- this.currentState = currentState;
- this.imageRegistry = imageRegistry;
- this.communicator = communicator;
- this.isGrabbedShell= false;
- this.grabPosition = new Point(0, 0);
- }
-
- @Override
- public Canvas compose(int style) {
- lcdCanvas = new Canvas(shell, style);
-
- int x = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X,
- EmulatorConfig.DEFAULT_WINDOW_X);
- int y = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
- EmulatorConfig.DEFAULT_WINDOW_Y);
-
- currentState.setCurrentResolutionWidth(
- config.getArgInt(ArgsConstants.RESOLUTION_WIDTH));
- currentState.setCurrentResolutionHeight(
- config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT));
-
- int scale = SkinUtil.getValidScale(config);
-// int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION,
-// EmulatorConfig.DEFAULT_WINDOW_ROTATION );
- // has to be portrait mode at first booting time
- short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
-
- composeInternal(lcdCanvas, x, y, scale, rotationId);
- logger.info("resolution : " + currentState.getCurrentResolution() +
- ", scale : " + scale);
-
- return lcdCanvas;
- }
-
- @Override
- public void composeInternal(Canvas lcdCanvas,
- int x, int y, int scale, short rotationId) {
-
- //shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- shell.setLocation(x, y);
-
- String emulatorName = SkinUtil.makeEmulatorName(config);
- shell.setText("Emulator - " + emulatorName);
-
- lcdCanvas.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
-
- if (SwtUtil.isWindowsPlatform()) {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE_ICO));
- } else {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE));
- }
-
- /* create a progress bar for booting status */
- skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE);
- skin.bootingProgress.setBackground(
- new Color(shell.getDisplay(), new RGB(38, 38, 38)));
-
- arrangeSkin(scale, rotationId);
-
- if (currentState.getCurrentImage() == null) {
- logger.severe("Failed to load initial skin image file. Kill this skin process.");
- SkinUtil.openMessage(shell, null,
- "Failed to load Skin image file.", SWT.ICON_ERROR, config);
- System.exit(-1);
- }
- }
-
- @Override
- public void arrangeSkin(int scale, short rotationId) {
- currentState.setCurrentScale(scale);
- currentState.setCurrentRotationId(rotationId);
- currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
-
- /* arrange the display */
- Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas,
- currentState.getCurrentResolutionWidth(),
- currentState.getCurrentResolutionHeight(), scale, rotationId);
-
- if (lcdBounds == null) {
- logger.severe("Failed to lcd information for phone shape skin.");
- SkinUtil.openMessage(shell, null,
- "Failed to read lcd information for phone shape skin.\n" +
- "Check the contents of skin dbi file.",
- SWT.ICON_ERROR, config);
- System.exit(-1);
- }
- logger.info("lcd bounds : " + lcdBounds);
-
- currentState.setDisplayBounds(lcdBounds);
- if (SwtUtil.isMacPlatform() == true) {
- lcdCanvas.setBounds(currentState.getDisplayBounds());
- }
-
- /* arrange the skin image */
- Image tempImage = null;
- Image tempKeyPressedImage = null;
-
- if (currentState.getCurrentImage() != null) {
- tempImage = currentState.getCurrentImage();
- }
- if (currentState.getCurrentKeyPressedImage() != null) {
- tempKeyPressedImage = currentState.getCurrentKeyPressedImage();
- }
-
- currentState.setCurrentImage(SkinUtil.createScaledImage(
- imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_MAIN));
- currentState.setCurrentKeyPressedImag(SkinUtil.createScaledImage(
- imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_PRESSED));
-
- if (tempImage != null) {
- tempImage.dispose();
- }
- if (tempKeyPressedImage != null) {
- tempKeyPressedImage.dispose();
- }
-
- /* arrange the progress bar */
- if (skin.bootingProgress != null) {
- skin.bootingProgress.setBounds(lcdBounds.x,
- lcdBounds.y + lcdBounds.height + 1, lcdBounds.width, 2);
- }
-
- /* set window size */
- if (currentState.getCurrentImage() != null) {
- ImageData imageData = currentState.getCurrentImage().getImageData();
- shell.setMinimumSize(imageData.width, imageData.height);
- }
-
- shell.pack();
-
- /* set window size */
- if (currentState.getCurrentImage() != null) {
- ImageData imageData = currentState.getCurrentImage().getImageData();
- shell.setSize(imageData.width, imageData.height);
- }
-
- /* custom window shape */
- SkinUtil.trimShell(shell, currentState.getCurrentImage());
-
- currentState.setNeedToUpdateDisplay(true);
- shell.redraw();
- }
-
- @Override
- public Rectangle adjustLcdGeometry(
- Canvas lcdCanvas, int resolutionW, int resolutionH,
- int scale, short rotationId) {
- Rectangle lcdBounds = new Rectangle(0, 0, 0, 0);
-
- float convertedScale = SkinUtil.convertScale(scale);
- RotationType rotation = SkinRotation.getRotation(rotationId);
-
- LcdType lcd = rotation.getLcd(); /* from dbi */
- if (lcd == null) {
- return null;
- }
-
- RegionType region = lcd.getRegion();
- if (region == null) {
- return null;
- }
-
- Integer left = region.getLeft();
- Integer top = region.getTop();
- Integer width = region.getWidth();
- Integer height = region.getHeight();
-
- lcdBounds.x = (int) (left * convertedScale);
- lcdBounds.y = (int) (top * convertedScale);
- lcdBounds.width = (int) (width * convertedScale);
- lcdBounds.height = (int) (height * convertedScale);
-
- return lcdBounds;
- }
-
- public void addPhoneShapeListener(final Shell shell) {
- shellPaintListener = new PaintListener() {
- @Override
- public void paintControl(final PaintEvent e) {
- if (currentState.isNeedToUpdateDisplay() == true) {
- currentState.setNeedToUpdateDisplay(false);
- if (SwtUtil.isMacPlatform() == false) {
- lcdCanvas.setBounds(currentState.getDisplayBounds());
- }
-
- if (skin.communicator.isSensorDaemonStarted() == true) {
- /* Let's do one more update for sdl display surface
- while skipping of framebuffer drawing */
- DisplayStateData lcdStateData = new DisplayStateData(
- currentState.getCurrentScale(), currentState.getCurrentRotationId());
- skin.communicator.sendToQEMU(
- SendCommand.CHANGE_LCD_STATE, lcdStateData, false);
- }
- }
-
- /* general shell does not support native transparency,
- * so draw image with GC. */
- if (currentState.getCurrentImage() != null) {
- e.gc.drawImage(currentState.getCurrentImage(), 0, 0);
- }
-
- }
- };
-
- shell.addPaintListener(shellPaintListener);
-
- shellMouseTrackListener = new MouseTrackAdapter() {
- @Override
- public void mouseExit(MouseEvent e) {
- /* shell does not receive event only with MouseMoveListener
- * in case that : hover hardkey -> mouse move into LCD area */
- HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
-
- if (hoveredHWKey != null) {
- shell.redraw(hoveredHWKey.getRegion().x,
- hoveredHWKey.getRegion().y,
- hoveredHWKey.getRegion().width,
- hoveredHWKey.getRegion().height, false);
-
- currentState.setCurrentHoveredHWKey(null);
- shell.setToolTipText(null);
- }
- }
- };
-
- shell.addMouseTrackListener(shellMouseTrackListener);
-
- shellMouseMoveListener = new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- if (isGrabbedShell == true && e.button == 0/* left button */ &&
- currentState.getCurrentPressedHWKey() == null) {
- /* move a window */
- Point previousLocation = shell.getLocation();
- int x = previousLocation.x + (e.x - grabPosition.x);
- int y = previousLocation.y + (e.y - grabPosition.y);
-
- shell.setLocation(x, y);
- return;
- }
-
- final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
- currentState.getCurrentRotationId(), currentState.getCurrentScale());
- if (hwKey == null) {
- /* remove hover */
- HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
-
- if (hoveredHWKey != null) {
- shell.redraw(hoveredHWKey.getRegion().x,
- hoveredHWKey.getRegion().y,
- hoveredHWKey.getRegion().width,
- hoveredHWKey.getRegion().height, false);
-
- currentState.setCurrentHoveredHWKey(null);
- shell.setToolTipText(null);
- }
-
- return;
- }
-
- /* register a tooltip */
- if (currentState.getCurrentHoveredHWKey() == null &&
- hwKey.getTooltip().isEmpty() == false) {
- shell.setToolTipText(hwKey.getTooltip());
- }
-
- /* draw hover */
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) {
- GC gc = new GC(shell);
- if (gc != null) {
- gc.setLineWidth(1);
- gc.setForeground(currentState.getHoverColor());
- gc.drawRectangle(hwKey.getRegion().x, hwKey.getRegion().y,
- hwKey.getRegion().width - 1, hwKey.getRegion().height - 1);
-
- gc.dispose();
-
- currentState.setCurrentHoveredHWKey(hwKey);
- }
- }
- }
- });
-
- }
- };
-
- shell.addMouseMoveListener(shellMouseMoveListener);
-
- shellMouseListener = new MouseListener() {
- @Override
- public void mouseUp(MouseEvent e) {
- if (e.button == 1) { /* left button */
- logger.info("mouseUp in Skin");
-
- isGrabbedShell = false;
- grabPosition.x = grabPosition.y = 0;
-
- HWKey pressedHWKey = currentState.getCurrentPressedHWKey();
- if (pressedHWKey == null) {
- return;
- }
-
- if (pressedHWKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) {
- /* send event */
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), pressedHWKey.getKeyCode(), 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
-
- currentState.setCurrentPressedHWKey(null);
-
- /* roll back a keyPressed image region */
- shell.redraw(pressedHWKey.getRegion().x, pressedHWKey.getRegion().y,
- pressedHWKey.getRegion().width, pressedHWKey.getRegion().height, false);
-
- if (pressedHWKey.getKeyCode() != 101) { // TODO: not necessary for home key
- SkinUtil.trimShell(shell, currentState.getCurrentImage(),
- pressedHWKey.getRegion().x, pressedHWKey.getRegion().y,
- pressedHWKey.getRegion().width, pressedHWKey.getRegion().height);
- }
- }
- }
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (1 == e.button) { /* left button */
- logger.info("mouseDown in Skin");
-
- isGrabbedShell = true;
- grabPosition.x = e.x;
- grabPosition.y = e.y;
-
- final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
- currentState.getCurrentRotationId(), currentState.getCurrentScale());
- if (hwKey == null) {
- return;
- }
-
- if (hwKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) {
- /* send event */
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.PRESSED.value(), hwKey.getKeyCode(), 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
-
- currentState.setCurrentPressedHWKey(hwKey);
-
- shell.setToolTipText(null);
-
- /* draw the HW key region as the cropped keyPressed image area */
- if (hwKey.getRegion() != null &&
- hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) {
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- if (currentState.getCurrentKeyPressedImage() != null) {
- GC gc = new GC(shell);
- if (gc != null) {
- gc.drawImage(currentState.getCurrentKeyPressedImage(),
- hwKey.getRegion().x, hwKey.getRegion().y,
- hwKey.getRegion().width, hwKey.getRegion().height, //src
- hwKey.getRegion().x, hwKey.getRegion().y,
- hwKey.getRegion().width, hwKey.getRegion().height); //dst
-
- gc.dispose();
-
- if (hwKey.getKeyCode() != 101) { // TODO: not necessary for home key
- SkinUtil.trimShell(shell, currentState.getCurrentKeyPressedImage(),
- hwKey.getRegion().x, hwKey.getRegion().y,
- hwKey.getRegion().width, hwKey.getRegion().height);
- }
-
- }
- }
- } /* end of run */
- });
- }
-
- }
- }
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- /* do nothing */
- }
- };
-
- shell.addMouseListener(shellMouseListener);
- }
-
- @Override
- public void composerFinalize() {
- if (null != shellPaintListener) {
- shell.removePaintListener(shellPaintListener);
- }
-
- if (null != shellMouseTrackListener) {
- shell.removeMouseTrackListener(shellMouseTrackListener);
- }
-
- if (null != shellMouseMoveListener) {
- shell.removeMouseMoveListener(shellMouseMoveListener);
- }
-
- if (null != shellMouseListener) {
- shell.removeMouseListener(shellMouseListener);
- }
- }
-}
--- /dev/null
+/**
+ * Profile-Specific Skin Layout
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.layout;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.skin.EmulatorSkin;
+import org.tizen.emulator.skin.EmulatorSkinState;
+import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
+import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
+import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
+import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
+import org.tizen.emulator.skin.custom.CustomProgressBar;
+import org.tizen.emulator.skin.dbi.LcdType;
+import org.tizen.emulator.skin.dbi.RegionType;
+import org.tizen.emulator.skin.dbi.RotationType;
+import org.tizen.emulator.skin.image.ImageRegistry;
+import org.tizen.emulator.skin.image.ImageRegistry.IconName;
+import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
+import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.util.SkinRotation;
+import org.tizen.emulator.skin.util.SkinUtil;
+import org.tizen.emulator.skin.util.SwtUtil;
+
+public class ProfileSpecificSkinComposer implements ISkinComposer {
+ private Logger logger = SkinLogger.getSkinLogger(
+ ProfileSpecificSkinComposer.class).getLogger();
+
+ private EmulatorConfig config;
+ private EmulatorSkin skin;
+ private Shell shell;
+ private Canvas lcdCanvas;
+ private EmulatorSkinState currentState;
+ private ImageRegistry imageRegistry;
+ private SocketCommunicator communicator;
+
+ private PaintListener shellPaintListener;
+ private MouseTrackListener shellMouseTrackListener;
+ private MouseMoveListener shellMouseMoveListener;
+ private MouseListener shellMouseListener;
+
+ public ProfileSpecificSkinComposer(EmulatorConfig config, EmulatorSkin skin,
+ Shell shell, EmulatorSkinState currentState,
+ ImageRegistry imageRegistry, SocketCommunicator communicator) {
+ this.config = config;
+ this.skin = skin;
+ this.shell = shell;
+ this.currentState = currentState;
+ this.imageRegistry = imageRegistry;
+ this.communicator = communicator;
+ }
+
+ @Override
+ public Canvas compose(int style) {
+ lcdCanvas = new Canvas(shell, style);
+
+ int x = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X,
+ EmulatorConfig.DEFAULT_WINDOW_X);
+ int y = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
+ EmulatorConfig.DEFAULT_WINDOW_Y);
+
+ currentState.setCurrentResolutionWidth(
+ config.getArgInt(ArgsConstants.RESOLUTION_WIDTH));
+ currentState.setCurrentResolutionHeight(
+ config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT));
+
+ int scale = SkinUtil.getValidScale(config);
+// int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION,
+// EmulatorConfig.DEFAULT_WINDOW_ROTATION );
+ // has to be portrait mode at first booting time
+ short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
+
+ composeInternal(lcdCanvas, x, y, scale, rotationId);
+ logger.info("resolution : " + currentState.getCurrentResolution() +
+ ", scale : " + scale);
+
+ return lcdCanvas;
+ }
+
+ @Override
+ public void composeInternal(Canvas lcdCanvas,
+ int x, int y, int scale, short rotationId) {
+
+ //shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ shell.setLocation(x, y);
+
+ /* This string must match the definition of Emulator-Manager */
+ String emulatorName = SkinUtil.makeEmulatorName(config);
+ shell.setText("Emulator - " + emulatorName);
+
+ lcdCanvas.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+
+ if (SwtUtil.isWindowsPlatform()) {
+ shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE_ICO));
+ } else {
+ shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE));
+ }
+
+ /* create a progress bar for booting status */
+ skin.bootingProgress = new CustomProgressBar(shell, SWT.NONE);
+ skin.bootingProgress.setBackground(
+ new Color(shell.getDisplay(), new RGB(38, 38, 38)));
+
+ arrangeSkin(scale, rotationId);
+
+ if (currentState.getCurrentImage() == null) {
+ logger.severe("Failed to load initial skin image file. Kill this skin process.");
+ SkinUtil.openMessage(shell, null,
+ "Failed to load Skin image file.", SWT.ICON_ERROR, config);
+ System.exit(-1);
+ }
+ }
+
+ @Override
+ public void arrangeSkin(int scale, short rotationId) {
+ currentState.setCurrentScale(scale);
+ currentState.setCurrentRotationId(rotationId);
+ currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
+
+ /* arrange the display */
+ Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(), scale, rotationId);
+
+ if (lcdBounds == null) {
+ logger.severe("Failed to read display information for skin.");
+ SkinUtil.openMessage(shell, null,
+ "Failed to read display information for skin.\n" +
+ "Check the contents of skin dbi file.",
+ SWT.ICON_ERROR, config);
+ System.exit(-1);
+ }
+ logger.info("display bounds : " + lcdBounds);
+
+ currentState.setDisplayBounds(lcdBounds);
+
+ /* arrange the skin image */
+ Image tempImage = null;
+ Image tempKeyPressedImage = null;
+
+ if (currentState.getCurrentImage() != null) {
+ tempImage = currentState.getCurrentImage();
+ }
+ if (currentState.getCurrentKeyPressedImage() != null) {
+ tempKeyPressedImage = currentState.getCurrentKeyPressedImage();
+ }
+
+ currentState.setCurrentImage(SkinUtil.createScaledImage(
+ imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_MAIN));
+ currentState.setCurrentKeyPressedImag(SkinUtil.createScaledImage(
+ imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_PRESSED));
+
+ if (tempImage != null) {
+ tempImage.dispose();
+ }
+ if (tempKeyPressedImage != null) {
+ tempKeyPressedImage.dispose();
+ }
+
+ if (SwtUtil.isMacPlatform() == true) {
+ lcdCanvas.setBounds(currentState.getDisplayBounds());
+ }
+
+ /* arrange the progress bar */
+ if (skin.bootingProgress != null) {
+ skin.bootingProgress.setBounds(lcdBounds.x,
+ lcdBounds.y + lcdBounds.height + 1, lcdBounds.width, 2);
+ }
+
+ /* set window size */
+ if (currentState.getCurrentImage() != null) {
+ ImageData imageData = currentState.getCurrentImage().getImageData();
+ shell.setSize(imageData.width, imageData.height);
+ }
+
+ /* custom window shape */
+ SkinUtil.trimShell(shell, currentState.getCurrentImage());
+
+ currentState.setNeedToUpdateDisplay(true);
+ shell.redraw();
+ }
+
+ @Override
+ public Rectangle adjustLcdGeometry(
+ Canvas lcdCanvas, int resolutionW, int resolutionH,
+ int scale, short rotationId) {
+ Rectangle lcdBounds = new Rectangle(0, 0, 0, 0);
+
+ float convertedScale = SkinUtil.convertScale(scale);
+ RotationType rotation = SkinRotation.getRotation(rotationId);
+
+ LcdType lcd = rotation.getLcd(); /* from dbi */
+ if (lcd == null) {
+ return null;
+ }
+
+ RegionType region = lcd.getRegion();
+ if (region == null) {
+ return null;
+ }
+
+ Integer left = region.getLeft();
+ Integer top = region.getTop();
+ Integer width = region.getWidth();
+ Integer height = region.getHeight();
+
+ lcdBounds.x = (int) (left * convertedScale);
+ lcdBounds.y = (int) (top * convertedScale);
+ lcdBounds.width = (int) (width * convertedScale);
+ lcdBounds.height = (int) (height * convertedScale);
+
+ return lcdBounds;
+ }
+
+ public void addPhoneShapeListener(final Shell shell) {
+ shellPaintListener = new PaintListener() {
+ @Override
+ public void paintControl(final PaintEvent e) {
+ if (currentState.isNeedToUpdateDisplay() == true) {
+ currentState.setNeedToUpdateDisplay(false);
+
+ if (SwtUtil.isMacPlatform() == false) {
+ lcdCanvas.setBounds(currentState.getDisplayBounds());
+ }
+ }
+
+ /* set window size once again (for ubuntu 12.04) */
+ if (currentState.getCurrentImage() != null) {
+ ImageData imageData = currentState.getCurrentImage().getImageData();
+ shell.setSize(imageData.width, imageData.height);
+ }
+
+ /* general shell does not support native transparency,
+ so draw image with GC */
+ if (currentState.getCurrentImage() != null) {
+ e.gc.drawImage(currentState.getCurrentImage(), 0, 0);
+ }
+
+ }
+ };
+
+ shell.addPaintListener(shellPaintListener);
+
+ shellMouseTrackListener = new MouseTrackAdapter() {
+ @Override
+ public void mouseExit(MouseEvent e) {
+ /* shell does not receive event only with MouseMoveListener
+ * in case that : hover hardkey -> mouse move into LCD area */
+ HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
+
+ if (hoveredHWKey != null) {
+ shell.redraw(hoveredHWKey.getRegion().x,
+ hoveredHWKey.getRegion().y,
+ hoveredHWKey.getRegion().width,
+ hoveredHWKey.getRegion().height, false);
+
+ currentState.setCurrentHoveredHWKey(null);
+ shell.setToolTipText(null);
+ }
+ }
+ };
+
+ shell.addMouseTrackListener(shellMouseTrackListener);
+
+ shellMouseMoveListener = new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (skin.isShellGrabbing() == true && e.button == 0/* left button */
+ && currentState.getCurrentPressedHWKey() == null) {
+ /* move a window */
+ Point previousLocation = shell.getLocation();
+ Point grabLocation = skin.getGrabPosition();
+ if (grabLocation != null) {
+ int x = previousLocation.x + (e.x - grabLocation.x);
+ int y = previousLocation.y + (e.y - grabLocation.y);
+
+ shell.setLocation(x, y);
+ }
+ return;
+ }
+
+ final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
+ final HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
+
+ if (hwKey == null) {
+ if (hoveredHWKey != null) {
+ /* remove hover */
+ shell.redraw(hoveredHWKey.getRegion().x,
+ hoveredHWKey.getRegion().y,
+ hoveredHWKey.getRegion().width,
+ hoveredHWKey.getRegion().height, false);
+
+ currentState.setCurrentHoveredHWKey(null);
+ shell.setToolTipText(null);
+ }
+
+ return;
+ }
+
+ /* register a tooltip */
+ if (hoveredHWKey == null &&
+ hwKey.getTooltip().isEmpty() == false) {
+ shell.setToolTipText(hwKey.getTooltip());
+
+ currentState.setCurrentHoveredHWKey(hwKey);
+
+ /* draw hover */
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if (hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) {
+ GC gc = new GC(shell);
+ if (gc != null) {
+ gc.setLineWidth(1);
+ gc.setForeground(currentState.getHoverColor());
+ gc.drawRectangle(hwKey.getRegion().x, hwKey.getRegion().y,
+ hwKey.getRegion().width - 1, hwKey.getRegion().height - 1);
+
+ gc.dispose();
+ }
+ }
+ }
+ });
+ } else {
+ if (hwKey.getRegion().x != hoveredHWKey.getRegion().x ||
+ hwKey.getRegion().y != hoveredHWKey.getRegion().y) {
+ /* remove hover */
+ shell.redraw(hoveredHWKey.getRegion().x,
+ hoveredHWKey.getRegion().y,
+ hoveredHWKey.getRegion().width,
+ hoveredHWKey.getRegion().height, false);
+
+ currentState.setCurrentHoveredHWKey(null);
+ shell.setToolTipText(null);
+ }
+ }
+ }
+ };
+
+ shell.addMouseMoveListener(shellMouseMoveListener);
+
+ shellMouseListener = new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (e.button == 1) { /* left button */
+ skin.ungrabShell();
+
+ HWKey pressedHWKey = currentState.getCurrentPressedHWKey();
+ if (pressedHWKey == null) {
+ logger.info("mouseUp in Skin");
+ return;
+ }
+
+ if (pressedHWKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) {
+ logger.info(pressedHWKey.getName() + " key is released");
+
+ /* send event */
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(), pressedHWKey.getKeyCode(), 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+
+ currentState.setCurrentPressedHWKey(null);
+
+ /* roll back a keyPressed image region */
+ shell.redraw(pressedHWKey.getRegion().x, pressedHWKey.getRegion().y,
+ pressedHWKey.getRegion().width, pressedHWKey.getRegion().height, false);
+
+ if (pressedHWKey.getKeyCode() != 101) { // TODO: not necessary for home key
+ SkinUtil.trimShell(shell, currentState.getCurrentImage(),
+ pressedHWKey.getRegion().x, pressedHWKey.getRegion().y,
+ pressedHWKey.getRegion().width, pressedHWKey.getRegion().height);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (1 == e.button) { /* left button */
+ skin.grabShell(e.x, e.y);
+
+ /* HW key handling */
+ final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
+ if (hwKey == null) {
+ logger.info("mouseDown in Skin");
+ return;
+ }
+
+ if (hwKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) {
+ logger.info(hwKey.getName() + " key is pressed");
+
+ /* send event */
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.PRESSED.value(), hwKey.getKeyCode(), 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+
+ currentState.setCurrentPressedHWKey(hwKey);
+
+ shell.setToolTipText(null);
+
+ /* draw the HW key region as the cropped keyPressed image area */
+ if (hwKey.getRegion() != null &&
+ hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) {
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ if (currentState.getCurrentKeyPressedImage() != null) {
+ GC gc = new GC(shell);
+ if (gc != null) {
+ gc.drawImage(currentState.getCurrentKeyPressedImage(),
+ hwKey.getRegion().x, hwKey.getRegion().y,
+ hwKey.getRegion().width, hwKey.getRegion().height, //src
+ hwKey.getRegion().x, hwKey.getRegion().y,
+ hwKey.getRegion().width, hwKey.getRegion().height); //dst
+
+ gc.dispose();
+
+ if (hwKey.getKeyCode() != 101) { // TODO: not necessary for home key
+ SkinUtil.trimShell(shell, currentState.getCurrentKeyPressedImage(),
+ hwKey.getRegion().x, hwKey.getRegion().y,
+ hwKey.getRegion().width, hwKey.getRegion().height);
+ }
+
+ }
+ }
+ } /* end of run */
+ });
+ }
+
+ }
+ }
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ };
+
+ shell.addMouseListener(shellMouseListener);
+ }
+
+ @Override
+ public void composerFinalize() {
+ if (null != shellPaintListener) {
+ shell.removePaintListener(shellPaintListener);
+ }
+
+ if (null != shellMouseTrackListener) {
+ shell.removeMouseTrackListener(shellMouseTrackListener);
+ }
+
+ if (null != shellMouseMoveListener) {
+ shell.removeMouseMoveListener(shellMouseMoveListener);
+ }
+
+ if (null != shellMouseListener) {
+ shell.removeMouseListener(shellMouseListener);
+ }
+ }
+}
/**
+ * General Skin Frame Maker
*
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
// TODO: copy alphaData
GC gc = new GC(patchedImage);
+ //gc.setInterpolation(SWT.NONE);
+
gc.setBackground(display.getSystemColor(SWT.COLOR_MAGENTA));
gc.fillRectangle(0, 0, patchedImageWidth, patchedImageHeight);
/**
* Capture a screenshot of the Emulator framebuffer
*
- * Copyright ( C ) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or ( at your option ) any later version.
+ * of the License, 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
this.config = config;
this.scaleLevel = 100d;
- shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX);
+ if (!SwtUtil.isMacPlatform()) {
+ shell = new Shell(parent, SWT.SHELL_TRIM);
+ } else {
+ shell = new Shell(parent.getDisplay(), SWT.SHELL_TRIM);
+ }
shell.setText("Screen Shot - " + SkinUtil.makeEmulatorName(config));
- if(!SwtUtil.isMacPlatform()) {
- if (icon != null) {
- shell.setImage(icon);
- }
- }
+
+ /* To prevent the icon switching on Mac */
+ if (!SwtUtil.isMacPlatform()) {
+ if (icon != null) {
+ shell.setImage(icon);
+ }
+ }
+
shell.addListener( SWT.Close, new Listener() {
@Override
public void handleEvent( Event event ) {
// }
// });
- Rectangle monitorBound = Display.getDefault().getBounds();
- logger.info("host monitor display bound : " + monitorBound);
- Rectangle emulatorBound = parent.getBounds();
- logger.info("current Emulator window bound : " + emulatorBound);
- Rectangle dialogBound = shell.getBounds();
- logger.info("current ScreenShot Dialog bound : " + dialogBound);
+ Rectangle monitorBounds = Display.getDefault().getBounds();
+ logger.info("host monitor display bounds : " + monitorBounds);
+ Rectangle emulatorBounds = parent.getBounds();
+ logger.info("current Emulator window bounds : " + emulatorBounds);
+ Rectangle dialogBounds = shell.getBounds();
+ logger.info("current ScreenShot Dialog bounds : " + dialogBounds);
/* size correction */
- shell.setSize(emulatorBound.width, emulatorBound.height);
- dialogBound = shell.getBounds();
- logger.info("current ScreenShot Dialog bound : " + dialogBound);
+ shell.setSize(emulatorBounds.width, emulatorBounds.height);
+ dialogBounds = shell.getBounds();
+ logger.info("current ScreenShot Dialog bound : " + dialogBounds);
/* location correction */
- int x = emulatorBound.x + emulatorBound.width + 20;
- int y = emulatorBound.y;
- if ((x + dialogBound.width) > (monitorBound.x + monitorBound.width)) {
- x = emulatorBound.x - dialogBound.width - 20;
+ int x = emulatorBounds.x + emulatorBounds.width + 20;
+ int y = emulatorBounds.y;
+ if ((x + dialogBounds.width) > (monitorBounds.x + monitorBounds.width)) {
+ x = emulatorBounds.x - dialogBounds.width - 20;
+ }
+ if (y < monitorBounds.y) {
+ y = monitorBounds.y;
+ } else if ((y + dialogBounds.height) > (monitorBounds.y + monitorBounds.height)) {
+ y = (monitorBounds.y + monitorBounds.height) - dialogBounds.height;
}
shell.setLocation(x, y);
- dialogBound = shell.getBounds();
- logger.info("current ScreenShot Dialog bound : " + dialogBound);
+
+ dialogBounds = shell.getBounds();
+ logger.info("current ScreenShot Dialog bound : " + dialogBounds);
}
}
protected void capture() throws ScreenShotException {
- DataTranfer dataTranfer = communicator.sendToQEMU(
+ DataTranfer dataTranfer = communicator.sendDataToQEMU(
SendCommand.SCREEN_SHOT, null, true);
byte[] receivedData = communicator.getReceivedData(dataTranfer);
--- /dev/null
+/**
+ *
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Munkyu Im <munkyu.im@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.util;
+
+import java.lang.reflect.InvocationTargetException;
+
+public class CocoaUtil {
+
+ private static final long aboutMenuValue = 0;
+ private static final long prefMenuValue = 2;
+ public static final String NSApplication_CLASS = "org.eclipse.swt.internal.cocoa.NSApplication";
+ public static final String NSMenu_CLASS = "org.eclipse.swt.internal.cocoa.NSMenu";
+ public static final String NSMenuItem_CLASS = "org.eclipse.swt.internal.cocoa.NSMenuItem";
+
+ public static Object invokeMethod(Class<?> clazz, Object object, String method, Object[] args)
+ throws IllegalArgumentException, IllegalAccessException, InvocationTargetException,
+ SecurityException, NoSuchMethodException {
+ Class<?>[] signature = new Class[args.length];
+ for (int i = 0; i < args.length; i++) {
+ Class<?> thisClass = args[i].getClass();
+ if (thisClass == Integer.class)
+ signature[i] = int.class;
+ else if (thisClass == Long.class)
+ signature[i] = long.class;
+ else if (thisClass == Byte.class)
+ signature[i] = byte.class;
+ else if ( thisClass == Boolean.class )
+ signature[i] = boolean.class;
+ else
+ signature[i] = thisClass;
+ }
+ return clazz.getDeclaredMethod(method, signature).invoke(object, args);
+ }
+
+ // remove about and preference menu item
+ public void removeTopMenuItems() {
+ try {
+ Class<?> nsmenuClass = Class.forName(NSMenu_CLASS);
+ Class<?> nsmenuitemClass = Class.forName(NSMenuItem_CLASS);
+ Class<?> nsapplicationClass = Class.forName(NSApplication_CLASS);
+
+ Object sharedApplication = nsapplicationClass.getDeclaredMethod(
+ "sharedApplication", (Class<?>[]) null).invoke(null,
+ (Object[]) null);
+ Object mainMenu = sharedApplication.getClass()
+ .getDeclaredMethod("mainMenu", (Class<?>[]) null)
+ .invoke(sharedApplication, (Object[]) null);
+
+ Object mainMenuItem = invokeMethod(nsmenuClass, mainMenu,
+ "itemAtIndex", new Object[] { new Long(0) });
+ Object appMenu = mainMenuItem.getClass()
+ .getDeclaredMethod("submenu", (Class<?>[]) null)
+ .invoke(mainMenuItem, (Object[]) null);
+
+ Object aboutMenuItem = invokeMethod(nsmenuClass, appMenu,
+ "itemAtIndex", new Object[] { new Long(aboutMenuValue) });
+ Object prefMenuItem = invokeMethod(nsmenuClass, appMenu,
+ "itemAtIndex", new Object[] { new Long(prefMenuValue) });
+
+ //set hidden
+ invokeMethod(nsmenuitemClass, aboutMenuItem, "setHidden",
+ new Object[] { new Boolean(true) });
+ invokeMethod(nsmenuitemClass, prefMenuItem, "setHidden",
+ new Object[] { new Boolean(true) });
+
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+}
vmName = EMULATOR_PREFIX;
}
- int portNumber = config.getArgInt( ArgsConstants.NET_BASE_PORT );
+ int portNumber = config.getArgInt( ArgsConstants.NET_BASE_PORT ) + 1;
return vmName + ":" + portNumber;
}
return null;
}
- for (KeyMapType keyMap : keyMapList) {
- RegionType region = keyMap.getRegion();
+ for (KeyMapType keyEntry : keyMapList) {
+ RegionType region = keyEntry.getRegion();
int scaledX = (int) (region.getLeft() * convertedScale);
int scaledY = (int) (region.getTop() * convertedScale);
int scaledWidth = (int) (region.getWidth() * convertedScale);
int scaledHeight = (int) (region.getHeight() * convertedScale);
- if (isInGeometry(currentX, currentY, scaledX, scaledY, scaledWidth, scaledHeight)) {
- EventInfoType eventInfo = keyMap.getEventInfo();
+ if (isInGeometry(currentX, currentY,
+ scaledX, scaledY, scaledWidth, scaledHeight)) {
+ EventInfoType eventInfo = keyEntry.getEventInfo();
- HWKey hwKey = new HWKey();
- hwKey.setKeyCode(eventInfo.getKeyCode());
- hwKey.setRegion(new SkinRegion(scaledX, scaledY, scaledWidth, scaledHeight));
- hwKey.setTooltip(keyMap.getTooltip());
+ HWKey hwKey = new HWKey(
+ keyEntry.getEventInfo().getKeyName(),
+ eventInfo.getKeyCode(),
+ new SkinRegion(scaledX, scaledY, scaledWidth, scaledHeight),
+ keyEntry.getTooltip());
return hwKey;
}
#include "emulator.h"
#include "debug_ch.h"
#include "sdb.h"
-#include "qemu_socket.h"
#include "mloop_event.h"
#include "emul_state.h"
#include "maruskin_keymap.h"
#include "sysemu.h"
#include "sysbus.h"
+#if defined(_WIN32)
+#include "nbd.h"
+#else
+#include "qemu_socket.h"
+#endif
+
#ifdef CONFIG_HAX
#include "guest_debug.h"
int lcd_size_width, int lcd_size_height,
double scale_factor, short rotation_type)
{
- INFO("start_display handle_id:%ld, lcd size:%dx%d, scale_factor:%f, rotation_type:%d\n",
- (long)handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation_type);
+ INFO("start_display handle_id:%ld, display size:%dx%d, \
+scale_factor:%f, rotation_type:%d\n",
+ (long) handle_id, lcd_size_width, lcd_size_height,
+ scale_factor, rotation_type);
set_emul_win_scale(scale_factor);
- maruskin_init(handle_id, lcd_size_width, lcd_size_height, false);
+ maruskin_init(handle_id, lcd_size_width, lcd_size_height);
}
void do_mouse_event(int button_type, int event_type,
int origin_x, int origin_y, int x, int y, int z)
{
if (brightness_off) {
- TRACE("reject mouse touch in lcd off = button:%d, type:%d, x:%d, y:%d, z:%d\n",
- button_type, event_type, x, y, z);
- return;
+ if (button_type == 0) {
+ INFO("auto mouse release\n");
+ kbd_mouse_event(0, 0, 0, 0);
+
+ return;
+ } else {
+ TRACE("reject mouse touch in display off : "
+ "button=%d, type=%d, x=%d, y=%d, z=%d\n",
+ button_type, event_type, x, y, z);
+ return;
+ }
}
TRACE("mouse_event button:%d, type:%d, host:(%d, %d), x:%d, y:%d, z:%d\n",
kbd_mouse_event(x, y, z, 1);
TRACE("mouse_event event_type:%d, origin:(%d, %d), x:%d, y:%d, z:%d\n\n",
- event_type, origin_x, origin_y, x, y, z);
+ event_type, origin_x, origin_y, x, y, z);
break;
case MOUSE_UP:
guest_x = x;
kbd_mouse_event(x, y, z, 0);
TRACE("mouse_event event_type:%d, origin:(%d, %d), x:%d, y:%d, z:%d\n\n",
- event_type, origin_x, origin_y, x, y, z);
+ event_type, origin_x, origin_y, x, y, z);
break;
case MOUSE_WHEELUP:
case MOUSE_WHEELDOWN:
kbd_mouse_event(x, y, -z, event_type);
TRACE("mouse_event event_type:%d, origin:(%d, %d), x:%d, y:%d, z:%d\n\n",
- event_type, origin_x, origin_y, x, y, z);
+ event_type, origin_x, origin_y, x, y, z);
break;
default:
ERR("undefined mouse event type passed:%d\n", event_type);
INFO( "do_rotation_event rotation_type:%d\n", rotation_type);
+ set_emul_rotation( rotation_type );
+}
+
+void send_rotation_event(int rotation_type)
+{
+
+ INFO( "send_rotation_event rotation_type:%d\n", rotation_type);
+
char send_buf[32] = { 0 };
switch ( rotation_type ) {
}
send_to_emuld( "sensor\n\n\n\n", 10, send_buf, 32 );
-
- set_emul_rotation( rotation_type );
-
}
-QemuSurfaceInfo* get_screenshot_info(void)
+void set_maru_screenshot(DisplayState *ds)
{
- DisplaySurface* qemu_display_surface = get_qemu_display_surface();
+ pthread_mutex_lock(&mutex_screenshot);
- if ( !qemu_display_surface ) {
- ERR( "qemu surface is NULL.\n" );
- return NULL;
+ MaruScreenshot *maru_screenshot = get_maru_screenshot();
+ if (maru_screenshot) {
+ maru_screenshot->isReady = 1;
+ if (maru_screenshot->request_screenshot == 1) {
+ memcpy(maru_screenshot->pixel_data,
+ ds_get_data(ds),
+ ds_get_linesize(ds) *
+ ds_get_height(ds));
+ maru_screenshot->request_screenshot = 0;
+
+ pthread_cond_signal(&cond_screenshot);
+ }
}
+ pthread_mutex_unlock(&mutex_screenshot);
+}
- QemuSurfaceInfo* info = (QemuSurfaceInfo*) g_malloc0( sizeof(QemuSurfaceInfo) );
- if ( !info ) {
- ERR( "Fail to malloc for QemuSurfaceInfo.\n");
+QemuSurfaceInfo *get_screenshot_info(void)
+{
+ QemuSurfaceInfo *info =
+ (QemuSurfaceInfo *)g_malloc0(sizeof(QemuSurfaceInfo));
+ if (!info) {
+ ERR("Fail to malloc for QemuSurfaceInfo.\n");
return NULL;
}
- int length = qemu_display_surface->linesize * qemu_display_surface->height;
- INFO( "screenshot data length:%d\n", length );
+ int length = get_emul_lcd_width() * get_emul_lcd_height() * 4;
+ INFO("screenshot data length:%d\n", length);
- if ( 0 >= length ) {
- g_free( info );
- ERR( "screenshot data ( 0 >=length ). length:%d\n", length );
+ if (0 >= length) {
+ g_free(info);
+ ERR("screenshot data ( 0 >=length ). length:%d\n", length);
return NULL;
}
- info->pixel_data = (unsigned char*) g_malloc0( length );
- if ( !info->pixel_data ) {
- g_free( info );
+ info->pixel_data = (unsigned char *)g_malloc0(length);
+ if (!info->pixel_data) {
+ g_free(info);
ERR("Fail to malloc for pixel data.\n");
return NULL;
}
return info;
}
-void free_screenshot_info(QemuSurfaceInfo* info)
+void free_screenshot_info(QemuSurfaceInfo *info)
{
if (info) {
if(info->pixel_data) {
static void send_to_emuld(const char* request_type,
int request_size, const char* send_buf, int buf_size)
{
+#if defined(_WIN32)
+ int s = tcp_socket_outgoing( "127.0.0.1", (uint16_t) ( tizen_base_port + SDB_TCP_EMULD_INDEX ) );
+#else
char addr[128];
int s = 0;
snprintf(addr, 128, ":%u", (uint16_t) (tizen_base_port + SDB_TCP_EMULD_INDEX));
s = inet_connect(addr, true, NULL, NULL);
+#endif
if ( s < 0 ) {
ERR( "can't create socket to emulator daemon in guest\n" );
void do_hardkey_event(int event_type, int keycode);
void do_scale_event(double scale_factor);
void do_rotation_event(int rotation_type);
+void send_rotation_event(int rotation_type);
QemuSurfaceInfo *get_screenshot_info(void);
DetailInfo *get_detail_info(int qemu_argc, char **qemu_argv);
void notify_sdb_daemon_start(void)
{
- INFO("notify_sensor_daemon_start\n");
+ INFO("notify_sdb_daemon_start\n");
is_sdbd_initialized = 1;
if (client_sock) {
int scale = 0;
double scale_ratio = 0.0;
short rotation_type = 0;
+ int is_rotate = 0;
char* p = recvbuf;
memcpy( &scale, p, sizeof( scale ) );
if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation_type ) {
do_rotation_event( rotation_type );
+ is_rotate = 1;
}
#ifndef CONFIG_USE_SHM
maruskin_sdl_resize(); // send sdl event
#endif
+ if (is_rotate) {
+ send_rotation_event( rotation_type );
+ }
+
break;
}
case RECV_SCREEN_SHOT: {